Ubuntu: How to Extend a Root Drive
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 795M 1.4M 794M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29G 27G 0 100% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 974M 210M 698M 24% /boot
/dev/loop2 64M 64M 0 100% /snap/core20/2015
/dev/loop0 41M 41M 0 100% /snap/snapd/20290
/dev/loop1 64M 64M 0 100% /snap/core20/2105
/dev/loop3 92M 92M 0 100% /snap/lxd/24061
/dev/loop4 41M 41M 0 100% /snap/snapd/20671
tmpfs 795M 0 795M 0% /run/user/1000
# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <29.00 GiB
PE Size 4.00 MiB
Total PE 7423
Alloc PE / Size 7423 / <29.00 GiB
Free PE / Size 0 / 0
VG UUID 8uMRE1-uOny-bMV2-oeGM-mTA6-J3e3-N0P2KE
# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID 0e7NYA-oxvj-zwwK-ByD3-Cptw-pbUt-N73wFL
LV Write Access read/write
LV Creation host, time ubuntu-server, 2020-12-11 21:35:31 +0800
LV Status available
# open 1
LV Size <29.00 GiB
Current LE 7423
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
# cfdisk
Select “Write” from the bottom menu, type yes to confirm, and hit ENTER. Then use “q” to exit the program.
# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <99.00 GiB / not usable 16.50 KiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25343
Free PE 17920
Allocated PE 7423
PV UUID PXrn7f-Sj55-sV8u-1ut6-2SdA-bC9W-sWcbfR
# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <99.00 GiB
PE Size 4.00 MiB
Total PE 25343
Alloc PE / Size 7423 / <29.00 GiB
Free PE / Size 17920 / 70.00 GiB
VG UUID 8uMRE1-uOny-bMV2-oeGM-mTA6-J3e3-N0P2KE
# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <29.00 GiB (7423 extents) to <99.00 GiB (25343 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID 0e7NYA-oxvj-zwwK-ByD3-Cptw-pbUt-N73wFL
LV Write Access read/write
LV Creation host, time ubuntu-server, 2020-12-11 21:35:31 +0800
LV Status available
# open 1
LV Size <99.00 GiB
Current LE 25343
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 13
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 25951232 (4k) blocks long.
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 795M 1.3M 794M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 27G 67G 29% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 974M 210M 698M 24% /boot
/dev/loop2 64M 64M 0 100% /snap/core20/2015
/dev/loop4 41M 41M 0 100% /snap/snapd/20671
/dev/loop1 92M 92M 0 100% /snap/lxd/24061
/dev/loop0 64M 64M 0 100% /snap/core20/2105
/dev/loop3 41M 41M 0 100% /snap/snapd/20290
tmpfs 795M 0 795M 0% /run/user/1000
https://packetpushers.net/blog/ubuntu-extend-your-default-lvm-space/#:~:text=First%2C%20run%20df%20%2Dh%20to,installer%20to%20your%20root%20filesystem.
Update