wemu-img

Creates, inspects and converts disk images, with qemu-img's commands and options.

wemu-img is Warm64's qemu-img: the same commands and options, for the raw images Warm64 boots from.

wemu-img create -f raw disk.img 8G
wemu-img info disk.img
wemu-img resize disk.img +2G

Syntax

wemu-img COMMAND [options] ...
  • Options take --name=value or --name value, and short options (-f raw) where the command lists them.
  • An argument like -32M that starts with a digit is a value, not an option, so resize disk.img -32M works.
  • wemu-img --help prints the usage; wemu-img --version prints wemu-img version 9.0.0 (warm64 0.1.0).
  • Errors print wemu-img: MESSAGE and exit with status 1.

Formats

Warm64 boots raw images. -f and -O accept raw; any other format is refused with Unknown file format 'X' (this machine opens raw images).

A qcow2 file is recognised and refused with a pointer to QEMU's tool, which can convert it:

qemu-img convert -O raw disk.qcow2 disk.img

Note Only qcow2 is recognised. Any other file, including vmdk, vhd and vdi images, is treated as raw bytes. Convert those with qemu-img too.

Commands

create

wemu-img create [-f raw] [-o size=SIZE] FILE [SIZE]

Creates a sparse raw image (or truncates an existing file to SIZE). SIZE takes k, M, G and T; a bare number is bytes. -b (a backing file) is refused: a backing file needs a format with backing files (raw has none); -F is accepted with it.

wemu-img create -f raw disk.img 8G
# Formatting 'disk.img', fmt=raw size=8589934592

info

wemu-img info [--output=human|json] FILE

Prints the image's format, virtual size and space used on disk.

wemu-img info --output=json disk.img
{
    "virtual-size": 8589934592,
    "filename": "disk.img",
    "format": "raw",
    "actual-size": 0,
    "dirty-flag": false
}

resize

wemu-img resize [--shrink] FILE [+|-]SIZE

Grows the image to SIZE, or by +SIZE. Shrinking needs --shrink; without it the command says Use the --shrink option to perform a shrink operation.

convert

wemu-img convert [-f raw] [-O raw] [-S SIZE] [-p] SOURCE DESTINATION

Copies an image, leaving runs of zeros of at least -S bytes (default 4096) as holes, so the copy stays sparse. -S 0 writes every byte. The destination is always created or truncated.

Note Unlike qemu-img, convert takes one source only.

compare

wemu-img compare [-f raw] [-F raw] [-s] [-q] A B

Prints Images are identical. and exits 0, or Content mismatch at offset N! and exits 1. Images of different sizes count as identical when the longer one's extra bytes are all zero, unless -s (strict) is given, which prints Strict mode: Image size mismatch!. -f is the first image's format and -F the second's; -q prints nothing, leaving only the exit status. An error exits 1 as well (qemu-img uses 2).

map

wemu-img map [-f raw] [--start-offset=N] [--max-length=N] [--output=human|json] FILE

Lists the ranges that hold data, in 64 KiB units. A range counts as data when any of its bytes is non-zero.

measure

wemu-img measure [-f raw] [-O raw] [--output=human|json] (--size SIZE | FILE)

Prints the space a raw image needs: required size and fully allocated size.

dd

wemu-img dd [-f raw] [-O raw] [bs=512] [count=N] [skip=N] if=INPUT of=OUTPUT

Copies count blocks of bs bytes, skipping the first skip blocks of the input. The output is sparse.

bench

wemu-img bench [-f raw] [-c COUNT] [-d DEPTH] [-s SIZE] [-o OFFSET] [-S STEP] [-w] [--pattern=N] FILE

Times COUNT (default 75000) reads of SIZE bytes (default 4096), or writes with -w. Requests run one after another: -d (default 64) is printed in the summary line but doesn't run requests in parallel.

Warning bench -w overwrites the image with the pattern byte.

check, commit, rebase, snapshot, amend, bitmap

Raw images have no metadata to check, no backing files and no internal snapshots, so these report what qemu-img reports for a raw image: check exits with status 63, the others with 1.

See also