ESXi 5 : Increasing the size of a virtual disk and grow the partition in Ubuntu

Posted on Friday, April 6, 2012



I have an Ubuntu 10.04 Desktop running as a VM image in an ESXi 5 server.  It has a second virtual hard drive that is 50 GiB in size.   I want to increase the size of the virtual disk and grow the partition.






Right click on the server you want to edit and click Edit Settings.



Select the hard drive you want to increase in size.  This one was originally 50Gib I increased it to 100GiB and clicked OK.


Get the Gparted ISO

You can’t resize a partition in a live running Ubuntu (at least I do not know how ;) ) You need to download the Gparted ISO from here http://gparted.sourceforge.net/download.php [1]. 

After you download the ISO upload the ISO to the ESXi datastore.




Right click on the ESXi server from vSphere Client.  Then select the Summary tab and right click on the datastore and select Browse Datastore.





Click on the upload button to upload this ISO to the datastore.   In my case I had already created an ISO folder to upload to.









Right click on the server again and click Edit settings.





Select CD/DVD click browse and select the Gparted iso file.  Then checkbox connect at power on.






Now click the options tab and select Boot options and check box “the next time the virtual machine boots, force entry into the BIOS screen.  Then click OK.

This is done because the CD is probably not set as the first boot device.

Now reboot the machine.



In the BIOS set the CD-ROM drive as the first boot device
F10 to save and exit



Gparted starts up click enter.


Don’t touch the keymap and click OK,  just accept all the rest of the defaults.



Finally you get here,  Click on screen resolution and increase the size so you can actually see something.


Click on GParted -> Devices -> drive you want to edit.  (in this case /dev/sdb


Select the partition and click resize


Drag the bar to fill the space and click resize




At the bottom you will see the “1 operation pending”



Click Apply


Click Apply again.


You should see it start to grow the partition.


Click close after it is done.


Turn off the VM server then edit the VM again and select the CD/DVD and uncheck all the boxes and select Client Device and click OK.



Oops, I forgot to edit the /etc/fstab


       > sudo vi /etc/fstab


I added


/dev/sdb1      /disk2     ext3    defaults   0  0


Now reboot



There we go now you can see the drive has been grown to 100GB



References
[1]  Gparted download page, 
       Visited 4/2012
[2]   How to Increase Virtual Machine Disk Space in VMware ESXi 4.1
       http://blog.techgalaxy.net/archives/3174 
       visited 4/2012

2 comments:

  1. On my ESXi server I am using complete disk space available(I have not created LVM). I added a new partition and mounted that and made it by default.

    To increase the diskspace following are the steps that I have followed:
    Step1: Check the size with 'fdisk -l' & 'df -Th'
    Step2: From ESXi vSphere client increase the disk space.
    Step3: Restart the server(vm server on ESXi server)
    Step4: 'fdisk -l;df -Th' doesn't show any difference with the output from Step1
    Step4: resize2fs
    Step5: 'fdisk -l;df -Th' shows the difference.

    Correct me if I am wrong.

    ReplyDelete
    Replies
    1. I just tried this myself and I did not have any luck.
      The system kept saying "The filesystem is already 5242624 blocks long. Nothing to do!"

      If you have a more detailed procedure that works I would like to see it so I can test it on my machine.

      Delete