« 2008 Christmas list #0000001 | Home | BBC Publish F1 Calendar as iCal »

October 22, 2008

Removing a Drive from a Spanned Volume

When I needed more space in my main PC, I went for the (then) cheaper option of 4x 250GB drives over one large one, and as I wanted to avoid problems with moving the disks I didn't use the motherboard's RAID features and instead went with Windows dynamic discs and a spanned volume.

Time moved on and I wanted some of the contents of that drive on my main PC and the rest on the media PC, but I had nowhere to store roughly 1TB of data whilst I re-arranged the disks.  After much research on the net everyone told me that it wasn't possible to remove a single drive from a Windows spanned volume.  That's never stopped me trying before and I am glad to say that I managed it!  Instructions after the jump.
NOTES: Apologies for the lack of screenshots, I had assumed that all those people were right and it couldn't be done so didn't document it as I tried.  The majority of the work was done under Windows Vista, however I used my Windows XP partition to aid in moving locked files.  This is designed for people who are familiar with computers. file systems and data recovery, do not perform this technique on any vital data without full and verified backups.  I will not be responsible if this trick kills your data, it worked for me, but that doesn't mean it will work for you!

The first stage of the process is data clean-up and sanitisation.  In my situation I needed to make sure that one of the drives had no data left on it so that it could stay in my main PC and the block of three could move to the media PC.  A little tidying and deleting left ~400GB of free space, more than enough to release one of the 250GB drives.  You also need to make sure there is no page file on the disk and that hibernation, system restore and volume shadow copy are all disabled on the drive.

Now go to disk management (right-click my computer and select "Manage" then "Disk Management" on the left) and look at your disk layout.  If you right click the spanned volume there will be an option to shrink the volume. If the amount of space it says you can shrink is larger than the size of the drive you want to move then you are in luck and you can move on to later steps.  For me, it just said 11GB, not much use!  The reason Windows can't shrink the partition any more is that it doesn't seem to be able to move files, and will only shrink as far as the first sector of data that it finds.

So you need to move all the data to the start of the volume, a job for defrag surely?  Well, Windows built in defragger did nothing to help, and Diskeeper just took forever and didn't help get the available shrink space any larger.  A hunt round the net found JKDefrag a free tool that will do anything you like with your data, including move everything to the start of the drive even if it ends up fragmenting some of the files to do it.

Grab a copy of JKDefrag and extract the zip, now run it using the following switches:

jkdefrag -a 5 X:

This will take it's sweet time if you've got a lot of data to move around, but it will do it's job.  Keep an eye on the disk map that's presented, if you have no red dots in the upper portions of the display, have a look at your available shrink space and see if it's enough.

I had one little ass of a sector right near the end of the volume that wouldn't budge.  I tried the defrag in safe modes of Vista and XP but nothing would shift it, thankfully JKDefrag has a handy log file that tells you what it can't move.  Have a look in there for a guide as to what is stuck.  In my case it was X:\$Extend\$UsnJrnl:$J:$DATA which is the NTFS USN Journal that logs and tracks changes to the file system for rollbacks and other functions.  So you need to delete this, but don't worry, a chkdsk will replace it.  Use this command to remove the USN journal:

fsutil usn deletejournal /D X:

now run your JKDefrag again, then reboot and do it again, maybe even boot into safe mode and do it again, until there are no little red spots in that top part of the drive map.  When they are all gone you can try your shrink volume again.

For me this worked wonderfully, and I had a shrink size nearing the 400GB free space on the drive, to make sure i definitely got the partition off one of the disks, I shrunk it by ~300GB and there it was, a completely blank drive.  A little pluging and unpluging revealed which physical disk was empty and then out came the other three and into another Windows PC.

To get the drive to show up in XP I had to rebuild the partition table using a command line tool I now can't find, but I will update here if I remember.

I also had a problem with Vista not showing "Documents", "Pictures" etc as these were all on the drive that dissapeared.  There was also no option to change their location, however a quick reg hack fixed that, just edit the contents of [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders] to suit.  Be warned, DO NOT EDIT [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders] as it will do nothing, and is there only as a copy of your settings.