QEMU image command
You can use the qemu-img command to manage disk images.
- This example creates a qcow2 image with a maximum size of
10 GB:
# qemu-img create -f qcow2 /var/lib/libvirt/images/disk1.img 10G Formatting '/var/lib/libvirt/images/disk1.img', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false
- This example displays attributes of a qcow2
image:
# qemu-img info /var/lib/libvirt/images/disk1.img image: /var/lib/libvirt/images/disk1.img file format: qcow2 virtual size: 10G (10737418240 bytes) disk size: 136K cluster_size: 65536
- This example increases the size of a qcow2
image:
# qemu-img resize /var/lib/libvirt/images/disk1.img 20G Image resized. # qemu-img info /var/lib/libvirt/images/disk1.img image: /var/lib/libvirt/images/disk1.img file format: qcow2 virtual size: 20G (21474836480 bytes) disk size: 140K cluster_size: 65536
- This example creates a RAW image with a maximum size of
10 GB:
# qemu-img create -f raw /var/lib/libvirt/images/disk1.img 10G Formatting '/var/lib/libvirt/images/disk1.img', fmt=raw size=10737418240
- This example displays attributes of a RAW image:
# qemu-img info /var/lib/libvirt/images/disk1.img image: /var/lib/libvirt/images/disk1.img file format: raw virtual size: 10G (10737418240 bytes) disk size: 0
- This example increases the size of a RAW image:
# qemu-img resize -f raw /var/lib/libvirt/images/disk1.img 20G Image resized. # qemu-img info /var/lib/libvirt/images/disk1.img image: /var/lib/libvirt/images/disk1.img file format: raw virtual size: 20G (21474836480 bytes) disk size: 0