Ubuntu – How to extend partition in Ubuntu Guest on Vmware

gpartedpartitioningvmware

On my Windows 7 host, I am using VMware Player to use Ubuntu. I had initially allocated 20GB and now getting Disk space full errors. So I wanted to extend partition. By searching on forums I saw how to add more disk and used this command to make it 30G –

sudo lvextend -L30G /dev/sda1

But still df command shows that max is 20GB. After more searching it seems that I need to extend partition using gparted. I tried using that but Resize button is disabled. I searched for that and they say that if the partition shows a key image then that partition is active and I cannot change it if it is live.
Screenshot

After some more search looks like this can also be fixed by using booting the OS from CD or using gparted boot from cd, boot using iso etc etc without giving any clear instructions. Can someone please guide or post any link which has clear instructions including screenshots for a linux layman as to how I can extend the partition.

Best Answer

Just did it in a Ubuntu 18.04 Server guest over a Windows 10 host.

The easiest way is, like you already suggested, to boot a live Ubuntu (the regular one, not server) and use GParted.

But first you need to "configure" the VMWare to increase the "virtual disk" size. Follow these steps:

  1. Shutdown the guest
  2. Click on "edit virtual machine settings" of that guest
  3. Click on "Hard disk" and "Expand..."
  4. A VMware window will let you modify the size, in GBs, of the device. Set the size you want and click on "Expand". After a while it will end.

At this point, the hard drive is bigger than before, but the partition is not. You must resize the partition also. To do so, download the ISO file of the regular Ubuntu distribution. Any other bootable device will also work, but this is the simplest way. Having the ISO downloaded do this:

  1. In the same configuration window as before, instead of configure the "Hard Disk" go to "CD/DVD" section.
  2. Make sure the option "Connect at power on" is set.
  3. Select "Use ISO image file:" and browse to the ISO file you downloaded.

After this, the guest is ready to be launched. Click in "Play virtual machine" and pay attention because you need to press the Esc key very quick to enter the boot menu, just before the VMWARE logo appears. As it were the BIOS of your physical computer.

Tip: After click on "Play..." click again over the VMWare window (black screen at this point) to make sure that the control of keyboard and mouse are in the guest, and not in the host. If you miss this step, you can simply reboot and try again.

Once you see the boot options:

  1. Press the down arrow key to highlight "CD-ROM Drive" and press enter.
  2. Ubuntu will start as live session.
  3. Select appropriate language and "Try Ubuntu".
  4. Wait until the desktop is loaded.

Look for the GParted tool and launch it. You will see two main blocks, one with some color (yellow probably) and the other in gray. The colored block is your actual partition (probably called /sda/sda1). To resize it do:

  1. Right click on the yellow block and select "ummount" or "stop"
  2. Right click again and "resize".
  3. In the new window, drag the limit of the partition to wherever you want of the free space (gray).
  4. Click "Ok"
  5. Don't forget to click in "Apply changes" in Gparted's main window before closing, otherwise the operation is not performed.

Once it is finished, you have already a bigger partition, just reboot and you will be good to go. (Don't forget to uncheck the CD/DVD Connect at power on if it is not needed).

Related Question