Monday, 26 November 2007

Using Windows Shrink

I've been messing about recently with the "shrink" option which is now available on Windows Vista under Disk Management. This allows a partition to be reduced in size, subject to there being sufficient free space available.



I wanted to reduce the size of my "C:" drive as the standard installation for my laptop didn't come with any spare disk space or a separate partition for data. I always prefer to have a separate partition for data in case I have to re-install the O/S at any time.



So, my C: drive has plenty of spare space, at around 67GB. Right-clicking the partition in Disk Management and clicking the "shrink volume" option presents the option box as shown below.




Unfortunately, despite the fact that plenty of space is free (and in fact is also free contiguously, the shrink command fails to release the 40GB I'm trying to reclaim.

Vista accepts the command however spends about 2 minutes churning over the hard disk to eventually fail.


Clearly the layout of the disk is a problem, although Vista doesn't give me any clues to what's happening. On another track, I've been looking at HDD fragmentation and I now have PerfectDisk 8.0 installed on my laptop. (**Disclaimer** I paid for this software!).


Performing a defragmentation analysis shows me the layout in the next picture.

There's an unmovable file at the end of the C:\ drive, indicated by the red areas. Unfortunately PerfectDisk doesn't identify what specific file this is, although I know it is likely to be the page/swap file, the hibernation file or other control areas for NTFS.

I performed an offline defrag to tidy the NTFS areas however this didn't resolve the problem. I then removed completely the swap file and this turned out to be the file holding this space. I could then run shrink and reclaim my 40GB of space, which I've allocated to a swap volume and a data volume.

The shrink command is helpful, but it would be more helpful if the results were consistent and the command didn't simply fail when the free space isn't at the end of the volume. It also rather annoying that Microsoft has removed the graphic representation of a fragmented volume from their built-in defrag tool. Defrag can be run from the command line; try defrag c: -a -v from a command window. The output is not particularly helpful


Analysis report for volume C: OS
Volume size = 103 GB
Cluster size = 4 KB
Used space = 85.75 GB
Free space = 17.57 GB
Percent free space = 17 %
File fragmentation
Percent file fragmentation = 1 %
Total movable files = 121,296
Average file size = 633 KB
Total fragmented files = 659
Total excess fragments = 4,104
Average fragments per file = 1.03
Total unmovable files = 21,926
Free space fragmentation
Free space = 17.57 GB
Total free space extent = 86
Average free space per extent = 209 MB
Largest free space extent = 11.10 GB
Folder fragmentation
Total folders = 17,206
Fragmented folders = 38
Excess folder fragments = 772
Master File Table (MFT) fragmentation
Total MFT size = 141 MB
MFT record count = 144,197
Percent MFT in use = 99
Total MFT fragments = 2

...and is certainly not graphical.

I suggest finding a good defragmentation tool - I don't care which one, but one that can (a) move/reorganise system files (b) display a graphical representation of the volume, including identifying individual files and (c) will consolidate freespace.


3 comments:

Unknown said...

Chris,
I suggest you use "Gparted" to shrink down your partition. I am not sure if there is a version that works for the NTFS in Vista, but worth a look.

As for the unmovable files, I discuss how to fix those in my post on this:
http://www.ibm.com/developerworks/blogs/page/InsideSystemStorage?entry=separating_programs_from_data

Donn Edwards said...

You could try JkDefrag. It has a -a 5 switch that will move all the files to the start of the drive. This option is designed specifically for this kind of operation.

It's GPL freeware. BTW, I really like PD8, but use both.

BarryWhyte said...

Page Defrag (used to be sysinternals) now available for download from Microsoft allows you to defrag system files. It runs during boot. This allows you to at least get them in one chunk. If it is indeed the pagefile at the end. Simple fix would be either move to another drive or reduce to 0 size. Shrink then create a new one.

These days I create a partition just over double the size of the memory in my windows box. Then move the pagefile to that partition. It pretty much stays un-fragmented due to not using that parition for anything other than the pagefile. Speeds up the system.