IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    QEMU 硬盘扩容

    泠泫凝发表于 2024-11-08 07:30:10
    love 0

    扩容PVE虚拟机硬盘及系统内操作,可能适用于其他虚拟化平台。

    首先在PVE虚拟机-硬件-选中硬盘-硬盘操作-调整大小,然后在新跳出的对话框里面输入你需要扩大的大小。注意是需要扩大多少不是扩大到多少,PVE允许在虚拟机运行时扩大磁盘容量。

    我这里以ubuntu 20.04为例;扩大的磁盘为系统盘;/dev/sda2挂载为/(root),分区类型为Ext4。

    PVE界面上扩容好后使用fdisk -l查看当前磁盘情况:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    GPT PMBR size mismatch (2147483647 != 8589934591) will be corrected by write.
    The backup GPT table is not on the end of the device. This problem will be corrected by write.
    Disk /dev/sda: 4 TiB, 4398046511104 bytes, 8589934592 sectors
    Disk model: QEMU HARDDISK
    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: gpt
    Disk identifier: C21E9F23-xxxx-xxxx-xxxx-EA78EC110E55

    Device Start End Sectors Size Type
    /dev/sda1 2048 2203647 2201600 1.1G EFI System
    /dev/sda2 2203648 2147481599 2145277952 1023G Linux filesystem

    会发现提示分区表磁盘大小不匹配,执行resize2fs也会提示没有可用空间:

    1
    2
    3
    root@xxxx:~# resize2fs /dev/sda2
    resize2fs 1.45.5 (07-Jan-2020)
    The filesystem is already 268159744 (4k) blocks long. Nothing to do!

    此时执行parted -l,会提示有分区表错误,是否修复,输入fix即可。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    root@node3:~# parted -l
    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 6442450944 blocks) or continue
    with the current setting?
    Fix/Ignore? fix
    Model: QEMU QEMU HARDDISK (scsi)
    Disk /dev/sda: 4398GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:

    Number Start End Size File system Name Flags
    1 1049kB 1128MB 1127MB fat32 boot, esp
    2 1128MB 1100GB 1098GB


沪ICP备19023445号-2号
友情链接