Had a situation arise yesterday where a coworker was wanting to extend an LVM Volume Group across two disks. It’s actually really simple to do.
The first thing we do is use vgdisplay to show original info for the Volume Group. Notice how when you look at this, the Free PE Size is 0MB.
[root@nfsen01 ~]# vgdisplay
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.88 GB
PE Size 32.00 MB
Total PE 92
Alloc PE / Size 92 / 2.88 GB
Free PE / Size 0 / 0
VG UUID XXXXXXXXXXXXXXXXXXXXXXXXXX
To create the LVM PV on your new new disk follow these steps.
fdisk /dev/sdb
n
p
1
enter
enter
t
1
8e
w
Now we will probe for the new linux partition without rebooting:
partx -v -a /dev/sdb
pvcreate /dev/sdb1
Assuming you are using sdb1 as your drive, extending the Volume Group is as simple as:
vgextend VolGroup00 /dev/sdb1
And this will extend the volume across the entire disk. You should be able to run vgdisplay again and see your free PE size went up.
What you have to do next is extend the Logical Volume for the disk. This is optional depending on your objectives, if you wanted a common VG and wanted to create new volumes you can do it at your convenience now.
lvextend -L +931.51G /dev/mapper/VolGroup00-LogVol00
Assuming you’re running EXT3 you would use this command. For other file systems on top of LVM your milage may vary; Consult your documentation.
resize2fs /dev/mapper/VolGroup00-LogVol00 -p
After this is done you should be able to use df -h on the drive, and see your partition has been enlarged. This can even be done while the system is active, there’s no need for any boot CDs or the likes.