Home / Linux Admin /

KVM Disk Image Management

Convert Disk Image Formats

  1. With qemu installed, this works. In this example, converting from a VDI VirtualBox format to Qcow2. Note that that is -O (capital O) not -0 (zero)

Mount Disk Image in Linux

This is might be specific to qcow2 image files.

DO NOT mount the disk image in read/write mode while the VM is running!

  1. Install libguestfs-tools
  2. Create a mount point:
  3. Mount it (replace device with anything to get a list of what devices are available):
  4. Unmount it when finished:
  5. resource

Resize Qcow2 Disk Image

  1. qemu-img resize diskImage.qcow2 +5G
  2. after that, launch the VM and resize partitions

Shrink Qcow2 Disk Image

  1. virt-sparsify bloatedDiskImage.ext outputShrunkDiskImage.ext
  2. Be sure to test the resulting image before deleting the original

this document last modified: May 15 2018 01:00

Home / Linux Admin /