If you have some unused disk space and want to add to the volume group.No data will be lost on existing volume.
root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-root 1.9G 910M 989M 48% /
devtmpfs 874M 0 874M 0% /dev
tmpfs 884M 0 884M 0% /dev/shm
tmpfs 884M 8.4M 876M 1% /run
tmpfs 884M 0 884M 0% /sys/fs/cgroup
/dev/sda1 1.9G 138M 1.8G 8% /boot
/dev/mapper/vg02-u02 1.9G 33M 1.9G 2% /u02
/dev/mapper/vg02-u01 950M 33M 918M 4% /u01
/dev/mapper/vg01-var 1.9G 74M 1.8G 4% /var
/dev/mapper/vg01-home 1.9G 33M 1.9G 2% /home
tmpfs 177M 0 177M 0% /run/user/
Space running out on vg02.
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg01 1 4 0 wz–n- 7.45g 0
vg02 1 2 0 wz–n- 2.80g 4.00m
root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 1.9G 0 part /boot
├─sda2 8:2 0 5.6G 0 part
│ ├─vg01-root 253:0 0 1.9G 0 lvm /
│ ├─vg01-home 253:2 0 1.9G 0 lvm /home
│ └─vg01-var 253:3 0 1.9G 0 lvm /var
├─sda3 8:3 0 6.5G 0 part
│ ├─vg02-swap 253:1 0 1.9G 0 lvm [SWAP]
│ ├─vg02-u01 253:4 0 2.8G 0 lvm /u01
│ └─vg02-u02 253:5 0 3.9G 0 lvm /u02
└─sda4 8:4 0 2G 0 part
└─vg02-u02 253:5 0 3.9G 0 lvm /u02
sr0 11:0 1 1024M 0 rom
There is plenty of space on /dev/sda
I am going to increase space in volume u02 .i.e /dev/vgo2/u02 by 3 GB
[root@localhost ~]# lvdisplay /dev/vg02/u02
— Logical volume —
LV Path /dev/vg02/u02
LV Name u02
VG Name vg02
LV UUID b2NFoX-umEu-UeMx-dn1i-lXa7-7Q8b-H4xPTd
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2018-10-30 14:02:23 -0400
LV Status available
# open 1
LV Size 1.86 GiB
Current LE 477
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 8192
Block device 253:3
1. create a new partition containing the space after sda4
[root@localhost u02]# fdisk /dev/sda
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p
Selected partition 4
First sector (25427968-52428799, default 25427968):
Using default value 25427968
Last sector, +sectors or +size{K,M,G} (25427968-52428799, default 52428799): +3G
Partition 4 of type Linux and of size 3 GiB is set
Command (m for help): w
2. Reboot to ensure that all partitions are registered properly and the device names are created.
After reboot
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 1.9G 0 part /boot
├─sda2 8:2 0 7.5G 0 part
│ ├─vg01-root 253:0 0 1.9G 0 lvm /
│ ├─vg01-swap 253:1 0 1.9G 0 lvm [SWAP]
│ ├─vg01-home 253:2 0 1.9G 0 lvm /home
│ └─vg01-var 253:3 0 1.9G 0 lvm /var
├─sda3 8:3 0 2.8G 0 part
│ ├─vg02-u01 253:4 0 956M 0 lvm /u01
│ └─vg02-u02 253:5 0 1.9G 0 lvm /u02
└─sda4 8:4 0 3G 0 part
a. Create a partition
pvcreate /dev/sda4
Physical volume “/dev/sda4” successfully created.
b. Extend volume group vg02
[root@localhost ~]# vgextend vg02 /dev/sda4
Volume group “vg02” successfully extended
c. vgdisplay -v vg02 ;; to see the added size and # extents
Now more space is contained in volumegroup.
[root@localhost ~]# vgdisplay vg02
— Volume group —
VG Name vg02
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 5.80 GiB
PE Size 4.00 MiB
Total PE 1484
Alloc PE / Size 716 / 2.80 GiB
Free PE / Size 768 / 3.00 GiB
VG UUID OyHZN2-SE4D-R25V-Yv9s-td7P-Hc1v-nC3fhK
For safety I’d suggest unmounting the logical volume that you want to expand.
d. Extend the logical volume u02
[root@localhost ~]# lvextend -L+2G /dev/vg02/u02
Size of logical volume vg02/u02 changed from 1.86 GiB (477 extents) to 3.86 GiB (989 extents).
Logical volume vg02/u02 successfully resized.
[root@localhost ~]# xfs_growfs /dev/vg02/u02
meta-data=/dev/mapper/vg02-u02 isize=512 agcount=4, agsize=122112 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=488448, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 488448 to 1012736
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-root 1.9G 910M 989M 48% /
devtmpfs 874M 0 874M 0% /dev
tmpfs 884M 0 884M 0% /dev/shm
tmpfs 884M 8.4M 876M 1% /run
tmpfs 884M 0 884M 0% /sys/fs/cgroup
/dev/sda1 1.9G 138M 1.8G 8% /boot
/dev/mapper/vg01-var 1.9G 74M 1.8G 4% /var
/dev/mapper/vg01-home 1.9G 33M 1.9G 2% /home
/dev/mapper/vg02-u02 3.9G 33M 3.9G 1% /u02
Your logicalvolumepath will now have more available space.