Friday, February 12, 2010

Shrinking the system partition in Windows 7

Most new computers are coming with one large partition where the OS and applications are installed. Personally I like to have a separate partition for OS and one or more for other things, like say one keeping your personal files and other ones for backups etc. The advantage is that if you want to reinstall the OS, once that’s done you can simply change the location of your documents to where you put them on one of the other partitions – this used to be much easier in XP, where you could’ve just right-clicked My Documents on your desktop and change the location to say D:\My Documents. It seems in Windows 7 you have to go and do that for all your folders in your profile folder on your desktop, or you could move them in bulk and I believe Vista/Windows 7 will update the paths in the registry as well.

Back to shrinking the one big partition, I didn’t know until I searched just now the Internet that Vista and Windows 7 have a partition shrink option in Computer Management > Disk Management. One limitation is that files like swap, hibernation or even system restore files can be in the way, preventing you from shrinking a partition down to the size you want. One solution is to disable / turn them off, reboot and defrag the drive before attempting the shrink operation. Windows Defrag does not compact the free space, but there are other tools out there that can do that – one of my favourites is Raxco PerfectDisk, they have a trial version you could try on.

Here’s a good tutorial on shrink feature and solutions:
http://www.howtogeek.com/howto/windows-vista/working-around-windows-vistas-shrink-volume-inadequacy-problems/

imageimage

As you can see from the screenshot above, it only allows me to shrink the partition with a mere 1.2 GB – see the black blocks in the middle of the partition and also the files at the end of the partition in PerfectDisk.

image Disabling the page file from My Computer (right-click) > Properties > Advanced System Properties > Performance (Settings) > Advanced (tab) > Change. Select No paging file and click Set, then OK.

image Hibernation has to be disabled from an elevated command line window (administrator) using powercfg –h off command.

image

System restore can be turned off from My Computer (right click) > Properties > System Protection (tab) > select each drive and use the Configure button to turn off system protection.

image

One reboot later, run PerfectDisk again and you can see the black blocks are gone. Now defrag the partition with the option to consolidate free space, that’ll push the files at the start of the partition.

image

Once that’s done, notice that although the files are all now at the start of the partition, there could still be some system files (notice the grey boxes in the middle of the white space) left. You need to use the System Files defrag (toolbar button) – that will require a reboot, as the offline defrag needs to be done as part of the Windows system boot tasks.

image

If you find that the pesky metadata won’t move (apparently the preferred position seems to be somewhere in the middle of the partition), one solution is to try to shrink the partition as much as possible, do the offline defrag process to move the metadata in the middle, consolidate the free space and repeat if necessary until it allows you to shrink down to the size you want (in my case 96 GB for the system partition). Once the system partition is shrunk, you can create other partitions in the newly create free space.

imageThe whole process can be a pain in the neck, obviously the easier solution is to use a proper partitioning tool that is certified with Windows 7 - otherwise Windows might not like it and you will need to repair Windows (as it happened in the past when using GParted).

Ah well, a couple of hours down the drain I managed to shrink the system partition and created a new one and still have a running system, I can only wish you the same. Makes you wonder if it wasn’t worth the 5 euro for get the custom partitioning when ordering the system on Dell’s website or getting some proper partitioning tools...

VERY IMPORTANT:
Once done with the system partition you should enable back the swap file, hibernation (powercfg –h on) and system restore.

2 comments :

  1. Hi Dan,
    Thanks for the info, worked well, saved me some time and headaches.
    BC.

    ReplyDelete