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/sda1But 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.
13 Answers
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:
- Shutdown the guest
- Click on "edit virtual machine settings" of that guest
- Click on "Hard disk" and "Expand..."
- 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:
- In the same configuration window as before, instead of configure the "Hard Disk" go to "CD/DVD" section.
- Make sure the option "Connect at power on" is set.
- 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:
- Press the down arrow key to highlight "CD-ROM Drive" and press enter.
- Ubuntu will start as live session.
- Select appropriate language and "Try Ubuntu".
- 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:
- Right click on the yellow block and select "ummount" or "stop"
- Right click again and "resize".
- In the new window, drag the limit of the partition to wherever you want of the free space (gray).
- Click "Ok"
- 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).
1This is a several step solution: You can't resize your existing partition on /dev/sda1, because the free space is not congruent to that partition (next to it), and Ubuntu will not like you to move and resize partitions while it is running.
One step, easier, is to simply rebuild your VM.
Assuming that you do not want to reinstall your VM, you will need to boot your VM from the Ubuntu ISO - your can download it here if you don't have a copy. This will be similar to booting your computer with a USB.
After you boot, choose 'Try Ubuntu' to load a live Ubuntu session. Then you can use gparted to move the existing extended partition /dev/sda2, to the end of the disk. When you have done that, the unallocated space will be next to your /dev/sda1, and you will be able to expand /dev/sda1 to consume the space.
In short:
- Boot from live USB (Ubuntu ISO)
- Open gparted
- Move /dev/sda2 to the end of the disk
- Expand /dev/sda1 to consume the free space
- Reboot the VM, without using the ISO
I've done this without having to use a LiveCD/have access to an Ubuntu iso. You just have to first make sure that you extend the partition associated with the virtual machine in VMWare first -- but as this is not seen in the "guest", then run gparted from within your Ubuntu virtual machine and extend the partition that is now seen/released by VMWare. That is,
first adjust partition associated with the virtual machine in VMWare as described by Carlos above.
If you do not have gparted installed yet in your Ubuntu virtual guest, open up a terminal and install it:
sudo apt-get install gpartedLaunch gparted
gpartedExtend the partition that your root (/) is installed in. If your root is in a separated extended partition than your "unallocated" space (new hard disk space you just had VMWare recognize/make available to your guest), you might have to do this in 2 steps: first expand the extended drive containing the mount point (in v.1.0.0 GUI version of gparted, you right-click on that extended partition > Resize/Move), and then again for the partition for the mount point (again, right-click on the partition that root is mounted on). Then click on the green check mark to apply changes and you are good to go.