Extending/resizing a logical volume file system
In my infinite wisdom, I recently decided to “Just add more disk” to address a problem I was having with garbage collection. I wanted to add another 16GB of storage to my LVM filesystem to just stop my monitoring from carrying on about there being <20% available. Plus, the microk8s garbage collection was being garbage.
I’m using proxmox as my virtualisation layer, so adding more disk on was dead easy. I’ll leave that as an exercise for the reader.
Increasing my LVM root partition was a little more involved. But, in the end, it came down to just a few commands:
lsblk
This will list information about your block devices attached to your system
pvresize
This resizes the Physical Volume attached to the LVM
vgs
This gives information about the Volume Group(s)
pvs
This gives information about the Physical Volume(s)
lvextend
This does the magic
The combination of these that makes the magic work is:
lsblk
List out your block devices and note the one you increased the storage onpvresize /dev/sda3
Resize the Physical Volume to match the new sizelsblk
Give it the once over to make sure the new numbers are appliedvgs
Look at the Volume Group to see how it’s lookingpvs
Look at the Physical Volumes to see how they’re goinglvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Here’s the good bit. This extends the Logical Volume AND the file system (-r) to the full size of the newly resized Physical Volumedf
Gaze in wonder at all the additional storage you have available to you now
Other commands that might be helpful:s
Have a look at their manpages and/or –help system
partprobe
This informs the operating system about partition table changes. This is useful if/when yourlsblk
,vgs
and/orpvs
aren’t seeing the updated numbers.growpart
This will rewrite the partition table so the partition takes up all the space it can. This is more useful for systems NOT using LVM.resize2fs
The resize2fs program willresize ext2, ext3, or ext4 file systems. This is more useful for systems NOT using LVM.fsadm
This utility checks or resizes the filesystem on a device. This is used by some internal systems. YMMV.fdisk
Display or manipulate a disk partition table. You can create or destroy your file systems and data in here. You have been warned.
Explore other related articles:
lvm /
pv /
lv /
storage /
Penned by Paul Macdonnell on 2023-12-26
Things do, stuffs get