For a while now I have been using VirtualBox to run various windows guest operating systems on my Linux host. One thing that I have always been wary of when using them is how the disk image gradually grows over time. This is because on the host operating system the disk container uses a sparse file so that the virtual disk can appear to be bigger than it actually is, but it can only do this when the guest operating system is not using the space, and the data is effectively set to zero. When you delete a file on the guest operating system it doesn’t bother to set the file contents back to zero, it just removes the record of where the files data was located.
This is not really a problem and most people know that you can use a tool such as sysinternals SDelete to zero the free space. Then using the command
vboxmanage modifyhd --compact <diskimage.vdi>
the space can be reclaimed.
However in windows there is one file in particular called pagefile.sys (also known as the swap file) that is constantly being written to and then subsequently erased. Its possible that windows does this intelligently and re-uses the same sectors of the virtual disk for the pagefile, but it seems more likely to me that windows doesn’t do this, after all it isn’t aware that its really writing to a virtual disk.
What made sense to me was to create a second virtual disk specifically for the pagefile. I made the second disk image immutable. What this means is that all writes to the disk are stored in a differencing image which is thrown away when the guest machine reboots. Because of this I can ensure that it never gets any bigger. This also has some other advantages.
Firstly I can use the same immutable image for all my Virtual machines. These currently include; Windows XP, Windows 7, Windows 8.1, and Windows 10. Secondly because the image is immutable it allows all guests to use the image while all running at the same time.
Thirdly the fun part, I can host the differencing images to the immutable base image in tmpfs meaning that the guests get the advantage of having very fast i/o for their pagefile.sys. This is the advantage I like the most because it certainly seems to improve performance.
For some reason, with each new major version, Ubuntu keeps changing the location of the minimize maximize and close buttons on the window decorations. Its really annoying because as soon as you get used to one way, they put it back the other way. Once and for all I wanted to fix this problem and have my buttons where they should be, where they have always been (for me this was on the right having come from windows)
gconftool-2 --set /apps/metacity/general/button_layout --type string ":minimize,maximize,close"
Now at least I can get used to them in the right place!
EDIT: For ubuntu 13.04 you need to do this:
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
My colleague often says something along the lines of:
I don’t know why everyone has a desktop wallpaper its nothing but a waste of memory
I thought that this sounded somewhat like an urban myth and decided to see if there was any evidence to support or dispell this claim. Well it turns out that although the wallpaper is pushed to video memory for rendering it cant be kept there as if it were just general purpose RAM. So the wallpaper does have to be stored in conventional memory, but is it a waste?
Well assuming a resolution of 1280×1024 and a 32bpp color (4 bytes per pixel) we get:
1280 × 1024 × 4 = 5 MiB
So I am wasting 5 MiB of my 8 GiB of RAM. As a percentage:
5/8192 × 100 ≈ 0.06%
But yes it is a bit of a waste, I should probably turn off my desktop wallpaper.
The android developer guide suggests you install
ia32-libs when developing on a 64bit platform. However this installs some 242 packages. A much more sensible option is to only install the 32bit libraries that are actually needed and then you only have to install 57 new packages. Additionally Quantal Quetzal comes with an up to date version of eclipse (3.8) so you can install this via the package manager as well instead of downloading 3.7 as the guide suggests.
To install the packages simply run the following command:
sudo apt-get install eclipse libgl1-mesa-dev:i386 libsdl1.2debian:i386
The installation of eclipse will also provide a compatible Java runtime required for building android apps.
Suppose you happen to accidentally do
sudo chown -R www-data:www-data * whilst the current directory is
/var. Now that’s a fairly daft thing to do! but we all make mistakes. There doesn’t seem to be an easy way to correct this other than restore a backup or look at another machine with a similar setup. Rather than having to restore a backup I looked at a machine with a similar setup, the machine has lighttpd, mysql, and sendmail installed on it so I built the following script based on the permissions with those packages installed on a fresh install of Debian Squeeze
echo "Setting Directory ownership" &&
chown -R root:root /var &&
chown -R man:root /var/cache/man &&
chown -R www-data:www-data /var/cache/lighttpd &&
chown -R libuuid:libuuid /var/lib/libuuid &&
chown -R smmta:smmsp /var/lib/sendmail &&
chown -R mysql:mysql /var/lib/mysql &&
chown -R www-data:www-data /var/log/lighttpd &&
chown -R mysql:adm /var/log/mysql &&
chown -R www-data:www-data /var/run/lighttpd &&
chown -R mysql:root /var/run/mysqld &&
chown -R smmsp:smmsp /var/run/sendmail/msp &&
chown -R smmta:smmsp /var/run/sendmail/mta &&
chown -R smmta:smmsp /var/spool/mqueue &&
chown -R smmsp:smmsp /var/spool/mqueue-client &&
chown -R root:staff /var/local &&
chown -R root:mail /var/mail &&
chown -R root:smmta /var/run/sendmail &&
chown -R root:smmsp /var/run/sendmail/stampdir &&
chown -R root:crontab /var/spool/cron/crontabs &&
chown -R www-data:www-data /var/www &&
echo "Setting File ownership" &&
chown root:smmsp /var/lib/sendmail/dead.letter &&
chown -f root:smmsp /var/run/sendmail/mta/sendmail.pid &&
chown -f mysql:adm /var/run/mysqld.pid &&
In addition you will need to set the ownership permissions of
/var/mail/<user> depending on the users on the system.
I recently was asked to create a DVD from a .mov video file. I had already made a post about how to do this under windows using windows ports of various linux based applications. Coming back to it and this time running completely on linux, I have realised that it can be done much more simply.
The required software can be installed using
sudo apt-get install ffmpeg dvdauthor growisofs
First off the video file has to be transcoded into an dvd compatible mpeg2 file.
ffmpeg -i <video.mkv> -aspect 16:9 -target pal-dvd output.mpg
Then the file has to be authored into the correct VOB files using dvdauthor. To make sure that there are no errors in the process the following environment variable must be set.
Rather than using an xml control file for simple DVD’s the following two dvdauthor commands will suffice.
dvdauthor -o DVD/ -t output.mpg &&
dvdauthor -o DVD/ -T
Finally the files are burned to DVD media using growisofs
growisofs -dvd-compat -Z /dev/dvd -dvd-video -V "<name>" ./DVD
I have just completed a successful migration of gilesbathgate.com to a new server. Some headaches were importing the mysql data via the commandline (I gave up in the end and used phpMyAdmin) also lighttpd rewrite rules triped me up, and I forgot to install php5-gd for my wavatars support. But appart from that the migration was seemless, I am sure no one even noticed.
Green code is code that has been commented out. Its usually green because the popular development environments I use syntax highlight the comments in green. In my personal opinion having large chunks of commented out code is a violation of YAGNI. A much better approach than commenting out the code is just to remove it, if you are using source control, which surely you must be? a record of it will be stored in version control. Doing this has two advantages, firstly the current source code has less clutter, and secondly the source code is kept historically in version control along side the code that it was meant to work with. Keeping the code commented out along side the current code is daft, unless you think that un-commenting out the code six months later it will still work, which in most cases it probably won’t.
Here is how I do sidechain compression in Reason. In this example I am going to use a kick for the sidechain source, which can give the output of the compressor a bouncy catchy effect.
First of all you want to setup a default rack with a 14:1 Mixer, an MClass Compressor and a Redrum, make sure when you add the compressor its auto routed as an effect send to the mixer.
Now flip the rack and connect the Redrum’s Send 1 to the Left(mono) channel of the sidechain input on the compressor. Note that the sends from Redrum are mono outputs.
Program a basic 4/4 kick drum pattern into the Redrum device. You can add claps snares or anything else you like they will not be being sent to the compressor at this time until you turn the send knob for a particular Redrum channel.
Once the Redrum is setup how you like you can now send the kick drum to the sidechain by turning the send knob for the kick channel all the way to the right. Note that this doesn’t stop the kick from being sent to the mixer.
You can lower the compressors Threshold and raise its Ratio until you see the kick drum really pump the VU meter. Now that the compressor is pumping we need to give it something to compress. Add a synth to the rack and make sure its auto routed to the mixer. Turn up the aux send of the channel to which the synth was added.
When you play notes on the synth you will hear it go quieter when the kick drum is playing. This can be a useful way to make synth baselines fit better in the mix.
The advantage of using sends rather than using the single channel output of the Redrum are two fold. Firstly the kick drum is not muted and does not need further splitting using a Spider Audio Merger & Splitter. Secondly other elements of the beat can be sent to the sidechain in varying amounts. The advantage of using the compressor as a effect send is that many instruments can have the same compression added to them by altering the aux send of each channel.
Much better than Firefox or Sage is Flock, it integrates with social websites such as Facebook, YouTube, Flickr and others. It allows you to integrate the browser with your own hosted weblog, and create RSS aggregates.
Blogged with Flock