27

I'm running Ubuntu Desktop 14.04 as a VM on a mac with vmware fusion. I'm getting space warning issues and now want to expand from 20GB to 200GB.

I powered off the VM and on the vmware side increased the allocated disk space:

  1. Power off the VM
  2. VMWare Fusion -> Virtual Machine -> Settings -> Hard Disk (SCSI)

It then warned me that I should increase the partition size within the guest VM, which is unfortunate because I was hoping this would be automatic.

Looking at the disk usage analyzer inside of Ubuntu, it only currently sees the original 20 GB. How do I increase this to the 200 GB I allocated?

I'm looking for better direction than what is posted here.

From the Disks app, I see:

enter image description here

17

From Ubuntu (in VM) Install gparted by executing sudo apt-get install gparted in Terminal.

Open gparted either from terminal or from dash. Then extend you disk, maybe you may have to move your extended partition at the end of disk.

  • 1
    But you can not modify a partition that's currently in use. And because it's a VM, booting from a USB stick isn't as straightforward. Can you provide any more details? – tarabyte Apr 16 '15 at 16:49
  • You can boot from iso image (live session) in VM and then modify the disks using gparted – Faizan Akram Dar Apr 17 '15 at 2:51
  • 1
    Turns out you can modify a partition which is in use. – tarabyte May 6 '15 at 5:28
16

You do not need a live CD for this to work. I'm basically summarizing the other answers given here:

  1. From Ubuntu (in VM) install gparted by executing sudo apt-get install gparted in terminal
  2. Open sudo gparted from terminal
  3. Rightclick on the swap partition, click "swapoff"
  4. Delete swap partition
  5. Extend your data partition, but leave enough space to create a new swap partition
  6. Recreate swap partition with about the same size as before, select linux-swap as file system
  7. Click that green tick in gparted to apply all operations. Then select "swapon" to enable swap again
  • 1
    Today you answered a 2 years old question, coincidentally I needed this Today!! – Vagish Nov 27 '17 at 8:12
  • 1
    And I needed it today. – Richard Pennington Dec 18 '17 at 16:02
  • 2
    This should be the selected answer. The selected answer doesn't mention that if there is a partition between your main filesystem and your free space, that you will have to remove it in order to extend your main fs, and then you'll have to recreate it after. – Nathan F. Mar 28 '18 at 16:44
  • easies way to do it . – Mihai Jan 22 at 9:47
  • @NathanFiscaletti Indeed, the selected answer doesn't mention anything about removing partition (if it is between main fs and free space) but it does mention about moving it :) – Faizan Akram Dar Mar 1 at 15:17
13
  1. Download gparted LIVECD iso from here
  2. From your VM Choose the iso file and boot as live CD

    • Add the iso into your cd-rom drive from the GuestVM settings

    or

    • Set to boot from the CDROM in BIOS (F2 when you start your VM)
  3. Once tha gparted Live Cd runs you can use gparted now
  4. Choose the partition to resize and choose the new size and then apply
  5. When end reboot and be sure to remove the iso file attached to the VM CD ROM, and boot to your Ubuntu.

enter image description here

  • Can you elaborate more on step 2? Choose from what? Right-click? – tarabyte Apr 20 '15 at 3:05
  • @tarabyte Choose the Gparted IO Live CD to boot from in your Virtual machine.... – Maythux Apr 20 '15 at 7:32
  • So download Gparted IO Live CD on the Host OS, and NOT the guest OS (Ubuntu)? – tarabyte Apr 20 '15 at 21:13
  • Download wherever you want but use it in the CD ROM of your VM which means the guest – Maythux Apr 21 '15 at 5:17
  • In case there is a swap partition in between: askubuntu.com/a/120381/126822 – rlcabral Nov 19 '16 at 19:30
6

You should first delete all partitions between your partition and free space. You can do it using parted command.

  1. Install parted if you don't have them using :

    sudo apt-get install cloud-guest-utils
    
  2. turn off swap. we gonna remove it's partition!

    sudo swapoff -a
    
  3. run sudo parted.
  4. get partitions list with print all:

    (parted) print all
    Model: Virtio Block Device (virtblk)
    Disk /dev/vda: 752GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start   End    Size    Type      File system     Flags
    1      1049kB  528GB  528GB   primary   ext4            boot
    2      528GB   537GB  8588MB  extended
    5      528GB   537GB  8588MB  logical   linux-swap(v1)
    
  5. remove none root partitions with rm (part-index):

    (parted) rm 5
    Warning: Partition /dev/vda5 is being used. Are you sure you want to continue?
    Yes/No? yes
    Error: Partition(s) 5 on /dev/vda have been written, but we have been unable to
    inform the kernel of the change, probably because it/they are in use.  As a
    result, the old partition(s) will remain in use.  You should reboot now before
    making further changes.
    Ignore/Cancel? C
    (parted) print all
    Model: Virtio Block Device (virtblk)
    Disk /dev/vda: 752GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start   End    Size    Type      File system  Flags
     1      1049kB  528GB  528GB   primary   ext4         boot
     2      528GB   537GB  8588MB  extended
    
    
    (parted) rm 2
    Error: Partition(s) 5 on /dev/vda have been written, but we have been unable to
    inform the kernel of the change, probably because it/they are in use.  As a
    result, the old partition(s) will remain in use.  You should reboot now before
    making further changes.
    Ignore/Cancel? C
    (parted) print all
    Model: Virtio Block Device (virtblk)
    Disk /dev/vda: 752GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start   End    Size   Type     File system  Flags
     1      1049kB  528GB  528GB  primary  ext4         boot
    

The commands works on ubuntu 16.04 (NONE LVM) and machine is running on a kvm:

sudo growpart /dev/vda 1
sudo resize2fs /dev/vda1   
  • 2
    growpart and resize2fs are e.g. available via sudo apt-get install cloud-guest-utils – NextThursday Jun 20 '18 at 14:21
  • cloud-guest-utils (and thus growpart) is also available on Ubuntu 14.04. – jmidgren Sep 27 '18 at 8:01
  • Much better. Who's putting desktop OS's on VMs? [I know, I know; I have a bunch, too, but for the most part they should be headless] – Auspex Apr 26 at 14:15

protected by Community Jan 31 at 23:57

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.