Centos7 根分区扩展

话不多说,见以下操作

1.查看现有磁盘
在这里插入图片描述

  1. 查看磁盘大小fdisk -l:
    在这里插入图片描述

  2. 对磁盘进行分区fdisk /dev/vda:

[root@host-172-22-22-10 ~]# fdisk /dev/vda
欢迎使用 fdisk (util-linux 2.23.2)。

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

命令(输入 m 获取帮助):m(输入 m 查看帮助)
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

命令(输入 m 获取帮助):n (输入 n 新增分区)
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p (输入 p 选择新增主分区并选择分区号、第一个扇区、最后一个扇区号(在此均用默认值))
分区号 (3,4,默认 3):
起始 扇区 (104857600-209715199,默认为 104857600):
将使用默认值 104857600
Last 扇区, +扇区 or +size{K,M,G} (104857600-209715199,默认为 209715199):
将使用默认值 209715199
分区 3 已设置为 Linux 类型,大小设为 50 GiB

命令(输入 m 获取帮助):w (输入 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)
正在同步磁盘。

因为设备或资源忙,w的命令没有正常执行所以执行partprobe
[root@host-172-22-22-10 ~]# partprobe

  1. 再查看磁盘情况,已经多了一个分区:
    [root@host-172-22-22-10 ~]# fdisk -l
    在这里插入图片描述

  2. 查看卷分组vgdisplay -v:
    [root@host-172-22-22-10 ~]# vgdisplay -v
    在这里插入图片描述

  3. 为之前新增的分区创建物理卷 pvcreate /dev/sda3:

[root@host-172-22-22-10 ~]# pvcreate /dev/vda3
Physical volume “/dev/vda3” successfully created.

  1. 查看结果 pvdisplay:
    [root@host-172-22-22-10 ~]# pvdisplay
    在这里插入图片描述

  2. 扩展卷分组 vgextend cl /dev/vda3:

    [root@host-172-22-22-10 ~]# vgextend cl /dev/vda3
    Volume group “cl” successfully extended

  3. 查看逻辑卷 lvdisplay:
    [root@host-172-22-22-10 ~]# lvextend -L +49G /dev/cl/root
    Size of logical volume cl/root changed from 45.12 GiB (11550 extents) to 94.12 GiB (24094 extents).
    Logical volume cl/root successfully resized.

  4. 扩展逻辑卷 lvextend -L +49G /dev/cl/root:

[root@host-172-22-22-10 ~]# lvextend -L +49G /dev/cl/root
Size of logical volume cl/root changed from 45.12 GiB (11550 extents) to 94.12 GiB (24094 extents).
Logical volume cl/root successfully resized.

  1. 扩大文件系统 xfs_growfs /dev/cl/root:
    [root@host-172-22-22-10 ~]# xfs_growfs /dev/cl/root

在这里插入图片描述

  1. 查看结果 df -Th:
    在这里插入图片描述
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值