Overview
Modifying a cloud image offline — before uploading — allows you to install packages, configure software, inject files, and set system parameters without needing to launch an instance. This approach produces consistent, repeatable golden images for deployment. All modifications are performed on a copy of the image using libguestfs tools.Prerequisites
- A Linux workstation or build server with
libguestfs-toolsinstalled - A base cloud image in QCOW2 or RAW format (see Get Cloud Images)
- Root or
sudoaccess on the build host - Sufficient disk space: at least 3x the image size for safe modification
Tools Reference
| Tool | Purpose | Best For |
|---|---|---|
| virt-customize | Apply changes to an image non-interactively | Installing packages, running scripts, injecting files |
| guestfish | Interactive filesystem shell for an image | Manual file edits, inspecting content, complex changes |
| guestmount | Mount an image as a local directory | Interactive editing with standard filesystem tools |
| virt-sysprep | Reset and generalize an image for distribution | Removing machine-specific data before capturing |
Modify with virt-customize
virt-customize applies changes to an image from the command line without mounting it.
It is the fastest method for automatable, scripted modifications.
Install packages
Install software into the image using the native package manager:The
Install packages with virt-customize
--update flag runs a full package upgrade before installing the specified packages.Run a configuration script
Execute a shell script inside the image to perform complex configuration:
Run a script inside the image
Modify with guestfish
guestfish provides an interactive shell for directly editing files inside an image.
Use it for one-off edits, configuration file changes, or inspecting image contents.
Open the image in guestfish
Open image in interactive mode
><fs> prompt, run:Mount the root filesystem
Edit a configuration file
Use the Or write content directly with
edit command to open a file in your default editor:Edit a file inside the image
write:Write content to a file
Mount with guestmount
guestmount mounts the image filesystem as a local directory, enabling standard
filesystem tools (cp, vim, chmod) to operate on image contents.
Make modifications
The image contents are accessible as a regular directory:
Edit a file in the mounted image
Generalize with virt-sysprep
Before distributing or uploading an image as a golden template, usevirt-sysprep to
remove machine-specific identifiers. This ensures each launched instance is treated as
a fresh system rather than a clone of the build host.
Generalize the image for distribution
virt-sysprep removes:
- Machine ID (
/etc/machine-id) - Shell history files
- Temporary files and package caches
- Log files
- NetworkManager connection caches
Next Steps
Image Requirements
Verify your modified image meets all Xloud Compute compatibility requirements.
Convert Formats
Convert VMDK, VHD, or RAW images to QCOW2 after modification.
Upload an Image
Upload the customized image to the Xloud Image Service.
Image Properties
Tag uploaded images with OS metadata and hardware requirements.