问小白 wenxiaobai
资讯
历史
科技
环境与自然
成长
游戏
财经
文学与艺术
美食
健康
家居
文化
情感
汽车
三农
军事
旅行
运动
教育
生活
星座命理

PVE环境中调整虚拟机磁盘大小的完整指南

创作时间:
作者:
@小白创作中心

PVE环境中调整虚拟机磁盘大小的完整指南

引用
CSDN
1.
https://blog.csdn.net/hg_zhh/article/details/140734289

在Proxmox VE (PVE)环境中,有时需要调整虚拟机的磁盘大小。本文将详细介绍如何在PVE 8.2.2版本中,将一个CentOS 7.9.2009-minimal系统的虚拟机磁盘增加20GB。系统在安装时采用的是默认分区方式,不同分区方式下的操作步骤可能有所不同。

第1步:关闭虚拟机

首先需要将虚拟机关机,确保在调整磁盘大小的过程中不会影响数据安全。

第2步:在PVE管理平台调整虚拟机磁盘大小

在PVE管理界面中,找到目标虚拟机,选择磁盘管理选项,增加20GB的磁盘空间。

第3步:启动虚拟机

磁盘大小调整完成后,启动虚拟机。

第4步:查看磁盘信息

进入虚拟机系统后,使用parted工具查看磁盘分区信息。此时会发现磁盘总大小已经增加,但分区大小并未改变。

第5步:调整分区大小

使用parted工具调整分区大小。本例中将剩余空间添加到sda3分区。根据实际情况,可以调整其他分区。

[root@localhost ~]# parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 41943040 blocks) or continue with the current setting? 
Fix/Ignore? Fix                                                           
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot
 2      211MB   1285MB  1074MB  xfs
 3      1285MB  42.9GB  41.7GB                                     lvm
(parted) resizepart 3 100%
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot
 2      211MB   1285MB  1074MB  xfs
 3      1285MB  64.4GB  63.1GB                                     lvm
(parted) quit                                                             
Information: You may need to update /etc/fstab.
[root@localhost ~]#  

如果遇到以下提示,直接输入Fix进行修复:

Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel?
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 41943040 blocks) or continue with the current setting? 
Fix/Ignore? Fix  

第6步:更新物理卷和逻辑卷大小

使用以下命令更新物理卷和逻辑卷的大小:

[root@localhost ~]# pvresize /dev/sda3
[root@localhost ~]# lvresize --extents +100%FREE --resizefs /dev/mapper/centos-root
# 此处的参数可以根据实际需要调整

第7步:验证调整结果

使用相关命令验证磁盘大小是否已成功调整。通过查看分区信息,确认磁盘空间已经增加。

注意:分区操作存在风险,操作前请确保已备份重要数据。

本文介绍了在PVE环境中调整虚拟机磁盘大小的具体步骤,希望对您有所帮助。本文原文来自CSDN。

© 2023 北京元石科技有限公司 ◎ 京公网安备 11010802042949号