When we have space pressure on logical volumes (LV), we will seek for free space (or you may say unused space) in volume groups (VG) first. If there's no free space left for increasing the size of LV, it's time to add some physical volumes (PV) to the VG.
Let's check the VG and see what situation we are in.
[root@test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 39.51g 0
[root@test ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
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 39.51 GiB
PE Size 4.00 MiB
Total PE 10114
Alloc PE / Size 10114 / 39.51 GiB
Free PE / Size 0 / 0
VG UUID TyYYcm-27vh-gi62-06J0-c8zy-oOWK-hstO95
As you can see, there's no unused space in this VG. That is, we need more PVs. We have to seek for non-partitioned space which can be physical volume candidates.
[root@test ~]# fdisk -l
Disk /dev/sda: 257.7 GB, 257698037760 bytes
255 heads, 63 sectors/track, 31330 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009ac13
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 38.3 GB, 38260441088 bytes
255 heads, 63 sectors/track, 4651 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Luckily, we do have some non-partitioned space in /dev/sda, so we can create a partition (i.e. dev/sda3 in sequence).
Please note that, the system type that we want to add space is 8e which is LVM and highlighted in the above.
[root@test ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (5222-31330, default 5222):
Using default value 5222
Last cylinder, +cylinders or +size{K,M,G} (5222-31330, default 31330):
Using default value 31330
Now we have to change the system type of the device into 8e (LVM).
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 257.7 GB, 257698037760 bytes
255 heads, 63 sectors/track, 31330 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009ac13
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
/dev/sda3 5222 31330 209715185 8e Linux LVM
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
Check the partition result, There should be 3 partitions in /dev/sda.
[root@test ~]# fdisk -l
Disk /dev/sda: 257.7 GB, 257698037760 bytes
255 heads, 63 sectors/track, 31330 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009ac13
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
/dev/sda3 5222 31330 209715185 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 38.3 GB, 38260441088 bytes
255 heads, 63 sectors/track, 4651 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
partprobe all devices to make system recognize the new partition /dev/sda3 online.
[root@test ~]# partprobe
Or restart the system before actually making a PV.
[root@test ~]# init 6
If you met errors when partprobe, you may refer to this post for further information: How to Resolve PartProbe Error: "WARNING: the kernel failed to re-read the partition table on /dev/sda".
Create a PV for /dev/sda3.
[root@test ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
Add the PV /dev/sda3 to the VG. In this case, it's VolGroup.
[root@test ~]# vgextend VolGroup /dev/sda3
Volume group "VolGroup" successfully extended
Let's check the VG again.
[root@test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz--n- 239.50g 200.00g
[root@test ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
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 239.50 GiB
PE Size 4.00 MiB
Total PE 61313
Alloc PE / Size 10114 / 39.51 GiB
Free PE / Size 51199 / 200.00 GiB
VG UUID TyYYcm-27vh-gi62-06J0-c8zy-oOWK-hstO95
Now, the VG has more free space around 200GB.
So you can see that increasing VG size is actually a process of creating PVs and adding them to it.
Next, I think you might be interested in How to Increase Logical Volume Size on Linux.