Monday, July 11, 2011

Correcting Dynamic Disk is Invalid message

This was a really odd situation in my VMware ESXi environment involving a virtual disk that needed resizing.  I needed to add a few gigabytes to a virtual hard disk, which I have done scores of times and have my process pretty well down pat.  This one was a little different and I had to do some research and obtain some new tools.

My normal process is this:
  1. Add space to the .vmdk using the vSphere Client / vCenter Console.
  2. Use the diskpart command on the server to select the disk and volume in question, then issue the extend command. 
  3. If the command cannot complete (because the disk is in use in a certain way by the server), then I have to shut down that server and add the hard disk to another virtual server (as it's D: drive, for example).  I then perform #2 above from that server's console, detach the disk, and then power up the original server.
It's one of my favorite little admin tasks to do in VMware, because I know what it would take for me to add disk space to a server in the "real world", and I giggle a little bit every time I do it.

Today when I tried to use diskpart I could not see the volume when I ran the list vol command.  I knew then that something was wrong.  I check Disk Management (it's a Windows Server 2003 machine) and saw that the disk was a dynamic disk and was "Invalid".  I had never seen that before.  I could still access the disk just fine -- I could still see and manipulate all the files on the disk... I just couldn't make any changes to the size.  I also did not recall ever converting the disk to a dynamic disk.

Now I'll fast forward to the end... there are a few resources out there for handling this situation.  The best, most concise one that I found is here.  The explanation is that a byte on the disk that identifies it as dynamic or basic has become corrupt somehow.  The HxD disk editor can be used to see the value and even make a change to it.  Be careful, though, because you can really mess things up if you aren't careful.

According to the above instructions the trick is to look at sector 0 location 1C2.  For dynamic disks this value should be 42.  For basic disks the value should be 07.  In my case the value was 07 but Disk Management was showing the disk type as dynamic.  The instructions in the link above say to only make a change if the value in 1C2 is 42 (change it to 07), so this did not fit my situation.  I did notice that the value just below it in the HxD window was 42 (location 1D2).  I decided to give it a try, so I changed the 1D2 location from 42 to 07 (to match the value in 1C2) and then my server booted just fine.

So, based on my experience I'll add that it's important for the 1C2 and 1D2 values to match.  Of course it's possible that this isn't applicable in all cases.

No comments:

Post a Comment