I find that using virtual machines (VM) for my development environment keeps the development environment clean of any unnecessary installers, and allows me to have various development environments ready to go. For example, I have a VM for .Net 1.1, a VM for .Net 2.0, a VM for .Net 3.0, and a VM for .Net 3.5. Then I use some VM's for testing different web applications side by side that use different versions of the .Net framework.
One of the major issues with having all of these VM's is that they take up a lot of hard drive space. You cannot do much with the size of the OS install, or the footprint of the applications you choose to install. One thing to note here though is that the 64 bit Windows OS versions are about twice the install size of the 32 bit versions. If you do not actually need to test against the 64 Bit versions, then use the 32 bit OS versions.
So, where can you look to squeeze down the size of the files for your VM's? I have found three places that can make a considerable space saving. All up, on my configuration, performing the three steps below saves me around 6 GB. This is a big difference when trying to fit VM's onto a laptop, and when taking backups of your VM files.
1) Turn off Windows hibernation
By default, Windows XP installs with the Hibernate option set to on. This means that you can hibernate the PC, which places all of the memory onto the hard drive, in a file called c:\Hiberfil.sys. This file is created at the same size as your memory, and is pre-allocated, meaning it is there, even if you have never hibernated the system. For a developer, turning off the hibernate option will save from 1GB to 2GB, which is the typical amount of memory you would allocate to your VM. So far as I can tell, Windows Server 2003 has this feature turned off by default, but it is worth a check.
Instructions to turn off windows hibernation
- Open the Windows Control Panel
- Double-click Power Options
- Click the Hibernate tab, de-select the 'Enable hibernate support' check box, and then click Apply.
- Restart your computer and hiberfil.sys will be automatically deleted.
Note: If you decide to turn the hibernation feature back on in the future, go to the Windows Help & Support Center and search for 'enable hibernation'. It should be the first result. The instructions detail some other steps you may need to follow to reactivate the hibernation.
2) Turn of Windows System Restore
By default, Windows XP has System Restore turned on. This pre-allocates an amount of space on your HDD for storing restore points for the OS. Each time you make critical changes to the OS, it saves restore points so that you can undo the change if it all goes wrong. On my PC, the space taken up by this System Restore feature was 2GB.
Instructions to turn off system restore to save the system restore space
- Right click My Computer
- Properties
- System Restore tab
- Un-tick "Turn off System Restore on all drives"
- OK
- Reboot the computer
3) Remove or resize the Windows paging file
Now every developer should know what the paging file is, so I will not go into explaining what it is used for. Removing the paging file might be a little drastic, but depending on the amount of memory you allocate to your VM, you could at least reduce the size of the paging file, and minimize the pre-allocation, but let it grow if necessary. This will slow down the VM considerably if you ever get one of your applications run away and use up all of your physical memory. I will show below how to eliminate the use of the paging file, and also how to clean it out, but let it grow.
Instructions to remove the windows paging file
- Right click My Computer
- Properties
- Advanced tab
- Performance - Settings
- Advanced tab
- Virtual Memory - Change
- One by one, select each drive, select No paging file, and click Set
- OK
- OK
- OK
- Reboot the computer
Instructions to reduce the size of the paging file
- Follow the instructions above to remove the paging file, including the reboot
- Right click My Computer
- Properties
- Advanced tab
- Performance - Settings
- Advanced tab
- Virtual Memory - Change
- Select the drive you want to put the paging file onto
- Select the Custom size option
- Set an initial size of whatever you can spare. This can be as low as 2 MB
- Set the Maximum size to the limit you want it to grow to. This stops it running away and claiming all of your HDD free space.
- OK
- OK
- OK
- Reboot the computer
Posted
Mar 04 2008, 07:13 PM
by
David