Extend Volume Group and Logical Volume on CentOS/RHEL

Scenario: Added new disk /dev/sdc then extend Volume Group and extend Logical Volume /var on CentOS/RHEL
System: CentOS/RHEL 6/7 (ext4 filesystem)

Steps:
– After added disk /dev/sdc then create partition on /dev/sdc

[root@horse ~]# parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 32.3kB 21.5GB 21.5GB Free Space

(parted) mkpart
Partition type? primary/extended? p
File system type? [ext2]?
Start? 0%
End? 100%
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 32.3kB 1049kB 1016kB Free Space
 1 1049kB 21.5GB 21.5GB primary

(parted) q
Information: You may need to update /etc/fstab.
[root@horse ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-root 10G 1.3G 8.8G 13% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.7M 903M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 1014M 232M 783M 23% /boot
/dev/mapper/VolNFS-lv_nfs 100G 33M 100G 1% /NFSdisk
/dev/mapper/VolGroup-var 10G 249M 9.8G 3% /var
/dev/mapper/VolGroup-opt 10G 33M 10G 1% /opt
/dev/mapper/VolGroup-home 5.0G 33M 5.0G 1% /home
tmpfs 183M 0 183M 0% /run/user/0
[root@horse ~]# fdisk -l | grep sd
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 81797119 39848960 8e Linux LVM
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
/dev/sdb1 2048 209715199 104856576 83 Linux
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
/dev/sdc1 2048 41943039 20970496 83 Linux
[root@horse ~]#

– Extend the Volume Group and LV var in steps below:

[root@horse ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 VolGroup 1 5 0 wz--n- 38.00g 0
 VolNFS 1 1 0 wz--n- <100.00g 200.00m
[root@horse ~]# vgextend VolGroup /dev/sdc1
 Physical volume "/dev/sdc1" successfully created.
 Volume group "VolGroup" successfully extended
[root@horse ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 VolGroup 2 5 0 wz--n- <58.00g <20.00g
 VolNFS 1 1 0 wz--n- <100.00g 200.00m
[root@horse ~]# lvdisplay | grep Path
 LV Path /dev/VolGroup/root
 LV Path /dev/VolGroup/home
 LV Path /dev/VolGroup/swap
 LV Path /dev/VolGroup/opt
 LV Path /dev/VolGroup/var
 LV Path /dev/VolNFS/lv_nfs
[root@horse ~]# lvextend -L +19.5G /dev/VolGroup/var
 Size of logical volume VolGroup/var changed from 10.00 GiB (2560 extents) to 29.50 GiB (7552 extents).
 Logical volume VolGroup/var successfully resized.
[root@horse ~]# xfs_growfs /dev/VolGroup/var
meta-data=/dev/mapper/VolGroup-var isize=512 agcount=4, agsize=655360 blks
 = sectsz=512 attr=2, projid32bit=1
 = crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2621440, 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=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2621440 to 7733248
[root@horse ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-root 10G 1.3G 8.8G 13% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.7M 903M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 1014M 232M 783M 23% /boot
/dev/mapper/VolNFS-lv_nfs 100G 33M 100G 1% /NFSdisk
/dev/mapper/VolGroup-var 30G 250M 30G 1% /var
/dev/mapper/VolGroup-opt 10G 33M 10G 1% /opt
/dev/mapper/VolGroup-home 5.0G 33M 5.0G 1% /home
tmpfs 183M 0 183M 0% /run/user/0
[root@horse ~]#

Leave a Reply

Your email address will not be published. Required fields are marked *