Clone: Existing KVM Instance
Note:
When creating multiple clones from a single KVM instance, we recommend preparing the source configuration before cloning it. Preparing the source configuration lets you examine the configuration and remove unique parameters that would not apply to the clone configuration and cause the clone to possibly fail or not work correctly.For instructions on how to prepare a KVM instance for cloning or create a KVM clone, see these topics:
- Prepare KVM for Cloning: Using virt-sysprep
- Prepare KVM for Cloning: Manually
- Create a KVM Clone Using virt-clone Command
Note:
In addition to using the CLI to create KVM clones, you can use the Cockpit web console to clone KVM instances. For details, see Cloning VMs in Oracle Linux: Using the Cockpit Web Console.Prepare KVM for Cloning: Using virt-sysprep
virt-sysprep
) to prepare a source KVM disk configuration for cloning.
Note:
Thevirt-sysprep
tool helps you to prepare a KVM configuration for cloning by removing SSH host keys, persistent network configurations, and user accounts on the disk image. It also lets you add SSH keys, users, or logos. For more details about virt-sysprep
, see https://libguestfs.org/virt-sysprep.1.html.
- All important data on the source KVM is backed up.
Note that
virt-sysprep
changes the disk image in place without making a copy of it. To keep the configuration of the source KVM intact, create a clone. For details, see Create a KVM Clone Using virt-clone Command. - The system preparation tool (
virt-sysprep
) must installed on the host.yum install /usr/bin/virt-sysprep
- The source KVM must be shut down.
- The location of the source KVM disk image is required. Also, you must be the disk image owner and have disk write permissions.
Follow these steps to use the virt-sysprep
tool to prepare a source KVM disk image configuration for cloning.
Prepare KVM for Cloning: Manually
- All important data on the source KVM is backed up.
To keep the configuration of the source KVM intact, create a clone. For details, see Create a KVM Clone Using virt-clone Command
- The location of the source KVM disk image is required. Also, you must be the disk image owner and have disk write permissions.
- The source KVM must be shut down.
- Administrator privileges.
Follow these steps to manually prepare a source KVM configuration for cloning.
Create a KVM Clone Using virt-clone
Command
virt-clone
command.
- Root privileges.
- Source KVM is shut down.
- Sufficent disk space to store the cloned disk images.
- (Optional) Prepared source KVM configuration for cloning.
See Prepare KVM for Cloning: Using virt-sysprep or Create a KVM Clone Using virt-clone Command.
Steps
Follow these steps to clone an existing KVM instance: