Ubuntu 20.04 LTS Extending Storage Volume - llewellyn-marriott/notes GitHub Wiki
VMWare
Extend the drive as usual in VMWare.
Guest
We must now make the guest machine realise there is more space on the storage drive.
Rescan SCSI
Restart the guest machine, I have not yet found a way to get the drive rescan to work without a reboot. You are meant to be able to use something like this:
sudo apt-get install scsitools
sudo rescan-scsi-bus
Or this:
echo "- - -" > /sys/class/scsi_host/host2/scan
But I couldn't get it to work without a reboot
Extend the partition
The partition you want to extend should be sda3 and should be at the end of the drive. If it is not, you are in trouble. We can't actually "extend" the partition, so instead we just delete this current one not delete the data and make a new one that starts at the same place on the disk.
sudo fdisk /dev/sda
Command (m for help): p
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 176160734 174059487 83G Linux filesystem
Command (m for help): d
Selected partition 3
Command (m for help): p
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 1): 3
First sector (2048-10485759, default 2048):
Using the start value from above 2101248
Last sector, +sectors or +size{K,M,G} (2101248-174059487, default 194059487):
Using default value 194059487
Command (m for help): p
Device Boot Start End Blocks Id System
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 194059487 191958239 89G Linux filesystem
Command (m for help): w
The partition table has been altered!
Reboot or run partprobe
LVM
Extend the Physical Volume
Take a look at the physical volume and you should see some free PE
pvdisplay /dev/sda3
Resize it
pvresize /dev/sda3
Extend the Virtual Volume
Find the name
sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID q5Bgj3-ds2g-Jg14-2BDy-fLGq-R1A5-iFYeED
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-02-23 07:11:37 +0000
LV Status available
open 1
LV Size <67.00 GiB
Current LE 17151
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
Extend it
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Verify new size
sudo lvscan
ACTIVE '/dev/ubuntu-vg/ubuntu-lv' [<83.00 GiB] inherit
Filesystem
Extend the filesystem
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Verify
df -h
Finally done!
Credits: