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.
If you use LVM (Logical Volume Manager):
Expand physical volume (sda3 replace by your partition name):
sudo pvresize /dev/sda3
Check free space:
sudo vgdisplay
Add space to logical volume (VG00/share replace by your LV name):
sudo lvresize –L -r 100G VG00/share
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).
sudo fdisk /dev/sda3
:d
)n
)w
)Expand file system:
sudo e2fsck -f /dev/sda3 sudo resize2fs /dev/sda3
Reboot system, boot as usual.
Check partitions:
df