e42.uk Circle Device

 

Quick Reference

qemu-img create

qemu-img create quick start

Making a new disk image

qemu-img create -f raw root.img.raw 64G
qemu-img create -f qcow2 root.img.qcow2 64G

Making a new image with a backing image

Of course the format of the file taking the backing image must support copy on write:

qemu-img create -f raw back.img.raw 64G
qemu-img create -F raw -b back.img.raw -f qcow2 root.img.qcow2

Make an image from an existing image

This is effectively a copy from the current 'snapshot':

qemu-img convert -O qcow2 -f qcow2 root.img.qcow2 root_converted.img.qcow2

Input Image Information:

# qemu-img info root.img.qcow2
image: root.img.qcow2
file format: qcow2
virtual size: 64 GiB (68719476736 bytes)
disk size: 35 GiB
cluster_size: 65536
backing file: back.img.raw
backing file format: raw
Snapshot list:
ID        TAG               VM SIZE                DATE     VM CLOCK     ICOUNT
1         on20240122            0 B 2025-01-22 10:13:55 00:00:00.000          0
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

Information after convert command complete:

# qemu-img info root_converted.img.qcow2
image: root_converted.img.qcow2
file format: qcow2
virtual size: 64 GiB (68719476736 bytes)
disk size: 45.5 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

Notice there is no snapshot in the new file.

Extend the disk

qemu-img resize root_converted.img.qcow2 128G

Using Snapshots

Quick Links: Techie Stuff | General | Personal | Quick Reference