Thursday, November 20, 2008

Fast way to resize a virtual disk with VMware ESX Server

We’re starting some SharePoint development and I needed to create a development environment on Windows Server 2003.  So I created a new virtual machine (VM) of Server 2003 on our VMware ESX box and gave it a 1GB of RAM and 8GB of disk space.  I installed the OS and configured it for Windows SharePoint Services (WSS) and then installed Visual Studio 2008.  That left us with about 1.5GB of disk space.  Oops, time to resize the drive.

The beauty of working with virtual machines is that it’s relatively easy to increase or decrease the memory and disk storage.  In this case, I wanted to add another 4GB to the virtual disk.  I powered down the virtual machine and went into the “Virtual Machine Properties” from the VMware Infrastructure Client (VIC).  I selected the hard drive and it provided a entry field for the new size.  I increased the size to 12GB, adding an additional 4GB.

That takes us part way there.  I increased the size if the virtual disk from 8GB to 12GB, but it still has an 8GB partition, the OS wont see the additional space.  I saw all some tips on that Series of Tubes that recommended downloading Linux boot disks and boot the the VM from the Linux CD images as an .ISO file.

Meh, that’s too much work.  I took a simpler path.  I powered down another Server 2003 VM that was already running on the ESX box and added new VM’s virtual disk as a second virtual drive.  I booted up the second VM and opened up a command shell.  From the command shell, I ran the diskpart utility to extend the partition.  I did the following commands through diskpart:

diskpart


Microsoft DiskPart version 5.1.3565

         
Copyright (C) 1999-2003 Microsoft Corporation.

On computer: XXXXX



DISKPART> list volume

 

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info

  ----------  ---  -----------  -----  ----------  -------  ---------  --------

  Volume 0     E                       DVD-ROM         0 B
  Volume 1     C NTFS   Partition     12 GB  Healthy    Boot
  Volume 2     D NTFS   Partition    8 GB  Healthy


 

 

DISKPART> select volume 2
 
Volume 2 is the selected volume.
 
DISKPART> extend

 

DISKPART> exit

      
Leaving DiskPart...


I basically typed that in from memory, some of the numbers may be off, but it shows how to extend the size of the partition.  After exiting out of diskpart, I then shut down the second VM.  Next, I removed the virtual drive that belongs to the new VM.  Remember to select remove only and not remove and delete.  At this point I was able to power both VM’s back up.  The second VM will be slightly confused about the missing drive, but it was back to normal.  The new VM took some time to check out the resized partition after I logged back in.  With my VM, it declared it to be new hardware and wanted to reboot.  After it rebooted, it was happy and recognized that it had a 12GB partition.

3 comments:

  1. one way that i've found is using vmware converter to extend os disks. might take more time, but it works pretty well also

    ReplyDelete
  2. The VMware Converter would do the job, but it would have taken much longer. It took longer to write up this blog post than it did to resize the drive. By using diskpart, I was able to extend the partition in place, while using VMware Converter would have copied the files around.

    ReplyDelete
  3. Note, that when you added new VM’s virtual disk as a second virtual drive, YOU THEN NEED TO INCREASE THE CAPACITY OF THE DRIVE to the desired size. You have to do this prior to booting and performing Diskpart, as the extend will fail if there is no additional space designated. Great tech note Chris, this is a huge time saver and works fantastic. I also had to reinstall VM Tools after the resize.

    ReplyDelete

Note: Only a member of this blog may post a comment.