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:
List out your block devices and note the one you increased the storage on
Resize the Physical Volume to match the new size
Give it the once over to make sure the new numbers are applied
Look at the Volume Group to see how it’s looking
Look at the Physical Volumes to see how they’re going
lvextend -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 Volume
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
This informs the operating system about partition table changes. This is useful if/when your
pvsaren’t seeing the updated numbers.
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.
The resize2fs program willresize ext2, ext3, or ext4 file systems. This is more useful for systems NOT using LVM.
This utility checks or resizes the filesystem on a device. This is used by some internal systems. YMMV.
Display or manipulate a disk partition table. You can create or destroy your file systems and data in here. You have been warned.
Penned by Paul Macdonnell
Things do, stuffs get