esiebert7625
Immortal
Immortal

How to shrink or grow (extend) a virtual machines disk

This topic has come up often so I documented all the methods from personal experience and other posts in these forums.

How can I resize my VM’s hard disks?

There are several methods to do this that are listed below. You can no longer use vmkfstools to shrink a vmdk file in ESX3. If you want to shrink the disk in ESX3 then using Vmware Converter is the best way to do this, an alternate method is using Knoppix/dd to shrink a disk. With all these methods you should always make a backup copy of your original vmdk file in case something goes wrong. Also make sure you shutdown the OS cleanly before restarting the VM (GpartEd will sometimes fail otherwise). Methods 1, 4 & 5 are essentially the same using Linux boot CD’s and either GpartEd or QpartEd.

Method 1[/b] – Using vmkfstools and gparted (http://gparted.sourceforge.net/livecd.php) to extend a disk

o Download the gparted livecd ISO and make it available so it can be mounted by the virtual machine’s CD-ROM

o Shutdown the virtual machine you want to resize

o Log into the ESX Server console via Putty

o Type “vmkfstools –X ” ie. /vmfs/volumes/Storage1/my_vm.vmdk New disk size can be specified in kilo, mega or gigabytes and will be the total size of the new disk. So if you want to increase a virtual disk from 20GB to 24GB you would specify either 24000m or 24g

o Power on the Virtual Machine and make sure it boots properly, load Disk Management and you will see the new unallocated space

o Now to join the unallocated space to the primary partition, first shutdown the Virtual Machine

o Connect the Virtual Machine to the GpartEd ISO file and make sure you enable Connected at Power On

o Power on the Virtual Machine

o Press ESC at the Bios screen to get to the Boot Menu

o Select CD-ROM as the Boot device

o Gnome Partition Editor will load, press Enter at the boot screen

o At the Boot option screen select Manual Video Card and then select Done

o Select US English at the Language screen

o Select qwerty/us.map at the Keyboard screen

o Select Generic VESA Compatiable at the Video Driver screen

o Select 8 at the Display Depth screen

o Select 1024x768 at the Resolution screen

o Once the partition editor loads, click on /dev/sda1 in the partition list

o Click the Resize/Move button

o Click and drag the arrow to extend the size of the partition, make sure you do a resize (double arrow) and not a move (four way arrow) so you should 0 free space preceding and following and then click the Resize/Move button

o Next click the Apply button and then the operation will start, you can expand Details to see the progress, once completed click the Close button.

o Click the power button in the bottom right corner, then select reboot.

o Edit the VM and remove the ISO from the CD/ROM device (change to Client)

o When the server restarts it will do a Check Disk, let this complete, Windows will prompt for a reboot after you login

o Reboot and load Disk Management and your Primary Partion will be the new size without any unallocated space

Method 2[/b] – Using Vmware Converter (http://www.vmware.com/download/converter/) to shrink or extend a disk

o When you use Converter to copy a VM it will transfer the data to the destination server by one of two ways. If you do not change the disk size or increase the size of your original disks then it does a block level clone of the drive. If you reduce the size of your original disks it instead does a file level clone of the drive.

o Download and install Converter on the VM that you want to resize the drives, reboot after the install completes

o Start Converter application, click the Import Machine button

o Click Next at the Welcome screen and then Next again at the Source screen

o Select ‘Physical Computer’ and click Next

o Select “This Local Machine” and click Next

o At the Source Data screen select your volumes and change “Maintain Size” to “Type Size in GB” and enter your new disk size and click Next

o At the Destination screen click Next

o Select “Import this machine to a Vmware ESX Server or VirtualCenter virtual machine” and click Next

o At the Destination login screen, select your ESX/VC server and enter the login information and click Next

o At the Virtual Machine Name and Folder screen enter a new name for your VM and select a folder and click Next

o At the Host or Cluster screen select a host for your destination and click Next

o At the Datastore screen, select a datastore and click Next

o At the Networks screen, configure your NICs and click Next

o At the Customization screen, click Next

o Click Finish and the conversion will begin

o Once the Conversion is complete, edit the new VM settings and remove any extra hardware that Converter adds (USB/serial/parallel ports, etc.)

o Shutdown your original source VM and power on your new destination VM

o Make sure everything is functioning properly on the new VM and you can delete the original VM

Method 3[/b] – Using vmkfstools and another Windows virtual machine to extend a disk

o Shutdown the virtual machine you want to resize

o Log into the ESX Server console via Putty

o Type “vmkfstools –X ” ie. /vmfs/volumes/Storage1/my_vm.vmdk New disk size can be specified in kilo, mega or gigabytes and will be the total size of the new disk. So if you want to increase a virtual disk from 20GB to 24GB you would specify either 24000m or 24g

o Shutdown the second helper virtual machine

o Edit the settings of the second VM and add the hard disk from the first VM

o Power on the second VM and load the Disk Management snap-in and verify that the disk from the first VM has un-allocated space on it

o Select Start, Run and enter diskpart.exe

o The command ‘list volume’ will show you all volumes.

o Select your volume based on the results of the list volume command, ie. ‘select volume 1’

o Type the command ‘extend’ to extend the volume

o Check the Disk Management snap-in again and the volume should be extended with a larger capacity

o Shutdown the second VM and remove (not delete) the disk from it

o Power on your first VM and the new space should be there and ready to use.

Method 4[/b] – Using vmkfstools and System Rescue CD (http://linux.softpedia.com/get/System/Recovery/System-Rescue-CD-188.shtml) to extend a disk

o Download the System Rescue ISO and make it available so it can be mounted by the virtual machine’s CD-ROM

o Shutdown the virtual machine you want to resize

o Log into the ESX Server console via Putty

o Type “vmkfstools –X ” ie. /vmfs/volumes/Storage1/my_vm.vmdk New disk size can be specified in kilo, mega or gigabytes and will be the total size of the new disk. So if you want to increase a virtual disk from 20GB to 24GB you would specify either 24000m or 24g

o Power on the Virtual Machine and make sure it boots properly, load Disk Management and you will see the new unallocated space

o Now to join the unallocated space to the primary partition, first shutdown the Virtual Machine

o Connect the Virtual Machine to the System Rescue ISO file and make sure you enable Connected at Power On

o Power on the Virtual Machine

o Press ESC at the Bios screen to get to the Boot Menu

o Select CD-ROM as the Boot device

o Press Enter at the boot screen

o Press Enter after boot sequence is complete and then type ‘startx’

o Once X-windows loads, double-click the GpartEd icon (drive icon, 3rd down on the right hand side)

o Once the partition editor loads, click on /dev/sda1 in the partition list

o Click the Resize/Move button

o Click and drag the arrow to extend the size of the partition, make sure you do a resize (double arrow) and not a move (four way arrow) so you should 0 free space preceding and following and then click the Resize/Move button

o Next click the Apply button and then the operation will start, you can expand Details to see the progress, once completed click the Close button.

o Click the power button in the bottom right corner, then select reboot.

o Edit the VM and remove the ISO from the CD/ROM device (change to Client)

o When the server restarts it will do a Check Disk, let this complete, Windows will prompt for a reboot after you login

o Reboot and load Disk Management and your Primary Partion will be the new size without any unallocated space

Method 5[/b] - Using Knoppix Live CD with QtPartEd- (http://www.knoppix.org/) to shrink a disk

o Download the Knoppix Live CD and make it available so it can be mounted by the virtual machine’s CD-ROM

o Shutdown the virtual machine you want to resize

o Add a second virtual disk of the new smaller desired size to the VM you want to resize

o Connect the Virtual Machine to the Knoppix Live CD ISO file and make sure you enable Connected at Power On

o Power on the Virtual Machine

o Press ESC at the Bios screen to get to the Boot Menu

o Select CD-ROM as the Boot device

o Press Enter at the boot screen

o Click on the K Menu icon and then select System and then QTPartEd

o Select your original drive (usually sda) and click on the partition 1

o Select Operations from the top menu and then Resize, resize the drive so it is just less then the new drives (sdb) capacity

o Select File from the top menu and then Commit, click Yes at the warning window

o Once complete, select Cancel if you get a unmounted hard disk window and then OK at the Progress window.

o Open a Konsole window and type “dd if=/dev/sda of=/dev/sdb” This copy will take a long time and will not show a status while it is running. Yyou will get an insufficient space error at the end of the copy, this is normal because the drive you’re copying from is bigger then the destination. But as long as the partition is smaller, everything will work.

o Shutdown the VM and edit the VM settings, remove the original C: drive and change the SCSI ID of the new drive to match the old one (usually 0:0)

o Power on the VM and it will run a Chkdsk and you will be all set

Method 6[/b] – Use Ghost or another 3rd party imaging product to shrink a disk

o Shutdown the virtual machine you want to resize

o Add a second virtual disk of the new smaller desired size to the VM you want to resize

o Use Ghost to clone the first disks partition to your second virtual disk.

o Once complete make sure the second virtual disk is ‘Active’

o Switch your disks by editing the virtual machine settings and switching the SCSI id’s (0:0 and 0:1)

o If the virtual machine boots OK and you verify that everything works then shutdown the VM and remove the larger disk and delete it

0 Kudos
10 Replies
oreeh
Immortal
Immortal

Nice, one more candidate for a FAQ section.

one minor correction

>o Select US English at the Language screen

>o Select qwerty/us.map at the Keyboard screen

should be:

o select you local language at the Language screen

o select your keyboard layout at the Keyboard screen

0 Kudos
esiebert7625
Immortal
Immortal

Ah, you're right, I usually document for my own environment. I sometimes forget to globalize and generalize when publishing it....thanks

0 Kudos
jasonboche
Immortal
Immortal

VERY NICE!

VCDX3 #34, VCDX4, VCDX5, VCAP4-DCA #14, VCAP4-DCD #35, VCAP5-DCD, VCPx4, vEXPERTx4, MCSEx3, MCSAx2, MCP, CCAx2, A+
0 Kudos
RDPetruska
Leadership
Leadership

One thing... "shrink" usually means compressing the used data space in a growable (sparse) virtual disk. And that is NOT supported at all on ESX 3, as only preallocated (flat) virtual disks are. I think in your case, you are actually referring to decreasing the max. size of the virtual disk (i.e. the opposite of "extending", or increasing the max. size of the virtual disk) here. And the wording may be confusing and/or misleading.

0 Kudos
esiebert7625
Immortal
Immortal

True, the wording is a little mis-leading, I think in this case shrink is a technique that the end result is a smaller drive, I wasn't implying you could do this with vmkfstools.

0 Kudos
kiwistag
Contributor
Contributor

Is there any way to "Shrink"a disk like you could in VMWare Server (GSX) where it would resize/shrink to the size requested.

We have an array with a 650GB partition & no other space on the ESX server storage volumes to create another disk to ghost / migrate to.

The 690GB disk is being reduced to 600GB on the storage device (physical RAID 5) to allocate room for other virtual machines. The virtual disk is only 400GB at this stage.

0 Kudos
RParker
Immortal
Immortal

Method 6: Use Integrated sizing in VIC and another Windows virtual machine to extend a disk

Edit settings for VM. Click on harddisk, resize as needed using tools. Then follow Method 3 to continue...

0 Kudos
michigun
VMware Employee
VMware Employee

what about windows dynamic disks?

As far as I know, the most of partition utilities don't working with it?

-- http://www.vm4.ru/p/vsphere-book.html
0 Kudos

Paragon Partition Manager 9 works with windows dynamic disk.

At least they say it works, I didn't try.

---

http://blog.vadmin.ru

EMCCAe, MCITP: SA+VA, VCP 3/4/5, VMware vExpert http://blog.vadmin.ru
0 Kudos
pgenest
Contributor
Contributor

We're using LeftHand Networks SANiQ/iSCSI with DL320s and all of our "storage" is to this SAN through iSCSI Software Adapters (vmhba40). Do you know if any of your, (well documented BTW), solutions will still work?

0 Kudos