Resizing VMWare Images
Last night I realized that one of my vmware images was about to fill up the disk. I have a 5GB XP image and even after clearing out all the downloads I only had 1GB left. At first I had not intended this to be a working instance but now I like the build and I want to keep it running. So, after a little investigation I found the vmware tool that is designed to manage vwmare disk images: vmware-vdiskmanager.exe.
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe /?
VMware Virtual Disk Manager – build 19175.
Usage: vmware-vdiskmanager.exe OPTIONS diskName | drive-letter:
Offline disk manipulation utility
Options:
-c : create disk; need to specify other create options
-d : defragment the specified virtual disk
-k : shrink the specified virtual disk
-n: rename the specified virtual disk; need to
specify destination disk-name
-p : prepare the mounted virtual disk specified by
the drive-letter for shrinking
-q : do not log messages
-r: convert the specified disk; need to specify
destination disk-type
-x: expand the disk to the specified capacity Additional options for create and convert:
-a: (for use with -c only) adapter type (ide, buslogic o
r lsilogic)
-s: capacity of the virtual disk
-t: disk type id Disk types:
0 : single growable virtual disk
1 : growable virtual disk split in 2Gb files
2 : preallocated virtual disk
3 : preallocated virtual disk split in 2Gb filesThe capacity can be specified in sectors, Kb, Mb or Gb.
The acceptable ranges:
ide adapter : [100.0Mb, 950.0Gb]
scsi adapter: [100.0Mb, 950.0Gb]
ex 1: vmware-vdiskmanager.exe -c -s 850Mb -a ide -t 0 myIdeDisk.vmdk
ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vm
dk
ex 4: vmware-vdiskmanager.exe -x 36Gb myDisk.vmdk
ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
ex 6: vmware-vdiskmanager.exe -k myDisk.vmdk
ex 7: vmware-vdiskmanager.exe -p m:
(A virtual disk first needs to be mounted at m:
using the VMware Diskmount Utility.)
Unfortunately this did not fix my problem as I have upgraded vmware since I orginally installed this image. Apparently, along the way (or by default) the image had a snapshot. The vmware-vdiskmanager.exe errorred out with the following error.
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -x 8GB “d:\My
Virtual Machines\Copy of XP_Pro\XP_Pro.vmdk”
Using log file C:\DOCUME~1\user\LOCALS~1\Temp\vmware-user\vdiskmanager.log
This disk is part of a snapshot chain in ‘d:\My Virtual Machines\Copy of XP_Pro\
winXPPro.vmx’.
The selected operation can only be executed on a disk with no snapshots.C:\Program Files\VMware\VMware Workstation>
As you can see from this I forgot to save the original error message. So, for this article I ran the same command against my backup of the image, which I remembered to create before I started down this path.
So, there was a snapshot that I had to get rid of before I started. So which one is it? I’ve never dealt with snapshots so lets look at the image directory.
D:\My Virtual Machines\Copy of XP_Pro>dir
Volume in drive D has no label.
Volume Serial Number is 64B5-6B5EDirectory of D:\My Virtual Machines\Copy of XP_Pro
01/20/2007 09:15 AM
.
01/20/2007 09:15 AM..
06/25/2005 03:16 PM 123 Desktop.ini
01/20/2007 02:00 AM 8,664 nvram
06/26/2005 04:42 PM 8,664 nvram.sav
01/20/2007 02:00 AM 36,895 vmware-0.log
01/20/2007 01:55 AM 4,768 vmware-1.log
01/20/2007 01:51 AM 4,767 vmware-2.log
01/20/2007 02:25 AM 2,404 vmware.log
06/10/2004 07:12 PM 25,214 vm_folder.ico
06/26/2005 04:42 PM 355,067 winXPPro.png.sav
06/26/2005 04:42 PM 315,625,872 winXPPro.vmsn
01/20/2007 01:58 AM 1,435 winXPPro.vmx
06/26/2005 04:42 PM 1,252 winXPPro.vmx.sav
01/20/2007 09:15 AM 1,096,089,600 XP_Pro-s001.vmdk
01/20/2007 09:15 AM 2,141,454,336 XP_Pro-s002.vmdk
01/20/2007 09:15 AM 239,468,544 XP_Pro-s003.vmdk
06/26/2005 02:29 PM 424 XP_Pro.vmdk
01/20/2007 02:00 AM 1,772,617,728 XP_Pro.vmdk-s001.REDO_a01276
01/20/2007 02:00 AM 1,649,672,192 XP_Pro.vmdk-s002.REDO_a01276
01/20/2007 02:00 AM 1,052,770,304 XP_Pro.vmdk-s003.REDO_a01276
01/20/2007 01:59 AM 354 XP_Pro.vmdk.REDO_a01276
20 File(s) 8,268,148,607 bytes
2 Dir(s) 21,036,797,952 bytes freeD:\My Virtual Machines\Copy of XP_Pro>
If you are like me this did not help you at all. After some hunting and picking I figured out that the “winXPPro.vmsn” file is the snapshop. At first I thought that the files containing the word “REDO” in them were the files but as it turns out these files are the ones that back up all of your changes since you first started. Now that I have found the snapshot I moved it to a location outside of this directory and tried the resizing command again. Unfortunately I received the same results. Okay, so I have a snapshot I cannot get rid of manually. It might just be that I need to edit a few files but I wanted to avoid that if I could. So, how does vmware manage snapshots? Through their GUI interface, of course. Under the VM tab of the vmware menu there is an option titled “Snapshots.” This drill further down into other options, one of which is “Snapshot Manager.” This would have been perfect except that the feature was greyed out as unavailable. This was probably because I have updated my vmware from 5.0 to 5.5 since this image was created. another roadblock or so I thought. It was at this point I realized I had not updated the virtual machine for this image. This means that I was still running the image as it was created for 5.0 and it had not been converted to accept all the functionality for 5.5. Once again under the VM tab I clicked the “Upgrade Virtual Machine” option. I was greated with the following message box:
The virtual machine contains a snapshot in which the virtual machine is suspended or powered on. To upgrade a virtual machine with such a snapshot, the virtual machine will be powered off in the snapshot. This causes the loss of any unsaved data in the snapshot.
Click Continue to upgrade the virtual machine and update the snapshot, resulting in a loss of any unsaved data in that snapshot.
Click Cancel if you do not want to upgrade the virtual machine.
What to do? What to do? As I want to get rid of the snapshot I needed to update it as well, so I selected “Continue.” After navigating the remaining message boxes the conversion was successful. I check the “Snapshot Manager” and it did not show that this image had any snapshots. No snapshots meant that I could update the size of the image’s disk. But when I ran the command it failed with the same error message. After a few minutes thinking I decided to reboot the vmware machine. After it came back up I checked the “Snapshot Manager” and there was a snapshot. Amazing. So, right click “Delete snapshot and children.” After a few minutes of cleanup I tried to resize the disk again. This time I was greeted with the following results.
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -x 8GB “d:\My
Virtual Machines\Copy of XP_Pro\XP_Pro.vmdk”
Using log file C:\DOCUME~1\user\LOCALS~1\Temp\vmware-user\vdiskmanager.log
The old geometry C/H/S of the disk is: 10402/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
C:\Program Files\VMware\VMware Workstation>
Rockin’. Wait, repartition, what? Of course! I’ll have to repartition the hard drive so that the image can utilize the new free space on the hard drive. Hmmm, resize the partition. Partition Magic! Of course, I do not own Partition Magic. Damn. And I bet that there is not a freeware version of a disk partition management software. I loose: Partition Logic. Excellent! Download, unzip, and boot the image to the ISO. Run through the resizing options, select the new size, NOTE THE WARNING MESSAGE ABOUT THE RESIZING PROCESS, and resize the filesystem and partition. After cleaning the house I found that the actions had completed successfully. Reboot to Windows, it performed a consistency check, and reboots. After login in I found my new 3GB worth of free space to be a refreshing sight. As I was checking for the new disk I noticed that the system did find some new hardware. This was a result of upgrading the virtual machine and not a problem. I will, however, want to check any special drivers I have installed.
Now I can test BiDiBLAH and not worry about how much disk space I have left.
Security Ripcord, vmware vmware-vdiskmanager partitionlogic
Help support my training and travel to security conferences. Get your SANS Training and GIAC Certifications through the Security Ripcord.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.









February 28th, 2007 at 7:17 pm
thanks for this howto. i saved me a lot of time.
August 1st, 2007 at 2:45 pm
Thanks for the write-up. Just what I needed, quickly and with the correct information.
March 13th, 2008 at 12:52 pm
Man u r the best. Just what i needed to fix my
problem. I had the same error message as you
did.
Ur article rocks
10x
April 26th, 2008 at 7:51 am
Hi, there is one thing that I do not understand: how do you get Partition Logic to recognize the vmdk disk as a real disk? What do you mean by “boot the image to the ISO”?
April 26th, 2008 at 2:51 pm
@Antonine,
You only need Partition Logic if you are going to be installing to a local hard drive. I would not recommend that you dual boot to VMware because 1) it is not necessary, just create another image for the other OS, and 2) the image is going to be huge. This could impact performance.
“boot the image to the ISO” means that you need to point your CD-ROM resource to the ISO file on your hard drive. VMware will recognize this and run but none of the settings will be persistent. You may need to modify the boot order when VMware image is booting. To do this just start the system and hit F2 when you start seeing text on the screen (remember to get focus by clicking within the window). Then you can find the boot order, move the CD-ROM to be first, save and exit, and the VMware system should reboot. Zooommm! You’re off.
Go forth and do good things,
Don C. Weber
July 8th, 2008 at 5:03 am
I was able to get VMWare Fusion set to boot from the ISO for Partition Logic, however Partitition Logic gives me the message “no hard disks registered” and I can’t figure out or find any information on how to proceed from here. Any ideas? Thanks!
July 15th, 2008 at 4:27 am
@Josh,
I’m not up on VMWare Fusion so I cannot duplicate. I would review some of the boot options to see if you need to specify a specific drive type or some other boot option.
Good luck,
Don C. Weber
June 5th, 2009 at 12:34 am
All good advice, though Partition Logic or other third party software isn’t needed. Just go into My Computer -> Manage -> Storage -> Disk Management on the VM and update. Voila!
June 26th, 2009 at 1:23 pm
great material, very well written and fun to read