27 growpart /dev/sda 3
28 resize2fs /dev/sda3
29 lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
30 resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
31 df -h
32 lsblk
If you have disk space already assigned to the VM from the host, you can verify using command
ravi@claude-1:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 118G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 118G 0 lvm /
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
To expand partition, eg. /dev/sda3 you have to use
root@claude-1:~# growpart /dev/sda 3
CHANGED: partition=3 start=4198400 old: size=121628672 end=125827071 new: size=247459807 end=251658206
Then resize logical volume to match partition size with
root@claude-1:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <58.00 GiB (14847 extents) to <118.00 GiB (30207 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
And in the end expand it’s filesystem using
root@claude-1:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 8, new_desc_blocks = 15
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 30931968 (4k) blocks long.
And you’re all set.
Before and after below.
ravi@claude-1:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 58G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 58G 0 lvm /
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
ravi@claude-1:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 118G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 118G 0 lvm /
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom