Centos7增加磁盘空间LVM

增加磁盘空间必须要都为LVM格式。

1.增加磁盘空间

Centos7增加磁盘空间LVM-Mr.shi

2.使用fdisk /dev/sda 创建一个新的卷

[root@logs ~]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

命令(输入 m 获取帮助):

3.选择 n 增加一个新的卷设置为主分区

命令(输入 m 获取帮助):n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e):p

4.扇区大小全部直接回车默认为最大即可

Select (default e): p
已选择分区 4
起始 扇区 (167772160-178257919,默认为 167772160):
将使用默认值 167772160
Last 扇区, +扇区 or +size{K,M,G} (167772160-178257919,默认为 178257919):
将使用默认值 178257919
分区 4 已设置为 Linux 类型,大小设为 5 GiB

5.使用t 修改卷格式 快速代码为8e

Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”

6.使用w同步卷信息

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。

7.刷新分区表内容 partprobe

**8.vgextend centos /dev/sda4 #将物理卷"/dev/sdb4"加入卷组"centos" **

9.pvscan查看所有链接硬盘信息

10. lvextend -L +4.9G /dev/mapper/centos-root把空间加入指定分区

[root@logs ~]# lvextend -L +4G /dev/mapper/centos-root
Size of logical volume centos/root changed from 76.99 GiB (19710 extents) to 80.99 GiB (20734 extents).
Logical volume centos/root successfully resized.

** 11.同步指定分区信息**

[root@logs ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=12, agsize=1768960 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=20183040, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3455, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 20183040 to 21468160

测试一下 df -h 就可以看到。

猜你喜欢

转载自blog.csdn.net/qq_42542371/article/details/81208007