From ThirdMartini

Contents

[edit] Introduction

On several occasions I've run into a case where I needed to resize a VMWare virtual disk belonging to a VMWare Virtual machine. Often due to the dreaded Windows Low disk space on drive C: Pop-up caused by all the applications that even though told to install to an alternate drive, seem to always install hundreds of megabytes of DLL files into the C:\windows directory. This is a step by step guide to increasing the disk size for a Windows VM hosted on Linux. However, the same can be done for any VM on a Windows host.

[edit] Step 1: Prepare the VM

The first thing we need to do is to safely shutdown a the Virtual Machine whose disk we would like to resize. This must be a complete shutdown.. we cannot safely resize a suspended or running VM.

Helpfull Hint: Once you shutdown the VM it is a good idea to take a snapshot of it in case something goes wrong in the next few steps. This way you will have a known good working VM image to go back to.

[edit] Step 2a: Resize the Disk in Question (VMWare Server/Workstation)

VMWare provides a nifty tool called vmware-vdiskmanager that gives us a simple way of doing this. To resize the disk simply run:

vmware-vdiskmanager -x <newsize>GB <path-to-disk>

As an example:

 vmware-vdiskmanager -x 6GB ./WindowsXP.vmdk

Here I've told vdiskmanager to expand my disk to 6GB. At this point vdiskmanager will run through the paces of relaying out the disk. After vdiskmanager completes we will need to resize NTFS.

[edit] Step 2b: Resize the Disk in Question (VMWare ESX)

From the ESX console we use vmkfstools

vmkfstools -X <newsize>GB <path-to-disk>

As an example:

 vmkfstools -X 6GB ./WindowsXP.vmdk

Here I've told vmkfstools to expand my disk to 6GB. At this point vmkfstools will run through the paces of relaying out the disk. After vmkfstools completes we will need to resize NTFS.

[edit] Step 3: Resize NTFS

There are a variety of tools that can resize NTFS for us after we resized the disk. My personal favorite is GParted Live CD. With the VM Still shutdown, download the GParted Live CD iso file and attach it to the Virtual Machine. Make sure the CD will be connected at boot and that the Virtual Machine will now boot the CD rom first. ( Boot the VM and hit F2 to access the BIOS menu to change the boot order )

Once the Live CD Boots, it will provide you with an easy interface to resizing the NTFS partition and File System. Just click the old partition and select the resize operation.

Image:

Personal tools