Here we use CentOS7.
Step 1. Check your LVM space useage.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_gitlab01-root 93G 54G 40G 58% /
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 4.0K 1.4G 1% /dev/shm
tmpfs 1.4G 8.4M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda1 497M 237M 260M 48% /boot
/dev/mapper/centos_gitlab01-home 5.0G 33M 5.0G 1% /home
tmpfs 285M 0 285M 0% /run/user/0
Step 2. Show all existed LVMs.
# lvdisplay
--- Logical volume ---
LV Path /dev/centos_gitlab01/root
LV Name root
VG Name centos_gitlab01
LV UUID RjHlm0-C9xW-x1Wx-sNmj-H5eD-t0Ek-fRAELc
LV Write Access read/write
LV Creation host, time gitlab01, 2016-05-13 12:57:49 +0800
LV Status available
# open 1
LV Size 92.50 GiB
Current LE 23681
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
... more
Step 3. Find the new hard disk index number.
# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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
Disk label type: dos
Disk identifier: 0x0000f450
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 209715199 104344576 8e Linux LVM
Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 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
Disk /dev/mapper/centos_gitlab01-root: 99.3 GB, 99325313024 bytes, 193994752 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
...more
Step 4.
# fdisk /dev/sdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-314572799, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-314572799, default 314572799):
Using default value 314572799
Partition 1 of type Linux and of size 150 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Step 5.
# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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
Disk label type: dos
Disk identifier: 0x0000f450
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 209715199 104344576 8e Linux LVM
Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 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
Disk label type: dos
Disk identifier: 0x282e09ee
Device Boot Start End Blocks Id System
/dev/sdb1 2048 314572799 157285376 8e Linux LVM
Disk /dev/mapper/centos_gitlab01-root: 99.3 GB, 99325313024 bytes, 193994752 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
...more
Step 6.
# vgdisplay
--- Volume group ---
VG Name centos_gitlab01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 99.51 GiB
PE Size 4.00 MiB
Total PE 25474
Alloc PE / Size 25473 / 99.50 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID nOobB3-jmbs-Ry1l-qFeo-1CBo-Xm7f-1huTGY
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
# vgextend centos_gitlab01 /dev/sdb1
Volume group "centos_gitlab01" successfully extended
# pvscan
PV /dev/sda2 VG centos_gitlab01 lvm2 [99.51 GiB / 4.00 MiB free]
PV /dev/sdb1 VG centos_gitlab01 lvm2 [150.00 GiB / 150.00 GiB free]
Total: 2 [249.50 GiB] / in use: 2 [249.50 GiB] / in no VG: 0 [0 ]
# vgdisplay
--- Volume group ---
VG Name centos_gitlab01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 249.50 GiB
PE Size 4.00 MiB
Total PE 63873
Alloc PE / Size 25473 / 99.50 GiB
Free PE / Size 38400 / 150.00 GiB
VG UUID nOobB3-jmbs-Ry1l-qFeo-1CBo-Xm7f-1huTGY
# lvextend -l +38400 /dev/centos_gitlab01/root
Size of logical volume centos_gitlab01/root changed from 92.50 GiB (23681 extents) to 242.50 GiB (62081 extents).
Logical volume centos_gitlab01/root successfully resized.
# xfs_growfs /dev/mapper/centos_gitlab01-root
meta-data=/dev/mapper/centos_gitlab01-root isize=256 agcount=4, agsize=6062336 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=24249344, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=11840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 24249344 to 63570944
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_gitlab01-root 243G 54G 190G 22% /
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 4.0K 1.4G 1% /dev/shm
tmpfs 1.4G 8.4M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda1 497M 237M 260M 48% /boot
/dev/mapper/centos_gitlab01-home 5.0G 33M 5.0G 1% /home
tmpfs 285M 0 285M 0% /run/user/0
http://droidspa.blogspot.tw/2016/07/centos-7.html
https://sc8log.blogspot.tw/2017/03/linux-lvm-lvm.html
http://download.ithome.com.tw/article/index/id/1280
https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-adding-a-new-disk/
http://linoxide.com/linux-how-to/add-new-disk-centos-7-without-rebooting/
http://ithelp.ithome.com.tw/articles/10081243
http://bencane.com/2011/12/19/creating-a-new-filesystem-with-fdisk-lvm-and-mkfs/