KVM把新添加的磁盘扩容到根目录

1、对新增的磁盘进行分区(注:可省略)

PS:使用fdisk或gdisk(大于2T时使用)对新增磁盘进行分区。

[root@kvm-clinet ~]# fdisk/dev/sdb

Welcome to fdisk (util‐linux 2.23.2).4

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

Be careful before using the write command.

Command (m for help): n

All primary partitions are in use

Adding logical partition 1

First sector (26654720‐41943039, default 26654720):  <‐‐‐  直接回车,使用默认起始柱面

Using default value 26654720

Last sector, +sectors or +size{K,M,G} (26654720‐41943039, default 41943039): <‐‐‐  直接回车,使用默认结束柱面,用完所有空间

Using default value 41943039

Partition 6 of type Linux and of size 7.3 GiB is set

Command (m for help): t  <‐‐‐‐  修改分区类型标记

Partition number (1‐6, default 1): <‐‐‐  直接回车,修改刚刚划分的分区

Hex code (type L to list all codes): 8e <‐‐‐‐8e  代表把类型修改为  Linux LVM

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

Command (m for help): w<‐‐‐‐  保存分区设定

[root@kvm-clinet ~]# partprobe

[root@kvm-clinet ~]# ls ‐l /dev/sdb1

brw‐rw‐‐‐‐. 1 root disk 8, 6 Jan 19 16:05 /dev/sdb1

2、确认根目录的卷名和卷组

[root@kvm-clinet ~]# df -hT

[root@kvm-clinet ~]# lvdisplay <‐‐‐‐查看现逻辑卷

3、扩充卷组和逻辑卷

[root@kvm-clinet ~]# pvcreate /dev/sdb1  <------将物理磁盘设备或物理磁盘分区初始化为物理卷

File descriptor 3 (pipe:[54618]) leaked on pvcreate invocation. Parent PID 1704: ‐bash

Physical volume "/dev/sdb1" successfully created

[root@kvm-clinet ~]#  vgextend centos /dev/sdb1 <------将新的pv添加到指定郑组centos中

Volume group “centos” sucessfully extended

[root@kvm-clinet ~]# vgdisplay  <----查看扩充后VG大小

[root@kvm-clinet ~]# lvextend -L +10G /dev/centos/root  <-----拉伸逻辑卷

[root@kvm-clinet ~]# lvdisplay <----查看扩充后LV大小

[root@kvm-clinet ~]# resize2fs /dev/centos/root <---刷新文件系统的容量信息,注意:如果文件系统是 xfs ,那么应该执行 xfs_growfs /dev/centos/root

[root@kvm-clinet ~]# df ‐hT  <---确认是否成功

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码哝小鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值