21.12. virt-customize: Customizing Virtual Machine Settings
virt-customizecommand-line tool can be used to customize a virtual machine. For example, by installing packages and editing configuration files.
virt-customize, the guest virtual machine must be offline, so you must shut it down before running the commands. Note that
virt-customizemodifies the guest or disk image in place without making a copy of it. If you want to preserve the existing contents of the guest virtual machine, you must snapshot, copy or clone the disk first. For more information on copying and cloning disks, see libguestfs.org.
virt-customizeon live virtual machines, or concurrently with other disk editing tools can cause disk corruption. The virtual machine must be shut down before using this command. In addition, disk images should not be edited concurrently.
It is recommended that you do not run
virt-customize, run one of the following commands:
yum install /usr/bin/virt-customize
yum install libguestfs-tools-c
The following command options are available to use with
|--help|| Displays a brief help entry about a particular command or about the || |
|-a [file] or --add [file]|| Adds the specified file, which should be a disk image from a guest virtual machine. The format of the disk image is auto-detected. To override this and force a particular format, use the || |
|-a [URI] or --add [URI]||Adds a remote disk. The URI format is compatible with guestfish. For more information, see Section 21.4.2, “Adding Files with guestfish”.|| |
|-c [URI] or --connect [URI]|| Connects to the given URI, if using libvirt. If omitted, then it connects via the KVM hypervisor. If you specify guest block devices directly (|| |
|-d [guest] or --domain [guest]||Adds all the disks from the specified guest virtual machine. Domain UUIDs can be used instead of domain names.|| |
|-n or --dry-run||Performs a read-only "dry run" customize operation on the guest virtual machine. This runs the customize operation, but throws away any changes to the disk at the end.|| |
| --format [|| The default for the -a option is to auto-detect the format of the disk image. Using this forces the disk format for -a options that follow on the command line. Using || |
|-m [MB] or --memsize [MB]|| Changes the amount of memory allocated to || |
|--network or --no-network|| Enables or disables network access from the guest during installation. The default is enabled. Use || |
|-q or --quiet||Prevents the printing of log messages.|| |
|-smp [N]|| Enables N virtual CPUs that can be used by || |
|-v or --verbose||Enables verbose messages for debugging purposes.|| |
|-V or --version|| Displays the || |
|-x||Enables tracing of libguestfs API calls.|| |
virt-customizecommand uses customization options to configure how the guest is customized. The following provides information about the
--selinux-relabelcustomization option relabels files in the guest so that they have the correct SELinux label. This option tries to relabel files immediately. If unsuccessful,
/.autorelabelis activated on the image. This schedules the relabel operation for the next time the image boots.
This option should only be used for guests that support SELinux.
The following example installs the GIMP and Inkscape packages on the guest and and ensures that the SELinux labels will be correct the next time the guest boots.
Example 21.1. Using
virt-customize to install packages on a guest
virt-customize -a disk.img --install gimp,inkscape --selinux-relabel
For more information, including customization options, see libguestfs.org.