Or I wished…
Step 0: Safety Third:
First I backed up VM. I can be a bit monkey brain so critical step.

Step 1: Changes in the file system:
VM off and added 10gb to the disk

After booting VM we can verify that the disk has become bigger
root@bitwarden ~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 35G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 24G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 20G 0 lvm /
root@bitwarden ~# fdisk -l /dev/sda
GPT PMBR size mismatch (52428799 != 73400319) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 35 GiB, 37580963840 bytes, 73400320 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 16DB24D7-666C-459B-A2A3-89FCD57DDD3F
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 52426751 50325504 24G Linux filesystem
Step 2: We delete everything
2.1.2025: I recommend to use cfdisk instead now. Since resizing is simpler with cf disk. # cfdisk /dev/sda
-> resize (Will select the highest capacity) -> write (confirm with yes)
root@bitwarden ~# fdisk /dev/sda
... truncated output ...
GPT PMBR size mismatch (52428799 != 73400319) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Command (m for help): p
Disk /dev/sda: 35 GiB, 37580963840 bytes, 73400320 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 16DB24D7-666C-459B-A2A3-89FCD57DDD3F
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 52426751 50325504 24G Linux filesystem
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 has been deleted.
Command (m for help): n
Partition number (3-128, default 3):
First sector (2101248-73400286, default 2101248):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2101248-73400286, default 73400286):
Created a new partition 3 of type 'Linux filesystem' and of size 34 GiB.
Partition #3 contains a LVM2_member signature.
Do you want to remove the signature? [Y]es/[N]o: N
Answer no, or it will delete everything. I messed up here and deleted everything. Had to recover from a backup.
Command (m for help): f
f: unknown command
Command (m for help): t
Partition number (1-3, default 3):
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@bitwarden ~#
Step 3: Resizing LVM
root@bitwarden ~# partprobe /dev/sda
root@bitwarden ~# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 1 0 wz--n- <24.00g <4.00g
root@bitwarden ~# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
root@bitwarden ~# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 1 0 wz--n- <34.00g <14.00g
root@bitwarden ~# lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 20.00 GiB (5120 extents) to <34.00 GiB (8703 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@bitwarden ~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu-vg lvm2 a-- <34.00g 0
root@bitwarden ~#
Step 4: And now for the magic
root@bitwarden ~# 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 = 3, new_desc_blocks = 5
The filesystem on /dev/mapper/ubuntu--vg-ubuntu-t-lv is now 8911872 (4k) blocks long.
root@bitwarden ~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 34G 17G 16G 52% /
root@bitwarden ~#
And now we can enjoy larger disk.
Ending Notes
I have truncated some command outputs for example lsblk displays docker containers and tmpfs but I have removed them.
2.1.2025: Needed this again, decided to put here since search it here first, after realizing it in my nextcloud. Rewrote some bits and made better flow.
Leave a Reply