LinuxCommandLibrary

virt-sysprep

Prepare VM images for cloning

TLDR

List available operations

$ virt-sysprep --list-operations
copy
Remove sensitive data
$ sudo virt-sysprep -a [path/to/image.qcow2]
copy
Dry run by domain name
$ sudo virt-sysprep -d [vm_name] -n
copy
Run specific operations
$ sudo virt-sysprep -d [vm_name] --operations [operation1,operation2]
copy
Set hostname and machine-id
$ sudo virt-sysprep -d [vm_name] --enable customizations --hostname [host_name] --operation machine-id
copy

SYNOPSIS

virt-sysprep [OPTIONS]

DESCRIPTION

virt-sysprep resets, unconfigures, or customizes a virtual machine image for cloning or deployment. It removes machine-specific data like SSH keys, logs, and persistent device names.
This prepares VM images for use as templates by removing identity information that should be unique per machine.

PARAMETERS

-a, --add IMAGE

Add disk image
-d, --domain VM
Specify VM by name
-n, --dry-run
Show what would be done without making changes
--operations OPS
Run only specified operations
--list-operations
List all supported operations
--hostname NAME
Set hostname
--enable FEATURE
Enable specific feature

CAVEATS

VM must be shut down. Root privileges typically required. Some operations may break the VM if used incorrectly. Always backup images before processing.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community