One of the benefits of LVM (Logical Volume Manager) is the possibility to extend LVM based storage by adding new Physical Volumes which together form LVM Volume Group. Adding new Physical Volume increases the capacity of the whole Volume Group by the capacity of that particular Physical Volume and can be performed online without any outages in LVM activity.
Steps:
1. Power off the server
2. Insert new hard disk and power on the server
3. Verify, if new hard disk was detected by the system:
[root@tuxfixer ~]# fdisk -l
...
Disk /dev/sdb: 120 GiB, 128849018880 bytes, 251658240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
...
4. Create new partition on new hard disk and set it’s type to 0x8e:
[root@tuxfixer ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xd035cd45.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-251658239, default 2048): 2048
Last sector, +sectors or +size{K,M,G,T,P} (2048-251658239, default 251658239): 251658239
Created a new partition 1 of type 'Linux' and of size 120 GiB.
Command (m for help): p
Disk /dev/sdb: 120 GiB, 128849018880 bytes, 251658240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd035cd45
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 251658239 251656192 120G 83 Linux
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): 0x8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): p
Disk /dev/sdb: 120 GiB, 128849018880 bytes, 251658240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd035cd45
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 251658239 251656192 120G 8e Linux LVM
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
5. Initialize new partition for use with existing Volume Group:
Verify existing Volume Group (in our case named fedora) before extension:
[root@tuxfixer ~]# vgdisplay fedora
--- Volume group ---
VG Name fedora
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 49.51 GiB
PE Size 4.00 MiB
Total PE 12674
Alloc PE / Size 12673 / 49.50 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID R2Tjtr-5jk6-0CbQ-dMj7-VYVg-z9d5-DGlD9w
Note: size of the Volume Group before extension is 49,51 GiB and there is only 4 MiB of free space in the Volume Group.
Initialize new partition (/dev/sdb1) as new Physical Volume:
[root@tuxfixer ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
6. Extend existing Volume Group with the new Physical Volume (/dev/sdb1)
[root@tuxfixer ~]# vgextend fedora /dev/sdb1
Volume group "fedora" successfully extended
7. Verify Volume Group after extension
[root@tuxfixer ~]# vgdisplay fedora
--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 169.50 GiB
PE Size 4.00 MiB
Total PE 43393
Alloc PE / Size 12673 / 49.50 GiB
Free PE / Size 30720 / 120.00 GiB
VG UUID R2Tjtr-5jk6-0CbQ-dMj7-VYVg-z9d5-DGlD9w
Note: new size of the existing Volume Group is now 169,50 GiB and there is 120 GiB of free space in the Volume Group.