Monday, February 05, 2007

VMWare Hard Disk Resizing Without ESX

I had to make a dev windows vm image on a linux host bigger, but couldn't use the fancy esx command line tool that everyone else recommends. So, here's my inefficient method using only preallocated virtual drives:

The vm disks here are called olddisk and newdisk-0
  1. Install the Windows Recovery Console on the virtual machine.
  2. Boot into the recovery console, then run chkdsk /R
  3. Turn off the vm.
  4. Make a new virtual disk image for a 50gb drive.
  5. Look at the old vmdk file sizes.
  6. Copy the vmdk files that were 2gb over top of the new vmdk files
    That is, olddisk-f001.vmdk overwrites newdisk-0-f001.vmdk and so on and so forth.
  7. For the last old vmdk (not the descriptor file that is in plain text), check the contents of the file
    'hd olddisk-f005.vmdk'
  8. If it's all zeros, you're good to go.
    If it's not all zeros, copy olddisk-f005.vmdk over newdisk-0-f005.vmdk then pad the rest of the file with nulls so it matches the size of the other files exactly. (I didn't have to figure out how to do that step)
  9. In the vmware console, remove both virtual hard disks and then re-add the new one.
  10. Boot your new system.
  11. Run chkdsk again
  12. Use diskpart.exe or a gparted iso or ubcd to expand the ntfs partition. (gparted actually showed the disk as already expanded, so I set it to 50GB less two bytes so it would let me apply the new size. This appears to have worked wonderfully)
I used recovery console for chkdsk, becuase just running chkdsk at boot didn't work.