系统的文件系统类型如下:
[root@tomas121 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos_tomas121-root xfs 50G 1.4G 49G 3% /
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 58M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/centos_tomas121-data xfs 481G 200G 282G 42% /data
/dev/sda1 xfs 497M 125M 373M 26% /boot
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0
系统一分配的逻辑卷如下:
[root@tomas121 ~]# cd /dev/centos_tomas121/
[root@tomas121 centos_tomas121]# ls
data root swap
1.1、fdisk -l#查看磁盘
[root@tomas121 ~]# fdisk -l
Disk /dev/sda: 300.0 GB, 300000000000 bytes, 585937500 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: 0x00027686
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 585814015 292393984 8e Linux LVM
Disk /dev/sdb: 300.0 GB, 300000000000 bytes, 585937500 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
#上面显示/dev/sdb 为新增磁盘
1.2、pvcreate /dev/sdb #创建物理卷,将新增磁盘加入到物理卷
[root@tomas121 centos_tomas121]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@tomas121 centos_tomas121]# pvs #查看物理卷
PV VG Fmt Attr PSize PFree
/dev/sda2 centos_tomas121 lvm2 a-- 278.85g 0
/dev/sdb lvm2 --- 279.40g 279.40g
[root@tomas121 centos_tomas121]# pvdisplay #查看物理卷信息
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_tomas121
PV Size 278.85 GiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 71385
Free PE 0
Allocated PE 71385
PV UUID 6fedHJ-uBvR-AeRq-PcEn-UK9n-aKu5-B1E3UB
"/dev/sdb" is a new physical volume of "279.40 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 279.40 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ZVnShK-YjZa-RADS-fYiL-rZX5-Y4BT-vT6Szl
1.3、vgextend centos_tomas121 /dev/sdb #扩展卷组centos_tomas121,即将PV加入卷组(VG)
[root@tomas121 centos_tomas121]# vgextend centos_tomas121 /dev/sdb
Volume group "centos_tomas121" successfully extended
[root@tomas121 centos_tomas121]# pvs #查看物理卷
PV VG Fmt Attr PSize PFree
/dev/sda2 centos_tomas121 lvm2 a-- 278.85g 0
/dev/sdb centos_tomas121 lvm2 a-- 279.39g 279.39g
[root@tomas121 centos_tomas121]# pvdisplay #查看物理卷信息
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_tomas121
PV Size 278.85 GiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 71385
Free PE 0
Allocated PE 71385
PV UUID 6fedHJ-uBvR-AeRq-PcEn-UK9n-aKu5-B1E3UB
--- Physical volume ---
PV Name /dev/sdb
VG Name centos_tomas121
PV Size 279.40 GiB / not usable 2.29 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 71525
Free PE 71525
Allocated PE 0
PV UUID ZVnShK-YjZa-RADS-fYiL-rZX5-Y4BT-vT6Szl
1.4、vgdisplay #查看卷组信息
[root@tomas121 centos_tomas121]# vgdisplay
--- Volume group ---
VG Name centos_tomas121
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
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 558.24 GiB
PE Size 4.00 MiB
Total PE 142910
Alloc PE / Size 71385 / 278.85 GiB
Free PE / Size 71525 / 279.39 GiB
VG UUID Cn4INa-4uP4-QXvk-qQEH-Z67P-0Rl6-1xaccU
1.5、lvextend -L +279.39G /dev/centos_tomas121/data #将原/data逻辑卷的大小增加279.39G
[root@tomas121 centos_tomas121]# lvextend -L +279.39G /dev/centos_tomas121/data
Rounding size to boundary between physical extents: 279.39 GiB
Size of logical volume centos_tomas121/data changed from 200.91 GiB (51432 extents) to 480.30 GiB (122956 extents).
Logical volume data successfully resized.
[root@tomas121 ~]# df -hP|grep /data #查看/data目录的磁盘空间大小
/dev/mapper/centos_tomas121-data 201G 199G 1.9G 100% /data
1.6、xfs_growfs /dev/centos_tomas121/data #执行扩容调整,将文件系统增到逻辑卷的大小
[root@tomas121 centos_tomas121]# xfs_growfs /dev/centos_tomas121/data
meta-data=/dev/mapper/centos_tomas121-data isize=256 agcount=4, agsize=13166592 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=52666368, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=25716, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 52666368 to 125906944
#对原/data逻辑卷进行扩容后,再次查看/data目录的磁盘空间大小
[root@tomas121 ~]# df -hP|grep /data #查看/data目录的磁盘空间大小
/dev/mapper/centos_tomas121-data 481G 199G 282G 42% /data
参考:
http://blog.csdn.net/kjsayn/article/details/52996313
http://www.linuxidc.com/Linux/2016-06/132709.htm
http://jingyan.baidu.com/article/0f5fb099131f306d8234ea53.html
http://www.cnblogs.com/jenqz/p/4929871.html
http://www.cnblogs.com/kevingrace/p/5825963.html
http://www.cnblogs.com/kysnail/archive/2012/03/25/2417221.html