linux 分区lvm类型,CentOS 通过 LVM 扩充MBR类型分区

在虚拟机中对磁盘进行扩容后,原系统分区的大小并不会改变,此时,需要对系统分区进行扩容操作。

1、查看所有磁盘及分区

blkid

此处以/dev/sda为例,根据系统环境不同,得到的结果也不相同。

2、创建新分区fdisk /dev/sda ## /dev/sda为通过fdisk -l 查看到的物理磁盘(第一行)

Welcome to fdisk

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Command (m for help): n ## n为创建一个新的分区

Partition type: ## 这里需要选择时创建主分区还是扩展分区,都可以,这里直接选了主分区

p primary (2 primary, 0 extended, 2 free)

e extended

Select (default p): p ## 选择创建一个主分区,主分区只能有4个,编号为1-4,下面的全部直接回车就好了,会自动将剩余所用空间都创建

Partition number (3,4, default 3):

First sector (104857600-209715199, default 104857600):

Using default value 104857600

Last sector, +sectors or +size{K,M,G} (104857600-209715199, default 209715199):

Using default value 209715199

Partition 3 of type Linux and of size 50 GiB is set

Command (m for help): t ## t为修改分区类型

Partition number (1-3, default 3): 3 ## 刚才创建的分区编号为3

Hex code (type L to list all codes): 8e ## 8e就是 lvm格式的分区

Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): 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: Device or resource busy.

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)

Syncing disks.

partprobe

3、扩容分区pvcreate /dev/sda3 ## 创建物理卷

pvdisplay ## 查看物理卷

vgdisplay ## 查看卷组 VG Name 为 centos

vgextend centos /dev/sda3 ## 将物理卷加入到卷组

vgdisplay ## 加入后,再次查看卷组

lvdisplay ## 查看逻辑卷,逻辑卷名称:LV Path /dev/centos/root

lvextend -l +100%FREE /dev/centos/root ## 将剩余百分百空间都添加到逻辑卷中

xfs_growfs /dev/centos/root ## xfs 在线扩容分区

df -h ## 查看扩容结果

以上操作完成即扩容完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值