Thursday, October 11, 2012

repartition disk ubuntu 12.04 in vmware with GParted

I was playing with my linux and unix VMs (vmware workstation 9) to setup for my lab environment, for the purpose of my lab session. I am surviving with only my dell XPS which runs on win7 Enterprise :( While playing setting up, there were 2 main obstacles that made me a "dumbledore"  moment.

In this session, I shall highlight the guide to solve one of the obstacles. The other is with wxwidget, which I will cover soon.

When I was creating a VM for ubuntu 12.04, at the option to select disk space, I only create a VMDK of only 4GB. This is because I am trying to save on the HDD space on my dell XPS. Installation went well, until i booted up and start to compile and run my code. To my horror, my free space in ubuntu is left with 127MB, that is after several sudo apt-get of the necessary software. A quick df -h showed me the details of the HDD space use.  Therefore, I need to increase the VMDK size (by 1GB hahaha... I am damn ngiao[petty] OK!).  

Few steps to complete this.
1. Power off the guest OS VM (e.g Ubuntu 12.04). 
2. Change the Hardware setting of the VM to XXX GB (as required).
3. Download GParted iso (opensource disk utility) on the host OS.
4. Power on guest OS VM
5. mount 3. 
6. restart ubuntu 12.04 (click shutdown from dashboard, in the popup on the LHS, there is a restart)
7. while rebooting press F2 on the vm boot sequece to go into the pseudo bios scree.
8. change the boot sequence by moving CD Rom to the top (it contains the GParted) and save before exit
9. continue to boot as usual and you will be greeted by the GParted GUI (unless you have choosen otherwise during the startup dialog)
10. Use GParted to resize the partition and then reboot

the dumb moment..... I am trying to make sense out of the google research I did on using GParted at step10. None of the results user guides are detailed enough to help a layman (e.g me) to use it. After some experimentation based on the steps given by others and recalling my prior experience, I managed to deduce the steps to assign the unallocated space created from VM workstation and resize it to be larger.

**Rules of thumb: Never delete the boot partition on the LHS. Always compact the partition on the RHS of the boot partition by 1.Delete partition (s) to the RHS of the boot partition. 2. Combining unallocated space. 3. Resizing of boot partition will always take the unallocated space from the RHS of the boot partitition. 

Explore the partition information. In this screenshot from my VM, my unallocated is at the extreme RHS, which is not sequentially next to the boot partition. 

Right Click on linux swap partition, then click on information. Check that partition is swap-off (e.g the swap-on option is waiting for you to enable, DO NOT click it). Right click again to delete the linux swap partition (/dev/sda5) and then right click on /dev/sda2 to delete the extended partition. The final output will be the screen above. Note that my unallocated space became 2GB from 1 GB.
Right Click on the boot partition and click on resize. The popup window appeared to allow adjusting of the hdd size by sliding the vertical bar or changing the new size parameter. I leave 1GB for the linux swap partition. To finalize all the new settings, click on the OK button. 

Next, click on the remaining unallocated space and assign it to be extended partition, such that logical partition can be created in it. Review the lower window on the actions to be executed. Once finalize click on the apply button.

Fingers crossed.....

Reboot to guest OS and double check the size of the partition by issuing sudo fdisk -l

1 comment:

Desi Dude said...

Thank you for this post. It helped me a lot compared to any other posts out there. With help of screenshots, I was able to understand step by step what to do. Good contribution.