LinuxCommandLibrary

create-image

Create a virtual machine image

TLDR

Create a CPIO archive from the current directory

$ create-image [[-o|--output]] [path/to/output.cpio]
copy

Display help
$ create-image [[-h|--help]]
copy

SYNOPSIS

create-image [-f fmt] [-o options] [-b backing_file] filename [size]

PARAMETERS

-f, --format=FMT
    Image format (e.g., raw, qcow2, vmdk)

-o, --option=KEY=VALUE
    Format-specific options (e.g., cluster_size=64K)

-b, --backing-file=FILE
    Base image for copy-on-write

-B, --backing-fmt=FMT
    Format of backing file

filename
    Path to output image file

size
    Size (e.g., 10G, 1024M); required unless prealloc

DESCRIPTION

The create-image command is not a core standard Linux utility but commonly refers to subcommands or scripts in virtualization tools like QEMU's qemu-img create or similar in other VM software for generating new disk image files.

These images serve as virtual hard drives for emulators, hypervisors (KVM, VirtualBox), or container storage. Users specify output file, size, and format to produce raw binary files, sparse qcow2 overlays, or VMware-compatible VMDK. Backing files enable efficient copy-on-write setups, saving space by referencing base images.

Typical workflow: create a base image, attach to VM for OS install, snapshot for variants. Requires loop devices or libvirt for mounting. Common in cloud image building (e.g., Fedora's image tools) and testing environments. Always pre-allocate space wisely to avoid host fragmentation; qcow2 is popular for its features like encryption and clustering.

Word count approx. 150; adapt for specific impl.

CAVEATS

Not standard; use qemu-img create equivalent. Fails if insufficient space or invalid format. Some formats unsupported on all platforms. Preallocation (--preallocation=metadata) can be slow on large images.

EXAMPLES

create-image -f qcow2 disk.qcow2 20G
create-image -f raw -o compat6=on disk.vmdk 10G
create-image -f qcow2 -b base.qcow2 overlay.qcow2

EXIT CODES

0: success; 1: general error; 2: invalid args; check man qemu-img for details.

HISTORY

Emerged with QEMU (2003) as qemu-img create; evolved for KVM/libvirt integration. Similar tools in Xen, VirtualBox. Linux image creation traces to floppy tools like mtools (1990s), now vital for cloud (OpenStack, AWS AMIs).

SEE ALSO

qemu-img(1), dd(1), losetup(8), virt-resize(1), genisoimage(1)

Copied to clipboard