While I would love to be able to say that this procedure I’m going to describe for resizing disks inside guest VMs is new or unique or original, I can’t. I’m sure that lots of smart people out there have been down this path before, and more than a couple of them have probably written up good instructions on how to do it. I’m including this information here partly for myself (in the event I need it in the future), and partly because the information fits in with a lot of the other information I have here on VMware and related technologies.
So, with that being said, here’s how I recently went about resizing some guest VM disks using vmkfstools and GParted (specifically, the GParted LiveCD). This process assumes you need to resize a Windows guest. The process should be very similar if not the same for non-Windows guests, but I haven’t tested it so I can’t be absolutely certain. The process is very straightforward and not unusual in the least, but feel free to post any corrections or questions in the comments.
- Download the GParted LiveCD (here’s a direct link) and then upload it to your ESX Server using the file upload tool of your choice. Being a Mac OS X user, I use Interarchy. Use whatever best suits you.
- Power off the VM that you will be manipulating. (I know, that seems obvious, but still…)
- Open an SSH session to the ESX Server where your guest VM is hosted. Switch to root, change into the appropriate directory where the VM is stored, and then run the following command:
vmkfstools -X <New disk size> <VMDK filename>
If your current virtual hard disk was 10GB and you wanted to make it 20GB, then specify “20g†on the command line, i.e., specify the new total size of the disk, not the amount by which to increase it.
- Flipping to the graphical VI Client, change the CD-ROM of the guest VM to be the ISO image of the GParted LiveCD you downloaded earlier. Make sure it is set to connect at power on. Power on the VM and boot from the CD.
Note that booting from the CD can be a bit tricky. You may need to boot up several times before you catch it just right. Be sure that if Windows starts booting up, you let it boot up and then shut it back down again. If you reset the VM in the midst of the Windows boot sequence, the NTFS filesystem will be marked as “dirty†and GParted won’t make the changes you wanted.
- GParted will boot up from the CD. You may need to press Enter a couple of times to accept the defaults (unless you need settings other than the defaults, of course) before the graphical environment loads and you see the GParted interface. Once the GParted interface is up, you should be able to figure out how to make the changes you want to make.
- Shutdown the VM (you can use the shutdown option in GParted), disconnect the CD-ROM, and power the VM back up again. When Windows boots, it will run a Chkdsk, then reboot again, and then come up to a login screen. After you login, you may be prompted to reboot again after the discovery of “new hardware.†After that final reboot, you should be good to go with a new, larger virtual hard disk.
The most time consuming portion, in my experience, is waiting for GParted to boot from the ISO image. Otherwise, the entire process is almost completely painless.
Tags: Hardware, Linux, Virtualization, VMware


15 comments
Comments feed for this article
Trackback link
http://blog.scottlowe.org/2007/05/15/resizing-disks-inside-guests/trackback/
Tuesday, May 15, 2007 at 2:00 pm
josh
i’ve found it’s easier to catch the vmware bios screen if you connect directly to the ESX server with the client rather than using the virtualcenter. It seems when the VC does it’s various HA and DRS checks against the system(s) it pauses and doesn’t show the first step in the console.
Tuesday, May 15, 2007 at 2:37 pm
Chiefton
Is there any benefit to doing this over using VMWare Converter? I have use it on a few servers now and it has worked pretty well. It basically copies the original VM, then expands the drive(s). It also has to be powered down. After you verify it is working, you can delete the original VM. But if something did go wrong, you can boot back up your original VM right were you left it. It has been great for us.
Tuesday, May 15, 2007 at 4:13 pm
Justin
Before we went 100% fiber channel we were using ISCSI with Snap Drive from netapp to resize disks on the fly. It was a lot easier and faster and didn’t require the server to be shutdown!
Were hoping that with Fiber Channel Virtualization in 3.0.2 with Emulex HBA’s we might finally be able to use snap drive again!
Tuesday, May 15, 2007 at 8:30 pm
VMzare
Information is very helpful, and it is going to help lots of guys like me, Other thing I realised why not use diskpart.exe. Diskpart is also tricky thing I know, it works something and sometime it fails.
Wednesday, May 16, 2007 at 8:19 am
Ausmith1
I’ve found that using diskpart under Windows PE 2 is very effective. Windows PE is now free as part of the Windows Vista AIK (Automated Install Kit)
Download the AIK @ http://www.microsoft.com/downloads/details.aspx?familyid=c7d4bc6d-15f3-4284-9123-679830d629f2&displaylang=en
Build a PE 2 ISO, some excellent instructions are available @
http://www.minasi.com/newsletters/nws0701.htm
Boot from the PE 2 ISO, at the command prompt type “diskpart”
To see your physical disks, type “list disk”
To see your partitions, type “list vol”
To extent a partition first select it “select vol n”, then extend it “extend”
Type “exit” twice to exit first diskpart then PE and the system will reboot.
It’s also possible to automate the diskpart action if you wish by creating a text file of the actions you want and calling it from a batch file or script.
diskpart.txt
select vol 0
extend
exit
Then call it via:
diskpart /s diskpart.txt
I’m somewhat more confidant of diskpart working properly for resizing an NTFS volume, because AFAIK MS have never released the specifications to the NTFS data structures and the Linux driver has been reverse engineered. Now I’ll freely admit that the guys who wrote the NTFS driver for Linux did a great job but for critical business work I tend to rely on the code written by the guys who have access to the NTFS source. Just a personal preference…
For ext3 volumes I use the exact method you describe and it works fine.
Wednesday, May 16, 2007 at 8:37 am
slowe
Josh,
Thanks for the tip; I’ll have to try that.
Chiefton,
I haven’t tried this process with VMware Converter, although I’ve seen several articles suggesting that. Does VMware Converter have to “process” the entire VM in order to do this? It seems like that would take longer than the process I describe here, but we’d have to do some comparisons to know for sure.
Justin,
Using SnapDrive with iSCSI to resize disks on the fly is definitely very cool and very helpful, but that was only for data (non-OS) drives, right? Were you able to use SnapDrive to resize a system (C:) drive?
VMzare,
You could use diskpart.exe and just attach the resized VMDK to a different VM for the purposes of modifying the partition. I’ll see about trying that mechanism to see how it works.
Wednesday, May 16, 2007 at 8:41 am
slowe
Ausmith1,
Good information; I’ll have to try that and post some additional results.
Wednesday, May 16, 2007 at 12:34 pm
Justin
Slowe-
Using SnapDrive with iSCSI to resize disks on the fly is definitely very cool and very helpful, but that was only for data (non-OS) drives, right? Were you able to use SnapDrive to resize a system (C:) drive?
Yes this is just data drives (as only data drives are ISCSI), but we don’t’ put anything but the on c: so for us we don’t have any disk space problems there. If you wanted to resize the C: drive since its VM format you have to use the process above.
Wednesday, May 16, 2007 at 2:13 pm
slowe
Justin,
OK, that’s what I thought, but wanted to make sure I wasn’t mistaken. Thanks for the clarification!
Thursday, May 17, 2007 at 11:02 am
Chiefton
Yes, it does copy the entire VM then expand it. It can take a while so I typically just do it during a maintenance window if needed on a production server. It is just nice being able to “roll back” to the original VM if needed. It is a good safety net.
We don’t have our VM environment on NetApp yet although our Exchange databases are getting ready to move to one. All our VMs will be on a CX500 for the time being.
Wednesday, May 23, 2007 at 6:48 am
Dan
Thanks for the tip. An elegant and quick solution to a problem that was bugging me.
And you’re right - the only slow bits are trying to get the ISO to boot
Dan
Wednesday, May 23, 2007 at 10:46 am
slowe
Dan,
Josh’s tip (first comment on this article) is definitely accurate–if you use the VI client to connect directly to the ESX Server, catching the BIOS screen is much easier.
Josh,
Thanks for the tip–works great!
Tuesday, June 3, 2008 at 5:47 pm
Jeff
I followed the guide but once I got into Windows Disk Manager sees the added space, but Explorer still shows the old partition information.
IE: Explorer still shows my 20GB partition with 11GB used, while Disk Manager shows 40GB.
Any ideas?
Thursday, June 5, 2008 at 9:34 am
slowe
Jeff,
Apparently, the changes made within GParted didn’t take, or else the partition would have been resized. I can only suggest trying the process again. Good luck!
Tuesday, July 22, 2008 at 12:19 pm
Jason
This worked like a charm. Saved my skin.
thanks