1- List current partition table for sdb # fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 1572 MB, 1572864000 bytes 255 heads, 63 sectors/track, 191 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 130 1044193+ 8e Linux LVM 2- The volume group testvg is on /dev/sdb1 # vgdisplay -v testvg Using volume group(s) on command line Finding volume group "testvg" --- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 1 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 1 Act PV 1 VG Size 1.46 GB PE Size 4.00 MB Total PE 374 Alloc PE / Size 374 / 1.46 GB Free PE / Size 0 / 0 VG UUID eZzHlt-rHEf-L9A0-4J38-ixwC-eLoq-h2GIZf --- Logical volume --- LV Name /dev/testvg/testlv VG Name testvg LV UUID dWydnH-rdO1-YXjo-wnPm-23cO-BnzP-5GzSzv LV Write Access read/write LV Status available # open 1 LV Size 1.46 GB Current LE 374 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:2 --- Physical volumes --- PV Name /dev/sdb1 PV UUID 5Huyrd-Juc2-UtUO-LocX-BnSR-8hQv-1Guluh PV Status allocatable Total PE / Free PE 374 / 0 3- The logical volume testlv is on testvg and mounted on /d1 # df -h /d1 Filesystem Size Used Avail Use% Mounted on /dev/mapper/testvg-testlv 1.5G 35M 1.5G 3% /d1 4- Shutdown the host and extend LUN vmware-vdiskmanager -x 2000MB SAN.vmdk 5- Check new disk geometry, create a new "extended partition", to be able to extend more than 3 times the LUN # fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 2097 MB, 2097152000 bytes 255 heads, 63 sectors/track, 254 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 191 1534176 8e Linux LVM Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 2 First cylinder (192-254, default 192): Using default value 192 Last cylinder or +size or +sizeM or +sizeK (192-254, default 254): Using default value 254 Command (m for help): p Disk /dev/sdb: 2097 MB, 2097152000 bytes 255 heads, 63 sectors/track, 254 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 191 1534176 8e Linux LVM /dev/sdb2 192 254 506047+ 5 Extended Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (192-254, default 192): Using default value 192 Last cylinder or +size or +sizeM or +sizeK (192-254, default 254): Using default value 254 Command (m for help): p Disk /dev/sdb: 2097 MB, 2097152000 bytes 255 heads, 63 sectors/track, 254 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 191 1534176 8e Linux LVM /dev/sdb2 192 254 506047+ 5 Extended /dev/sdb5 192 254 506016 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. 6- Reboot the host to update the partition table (or use partprobe?) # reboot 7- Create a new pv on the new logical unit # pvcreate /dev/sdb5 Physical volume "/dev/sdb5" successfully created 8- Extend the volume group # vgextend testvg /dev/sdb5 Volume group "testvg" successfully extended 9- Check the new FREE PE value # vgdisplay testvg --- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 1,94 GB PE Size 4,00 MB Total PE 497 Alloc PE / Size 374 / 1,46 GB Free PE / Size 123 / 492,00 MB VG UUID eZzHlt-rHEf-L9A0-4J38-ixwC-eLoq-h2GIZf Test 2 - A Second Extension 1- Let's create a new logical volume on the previously extended space and populate with some data. # lvcreate -n test2lv -l 123 testvg Logical volume "test2lv" created # mkfs -t ext3 /dev/testvg/test2lv # mount /dev/testvg/test2lv /d2 # df -h /d2 Filesystem Size Used Avail Use% Mounted on /dev/mapper/testvg-test2lv 477M 11M 442M 3% /d2 2- Populate /d2 and check the data # tar cf /d2/etc.tar /etc tar: Removing leading `/' from member names # tar tvf /d2/etc.tar | wc -l 3883 3- Shutdown the host and extend the LUN # poweroff vmware-vdiskmanager -x 2500MB SAN.vmdk 4- Remove the old extended partition and create a new one, maintaining the existing start and end cylinders for existing logical units, and creating the new logical unit needed on the free space # fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 2621 MB, 2621440000 bytes 255 heads, 63 sectors/track, 318 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 191 1534176 8e Linux LVM /dev/sdb2 192 254 506047+ 5 Extended /dev/sdb5 192 254 506016 83 Linux Command (m for help): d Partition number (1-5): 5 Command (m for help): d Partition number (1-5): 2 Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 2 First cylinder (192-318, default 192): Using default value 192 Last cylinder or +size or +sizeM or +sizeK (192-318, default 318): Using default value 318 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (192-318, default 192): Using default value 192 Last cylinder or +size or +sizeM or +sizeK (192-318, default 318): 254 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (255-318, default 255): Using default value 255 Last cylinder or +size or +sizeM or +sizeK (255-318, default 318): Using default value 318 Command (m for help): p Disk /dev/sdb: 2621 MB, 2621440000 bytes 255 heads, 63 sectors/track, 318 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 191 1534176 8e Linux LVM /dev/sdb2 192 318 1020127+ 5 Extended /dev/sdb5 192 254 506016 83 Linux /dev/sdb6 255 318 514048+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. 5- Restart the host to update the partition table (or use partprobe?) # reboot 6- Check previous file systems # df -h /d1 /d2 S.ficheros Tamaño Usado Disp Uso% Montado en /dev/mapper/testvg-testlv 1,5G 35M 1,5G 3% /d1 /dev/mapper/testvg-test2lv 477M 47M 405M 11% /d2 7- Create a new physical volume # pvcreate /dev/sdb6 Physical volume "/dev/sdb6" successfully created 8- Extend the volume group # vgextend testvg /dev/sdb6 Volume group "testvg" successfully extended 9- Check the new FREE PE value # vgdisplay testvg --- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 2,43 GB PE Size 4,00 MB Total PE 622 Alloc PE / Size 497 / 1,94 GB Free PE / Size 125 / 500,00 MB VG UUID eZzHlt-rHEf-L9A0-4J38-ixwC-eLoq-h2GIZf 10- Extend the logical volume # lvextend -l +125 /dev/testvg/test2lv Logical volume test2lv successfully resized 11- Extend the file system # ext2online /dev/testvg/test2lv ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b # df -h /d2 S.ficheros Tamaño Usado Disp Uso% Montado en /dev/mapper/testvg-test2lv 961M 48M 865M 6% /d2 12- Check data availability # tar tvf /d2/etc.tar | wc -l 3883