This guide shows how to add a drive to an existing LVM volume.
- Erase the partition table on drive /dev/hdd and create the Physical volume
# dd if=/dev/zero of=/dev/hdd bs=1024k count=1
# pvcreate /dev/hdd
- Look at the current volume group, for fun
# sudo vgdisplay -A
— Volume group —
VG Name disks
System ID
Format lvm2
Metadata Areas 7
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 7
Act PV 7
VG Size 859.70 GB
PE Size 4.00 MB
Total PE 220084
Alloc PE / Size 220084 / 859.70 GB
Free PE / Size 0 / 0
VG UUID N4TcI6-DIRS-3edy-FAa0-tdUL-MTSX-bs2lJE
- Add the Physical Volume to the existing Volume Group, which I creatively named “disks”
# sudo vgextend disks /dev/hdd
- Look at the current Volume Group again, my how it has grown
# sudo vgdisplay -A
— Volume group —
-snip-
VG Size 1.11 TB
PE Size 4.00 MB
Total PE 291625
Alloc PE / Size 220084 / 859.70 GB
Free PE / Size 71541 / 279.46 GB
- Extend the Logical Volume, this time named “backup”, use the free extents reported by vgdisplay
# sudo lvextend -l+71541 /dev/disks/backup
Extending logical volume backup to 1.11 TB
Logical volume backup successfully resized
- And then look at vgdisplay again, whee
# sudo vgdisplay -A
— Volume group —
-snip-
VG Size 1.11 TB
PE Size 4.00 MB
Total PE 291625
Alloc PE / Size 291625 / 1.11 TB
Free PE / Size 0 / 0
- Now the final and most exciting step, expanding the filesystem. You’re using XFS right? And here’s a surprise, it should be mounted when you resize it. xfs_growfs will automatically resize the XFS filesystem to use all the available free space, and do it in less than a second.
# sudo xfs_growfs /backup
i guess another good question with LVM extention is…do you need it?
im at work butchering an old BSD NAS (toaster, whatever.) with a 700mhz processor and a whopping 128mb of ram. with such a shitty FSB and memory available extending the partition in my case just bogged down the mysql process beyond reason.