7

I have Ubuntu installed on a VirtualBox VM. How can I resize the Linux partition (not the virtual drive)?

I already performed the VM resize using VBoxManage modifyhd to resize the virtual drive, but I need to resize the Linux partition. I do not have a GUI to gparted, so I need to resize the partition from the command line.

0

1 Answer 1

5

If you use LVM (Logical Volume Manager):

  1. Expand physical volume (sda3 replace by your partition name):

    sudo pvresize /dev/sda3
    
  2. Check free space:

    sudo vgdisplay
    
  3. Add space to logical volume (VG00/share replace by your LV path; you can get it from sudo lvdisplay):

    sudo lvresize –L -r 100G VG00/share
    
  4. Check changes:

    sudo lvdisplay
    

If you don't use LVM:

All below commands work for unmounted partition, so you should boot from another source, for example, from iso (liveCD image).

  1. Change partition size: sudo fdisk /dev/sda3:

    • remove old partition (d)
    • create new one, bigger (n)
    • write changes (w)
  2. Expand file system:

    sudo e2fsck -f /dev/sda3
    sudo resize2fs /dev/sda3
    
  3. Reboot system, boot as usual.

  4. Check partitions:

    df
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .