轉載自:http://blog.itpub.net/25469263/viewspace-2662215/
centos7中使用vg方式擴充root分區
1.創建pv
fdisk /dev/sdb
輸入n增加分區
輸入p類型設置為:主分區
輸入1分區編號設置為1
回車 為默認大小
回車 為默認 大小
輸入w退出
2.把pv加入vg中,相當於擴充vg的大小
擴展vg,使用vgextend命令
|
1
2
3
|
[root@localhost ~]
# vgextend centos /dev/sdb1
Volume group
"centos"
successfully extended
vgextend名字命令接的vg的名字,后面是磁盤的位置
|
3.我們成功把vg卷擴展了,在用vgs查看一下
|
1
2
3
4
5
6
7
|
[root@localhost ~]
# vgs
VG
#PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 39.50g 20.04g
[root@localhost ~]
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 17.47g
swap centos -wi-ao---- 2.00g <br><br>雖然我們把vg擴展了,但是lv還沒有擴展
|
4.擴展lv,使用lvextend命令
|
1
2
3
|
[root@localhost ~]
# lvextend -L +20G /dev/mapper/centos-root
|
查看lv大小
|
1
2
3
4
|
[root@localhost ~]
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 37.47g
swap centos -wi-ao---- 2.00g
|
查看df -h中變化沒有
|
1
2
3
4
5
6
7
8
9
|
[root@localhost ~]
# df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/centos-root
18G 1.1G 17G 6% /
devtmpfs 479M 0 479M 0%
/dev
tmpfs 489M 0 489M 0%
/dev/shm
tmpfs 489M 6.7M 483M 2%
/run
tmpfs 489M 0 489M 0%
/sys/fs/cgroup
/dev/sda1
497M 125M 373M 25%
/boot
tmpfs 98M 0 98M 0%
/run/user/0
<br><br>沒有變化。
|
那么我們要使用[root@localhost ~]# xfs_growfs /dev/mapper/centos-root 命令使系統重新讀取大小
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@localhost ~]
# xfs_growfs /dev/mapper/centos-root
meta-data=
/dev/mapper/centos-root
isize=256 agcount=4, agsize=1144832 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=4579328, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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 4579328 to 9822208
|
再使用df -h查看
|
1
2
3
4
5
6
7
8
9
|
[root@localhost ~]
# df -h
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/centos-root
38G 1.1G 37G 3% /
devtmpfs 479M 0 479M 0%
/dev
tmpfs 489M 0 489M 0%
/dev/shm
tmpfs 489M 6.7M 483M 2%
/run
tmpfs 489M 0 489M 0%
/sys/fs/cgroup
/dev/sda1
497M 125M 373M 25%
/boot
tmpfs 98M 0 98M 0%
/run/user/0
|
到這里我們就成功擴展了。
備注:我們可以自行生產vg組以及在新的vg中生成lv
vgcreate 創建新的vg組
lvcreate 在新的vg中創建新的lv,但是要指定對vg名字
vgreduce 把pv從vg中移除,若vg中只有一個pv則直接使用vgremove
