[admin@localhost ~]$ sudo fdisk -l
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x0005871c
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 125829119 61864960 8e Linux LVM
/dev/sda3 125829120 419430399 146800640 8e Linux LVM
Disk /dev/mapper/centos-root: 38.2 GB, 38235275264 bytes, 74678272 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-swap: 6442 MB, 6442450944 bytes, 12582912 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-home: 18.7 GB, 18668847104 bytes, 36462592 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
6、扩展vg
创建PV
[admin@localhost ~]$ sudo pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
使用vgs查看
[admin@localhost ~]$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- <59.00g 0
7、把sda3加入到LVM组中
[admin@localhost ~]$ sudo vgextend centos /dev/sda3
Volume group "centos" successfully extended
注意:centos 是vg组名称,请根据具体情况填写
[admin@localhost ~]$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 3 0 wz--n- 198.99g <140.00g
8、扩展lv
我们把新扩展的100G全部添加到centos-root中
[admin@localhost ~]$ sudo lvextend /dev/mapper/centos-root /dev/sda3
Size of logical volume centos/root changed from <35.61 GiB (9116 extents) to <175.61 GiB (44955 extents).
Logical volume centos/root successfully resized.
使用lvs可以看到 centos-root 已经是140G了,但是…请继续往下看
[admin@localhost ~]$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- <17.39g
root centos -wi-ao---- <175.61g
swap centos -wi-ao---- 6.00g
使用df -kh查看,空间并没有变化,look down…
[admin@localhost ~]$ df -khl
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 1.6G 35G 5% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.9M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 189M 826M 19% /boot
/dev/mapper/centos-home 18G 33M 18G 1% /home
tmpfs 783M 0 783M 0% /run/user/1001
9、xfs在线扩容
[admin@localhost ~]$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root xfs 37320904 1616800 35704104 5% /
devtmpfs devtmpfs 3992828 0 3992828 0% /dev
tmpfs tmpfs 4004744 0 4004744 0% /dev/shm
tmpfs tmpfs 4004744 9036 3995708 1% /run
tmpfs tmpfs 4004744 0 4004744 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 192612 845724 19% /boot
/dev/mapper/centos-home xfs 18221056 33020 18188036 1% /home
tmpfs tmpfs 800952 0 800952 0% /run/user/1001
[admin@localhost ~]$ sudo xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=2333696 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=9334784, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=4558, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 9334784 to 46033920
10、再次确认df状态, 添加的100G空间已经有效
[admin@localhost ~]$ df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 176G 1.6G 175G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.9M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 189M 826M 19% /boot
/dev/mapper/centos-home 18G 33M 18G 1% /home
tmpfs 783M 0 783M 0% /run/user/1001
手机扫一扫
移动阅读更方便
你可能感兴趣的文章