Allocating more space on your Linux VM – after you already added more space with your VM Manager / VirtualBox etc

VirtualBox – File->Tools-VirtualMedia Manager to increase filesize

fdisk -l

mine was /dev/sda

fdisk /dev/sda

create a new partition with the “n”

command accept beginning and ending defaults

my new partiton was 3

now set the partition type to LVM by doing t command for chage type, I picked partition 3, the 8e for LVM

don’t forget to do a “w” before exiting fdisk otherwise your fdisk changes are not saved

create a physical volume with pvcreate

pvcreate /dev/sda3

List the volume groups with vgdisplay

vgdisplay
--- Volume group ---
VG Name ol
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <39.00 GiB
PE Size 4.00 MiB
Total PE 9983
Alloc PE / Size 9983 / <39.00 GiB
Free PE / Size 0 / 0
VG UUID maPsJk-B38g-eAHb-lNJM-XhOf-YOPr-tffgJx

Note vgextend uses 1.) volume group name: ol, 2.) new physical device: /dev/sda3

vgextend ol /dev/sda3
Volume group "ol" successfully extended

Now do a lvextend

pvscan # to confirm physical space is available to be used by lvextend

note: use name from lvdisplay above in lvextend below

lvextend -L+38G /dev/ol/root
...
Logical volume ol/root successfully resized.

lastly run lvdisplay (/dev/ol/root) again to get the volume name – then with the following command use all the free space available:

xfs_growfs /dev/ol/root

note: similar command to xfs_growfs – resizefs – only works on old fs types – cat /etc/fstab to see file system type which in my case was xfs

cat /etc/fstab
/dev/mapper/ol-root / xfs
Scroll to Top