Resizing a virtual disk image

The Resize disk option only supports increasing the size of the virtual disk image file. It has no shrink function. The Proxmox Resize disk option only adjusts the size of the virtual disk image file. After any resizing, the partition must be adjusted from inside the VM. The safest way to resize partitions is to boot a Linux-based virtual machine with a partitioning ISO image, such as GParted (http://gparted.org/download.php), and then resize the partitions using the GParted graphical interface. It is also possible to perform an online partition resizing while the virtual machine is powered on. Resizing a virtual disk image file involves the following three steps:

  1. Resize virtual disk image file in Proxmox:
    • From GUI: Select the virtual disk, and then click on Resize disk.
    • From CLI: Run the following command:
                # qm resize <vm_id> <virtual_disk> +<size>G    
  1. Resize the partition of the virtual disk image file from inside the VM:
    • For Windows VMs: Resize the disk by going to Computer Management under Administrative Tools.
    • For Linux VMs with RAW partitions: Run the following command:
                # cfdisk <disk_image>
    • For Linux VMs with LVM partitions: Run the following command:
                # cfdisk </dev/XXX/disk_image>    
    • For Linux VMs with QCOW2 partitions: Run the following commands:
                # apt-get install nbd-client
# qemu-nbd --connect /dev/nbd0 <disk_image>
# cfdisk /dev/nbd0
# qemu-nbd -d /dev/nbd0
  1. Resize the filesystem in the partition of the virtual disk image file:
    • For a Linux client with LVM: Run the following commands:
                # pvscan  (find PV name)
# pvresize /dev/xxx (/dev/xxx found from pvscan)
# lvscan (find LVname)
# lvresize -L+<size>G /dev/xxx/lv_<disk>
    • To use 100% free space: Run the following commands:
                # lvresize -l +100%FREE /dev/xxx/lv_<disk>
# resize2fs /dev/xxx/lv_<disk> (resize filesystem)
Steps 2 and 3 are necessary only if online resizing is done without shutting down a VM. If GParted or another bootable partitioning medium is used, then only step 1 is needed before booting the VM with an ISO.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.202.54