kvm虚拟机centos8磁盘扩容

32 篇文章 2 订阅

通过PVE搭建虚拟机,系统盘只有30G,发现使用的时候已经不足,需要进行扩容,

虚拟机关机状态,在PVE增加磁盘大小之后,虚机开机之后,还需要在虚拟机里面进行扩容操作

 

 开机检查磁盘大小

lsblk

[root@localhost ~]# fdisk -l
Disk /dev/vda: 132 GiB, 141733920768 bytes, 276824064 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x79cee493

Device     Boot   Start      End  Sectors Size Id Type
/dev/vda1  *       2048  2099199  2097152   1G 83 Linux
/dev/vda2       2099200 67108863 65009664  31G 8e Linux LVM


Disk /dev/mapper/cs-root: 29 GiB, 31079792640 bytes, 60702720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cs-swap: 2.1 GiB, 2202009600 bytes, 4300800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

开始扩容

1.创建一个新的分区

依次输入以下指令

n    [添加分区]
p    [主分区]
3    [分区号,回车默认也是3]
默认    [直接回车]
默认    [直接回车]
w    [保存分区]
[root@localhost ~]# fdisk /dev/vda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 
First sector (67108864-276824063, default 67108864): 
Last sector, +sectors or +size{K,M,G,T,P} (67108864-276824063, default 276824063): 

Created a new partition 3 of type 'Linux' and of size 100 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

 可以看到新的分区已经出现了

 2.将vda3分区初始化为物理卷

partprobe
pvcreate /dev/vda3

 3.查看跟分区所在的卷组信息

vgdisplay
# vgs

 

 4.扩容cs卷组

vgextend cs /dev/vda3

 5.扩容文件系统

lvextend -l +100%FREE /dev/mapper/cs-root

[root@localhost ~]# pvdisplay 
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               cs
  PV Size               <31.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              7935
  Free PE               0
  Allocated PE          7935
  PV UUID               Oaojfu-XAyd-ick0-U7nZ-2YFt-VBUk-FGgStv
   
  --- Physical volume ---
  PV Name               /dev/vda3
  VG Name               cs
  PV Size               100.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              25599
  Free PE               0
  Allocated PE          25599
  PV UUID               597ofc-wiTD-8lM3-h2JL-fXlR-alFZ-f12G2n

6.同步文件系统

xfs_growfs /

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值