Tuesday, January 5, 2010

How to increase the size of C drive in windows virtual machine in ESX 3.5

Let me first talk about extending the size for a non boot partition of a windows 2003 virtual machine in vmware esx 3.5.

To extend a non boot partition in windows 2003 virtual machine, you don't need to shut the system down. Lets say our virtual machine is Test1 with a D drive of 1 GB. To increase the D drive from 1 to 2 GB do this:
  1. Go to "Test1" virtual machine properties by clicking on "Edit virtual machine settings" on VMWare Infrastructure Client.
  2. Select the hard drive that you want to extend. Increase the disk size and click Ok. Wait for the process to complete.
  3. Go to the virtual machine "Computer Manangement" console and click on "disk management". You will see the extra space that you added as a chunk of unallocated block right next to the existing disk. You will need to extend the current disk to the available extra space.
  4. Go to the command prompt and type "diskpart". This will activate the diskpart utility. Then type "list volume" (looks like "DISKPART>list volume"). That will list the existing volumes.
  5. Select the volume you need to extend the size of by "select volume x" where x is the volume number (eg. "DISKPART>select volume 1"). It will inform that "volume 1" is the selected volume.
  6. Then extend the volume by "extend" ("DISKPART>extend"). You can notice in the disk managment console that the volume is extended. You can exit out of diskpart by entering"exit" from diskpart prompt.

Now HOW TO INCREASE THE SIZE OF C DRIVE IN WINDOWS 2003 VIRTUAL MACHINE!

As you realized it is easier to extend the size of a D or E (non boot drive) with diskpart utility. But remember that diskpart utility supports only the extension of data partitions. Systems or boot partitions maybe blocked from being extended. You may be able to extend the boot and system partitions into unallocated space but the file system may not be extended, so the computer might stop responding.

But there is a workaround. Lets say you need to extend the size of the C drive from 15 GB to 20 GB on Test1 server. Here is how you do it (after making sure you have a good backup of the entire system and that you have administrator privileges):

  • Remove the disk from Test1
  • Add the disk from Test1 to another server (lets call this Test2 server)
  • Increase the size of the Test1 disk that was imported to Test2.
  • Extend the size of the Test1 disk from Test2 disk management console.
  • Remove the Test1 disk from Test2 virtual machine.
  • Add the Test1 disk back to Test1.

Details of each process below.

Remove the disk from Test1

  1. Shut down Test1.
  2. Right click Test1 and select "Edit Settings"
  3. Select the disk and click on "Remove". MAKE SURE YOU HAVE CHOSEN "Remove from virtual machine" from 'Removal Options'. DO NOT choose "Remove from virtual machine and delete files from disk"
  4. Click OK. Remember in which datastore the disk is located because we will need to browse to it when attaching it to a different server.

Add the disk from Test1 to another server (lets call this Test2 server)

  1. Right click the other server on which you wish to attach the disk from Test1 and click on "edit settings".
  2. Click "Add" --> "hard disk" --> "Use an existing disk". Then browse to the datastore where the disk from Test1 is located. Select the disk from Test1.
  3. Click OK. Wait for process to complete.
  4. Go to disk management console of Test2 and make sure the disk from Test1 shows up.

Increase the size of the Test1 disk that was imported to Test2.

  1. Right click on Test2 and go to "edit settings" console.
  2. Select the hard disk from Test1 and increase the size (say to 20 GB from 15 GB).
  3. click OK and wait for the process to complete.

Extend the size of the Test1 disk from Test2 disk management console.

  1. Go to Test2 disk management console. You will see that the disk from Test1 has an unallocated block right next to it.
  2. Open up a command prompt in Test2. ("cmd" from Run)
  3. Type "Diskpart" without quotes (looks like --- C:\>Diskpart). This starts up the diskpart utility.
  4. Type "list volume" (DISKPART>list volume)
  5. Type "select volume x" where x is the number of the volume in concern (example, DISKPART>select volume 2). Make sure you have the correct volume selected by verifying the size of the disk.
  6. Type "Extend" (Diskpart>extend). Diskpart will inform that the volume was successfully extended. Exit out of diskpart by typing "exit".
  7. Verify that the disk was extended from disk management console of Test2. The disk from Test1 should show the increased size now.

Remove the Test1 disk from Test2 virtual machine

  1. Shut down Test2.
  2. Right click onf Test2 virtual machine and go to "edit settings" console.
  3. Select the disk and click on "Remove". BEFORE YOU DO SO MAKE SURE On 'Removal Options' you have chosen "Remove from virtual machine". DO NOT choose "Remove from virtual machine and delete files from disk"
  4. Click OK. Wait for the process to finish.

Add the Test1 disk back to Test1

  1. Right click Test1 virtual machine --> Edit settings.
  2. Click Add-->Hard Disk --> Use an existing disk
  3. Browse to the datastore where the disk from Test1 is located and select the disk.
  4. Click OK and wait for the process to complete.
  5. Boot up! You now have a C drive with an increase space!!!

No comments:

Post a Comment