Ubuntu lvm disk expand vmware
In this guide the VM resides in Vmware and the operating system is Ubuntu 18.04, but should be somewhat applicable to other Linux OS’es
Begin with connecting to your server and type in
sudo fdisk -lIf your disk has 4 partitions you cannot expand any more using this method (you can still attach a new disk and expand the existing LVM using this method)Sign on to your vCenter and edit settings of the virtual machine, increase the size of your disk
Locate which SCSI devices you have
sudo ls /sys/class/scsi_device/Then rescan the devices (or simply reboot the server if it is possible)
sudo echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan
sudo echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescanIf you re-run fdisk -l /dev/sda you can now see that the size of the disc is now the size you set (If you get GPT errors, try sudo parted -l)
Now run
fdisk /dev/sdaType
nand press enter Accept the default partition number 3 (or 2/4) (The default first sector should be OK but you may have to compare to earlier partitions so you dont overwrite. ie the first sector should not be inside an existing one If you get a GPT error with a missmatch error, you may run gdisk /dev/sda, w to write, press Y to correct the invalid sectors and write. Re-run fdisk /dev/sda)Write the changes by typing
w, enterIt is now time to extend the LVM with our new partition! Create the physical volume with the newly created partition:
pvcreate /dev/sda3Type
pvsand you should see the existing volumegroup, default in ubuntu isubuntu-vgExtend the volumegroup with the new volume:
vgextend ubuntu-vg /dev/sd3After that it’s time to extend the volume to it’s new size:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv /dev/sda3If you are having troubles finding the correct volumenames you can trylvdisplayResize the volume to expand to max size:
resize2fs /dev/ubuntu-vg/ubuntu-lvand then verify the new disksize withdf -h
Last updated