1,分区
[root@localhost ~]# fdisk /dev/vdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):n
分区号 (1-128,默认 1):
第一个扇区 (34-209715166,默认 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-209715166,默认 209715166):
已创建分区 1
命令(输入 m 获取帮助):p
磁盘 /dev/vdb:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: 84026D15-EEB3-4318-87DA-2990453F7847
# Start End Size Type Name
1 2048 209715166 100G Linux filesyste
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
2,把新的磁盘加入到centos vg组(扩容vg)
[root@localhost ~]# vgextend centos /dev/vdb1
Volume group "centos" successfully extended
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 118.99g <100.00g
3,扩容分区和扩容文件系统
[root@localhost ~]# lvextend -L 116G /dev/centos/root
Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to 116.00 GiB (29696 extents).
Logical volume centos/root successfully resized.
[root@localhost ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4455424, 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 4455424 to 30408704
4,查看
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 116G 1.1G 115G 1% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 145M 870M 15% /boot
tmpfs 379M 0 379M 0% /run/user/0
5,命令:
创建vg
[root@localhost ~]# vgcreate systemvg /dev/vdb1
Physical volume "/dev/vdb1" successfully created.
Volume group "systemvg" successfully created
删除vg
[root@localhost ~]# vgremove systemvg
Volume group "systemvg" successfully removed