Saturday, April 11, 2015

Disk2VHD for Dynamic Disks

I was virtualizing an old server for a customer today and ran into an issue I've never had before. The server has a C: drive for the operating systems and a D: drive for data. Like I've done before, we used Disk2VHD to perform the conversion.

After creating the virtual machine and starting it, the D: drive was showing as Dynamic and Offline. So, it appears that the D: drive was a dynamic disk rather than a basic disk. I suspect that at some point it was configured to use mirroring functionality in Windows which requires dynamic disks.

Ok, fair enough. How do we properly import this disk? According to several searches, I should be able to reactivate the disk. However, this didn't work in my case.

At this point, I'm a bit annoyed. An obvious solution is to do a simple file copy from the old D: drive in the original server, but I'm doing this conversion remotely and have already shut down the original server. I would need to abort the conversion for the weekend if I can't figure this out.

While I was searching for potential ways to repair the disk, I ran into a few articles about converting a dynamic disk to a basic disk without data loss. When you convert a dynamic disk to a basic disk in Disk Management, or by using diskpart, you lose all of the data. What wizardry is this that they're trying to sell me?

I'm not into low level disk stuff and likely never will be, but here is my overall understanding. The disk configuration for dynamic disks vs basic disks is pretty close. Close enough that you can use a hex editor and edit the disk to make it a functional basic disk without losing your data. There are a few utilities that do this for you (for $$ of course), or you can do it yourself.

Here are the basic instructions:
  1. Download a hex editor for the disk. I used this one:
  2. In the hex editor, rows are labeled as Offset and columns are labelled 0 to F. The first partition for a dynamic disk has a value of 42 for Offset 00000001C0 and column 2. Change this value to 07. The value 07 is used for basic disks with NTFS partitions.
  3. If your disk has multiple partitions, then you need to go down to the next row and make the same change. Note that basic disks can have a maximum of 4 partitions. Dynamic disks do not have this limitation.
  4. After modifying all the neccessary values, save the changes.
  5. At this point, I rescanned the drives and was able to see a basic disk, but not do anything with it. So, I restarted the VM.
  6. After the restart I was able to assign a drive letter to the modified disk, but it had no data. To recover the data I needed to repair the disk. You can use chkdsk /f, but I used the disk repair option available in Windows Explorer.
  7. The repair completed very quickly and I was able to see all of the data.
  8. After a final reboot the applications using the data on D: drive started properly and appear to be functional.
Some additional resources:

No comments:

Post a Comment