SysTutorials

How to Clone Xen DomU Virtual Machines

· updated April 12, 2026

Xen remains in active production use—particularly in cloud infrastructure like AWS EC2 and Citrix Hypervisor—though KVM has become the standard hypervisor for most Linux distributions. If you’re managing legacy Xen deployments, this guide covers the essential steps for cloning VBD-based DomU instances.

Prerequisites

Before starting, ensure:

Step 1: Copy the VM Files

Copy the entire VM directory as root:

cp -rv /home/xen/vm-f11-sample /home/xen/vm-10.0.0.213

Critical: Verify the source VM is shut down before copying. If it’s running, stop it first:

xl shutdown vm0

For large disks, monitor the copy progress and verify disk space:

df -h /home/xen/
du -sh /home/xen/vm-10.0.0.213/

File ownership will be root, which is appropriate for VM storage directories.

Step 2: Update Configuration Files

Navigate to the new VM directory and rename the configuration file:

cd /home/xen/vm-10.0.0.213
mv vm0-f11.run vm.run

Edit the configuration file with your preferred editor:

vim vm.run

Update the following fields:

name="10.0.0.213"
memory=1024
disk = ['file:/home/xen/vm-10.0.0.213/vmdisk0,xvda,w']
vif = ['bridge=eth0']
bootloader = "/usr/bin/pygrub"
vcpus=2
on_reboot = 'restart'
on_crash = 'restart'

Key changes:

If cloning multiple VMs, consider parameterizing the disk path and memory allocation for consistency.

Step 3: Boot and Configure the New VM

Create and start the new domain:

xl create /home/xen/vm-10.0.0.213/vm.run

Connect to the console:

xl console 10.0.0.213

Press Enter to see the login prompt. Log in with your credentials.

Step 4: Update Network Configuration

For RHEL-based systems, edit the network interface configuration:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Update the IP address:

IPADDR=10.0.0.213
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
ONBOOT=yes

Important: Comment out or remove the HWADDR line if using Xen bridge networking. This prevents MAC address conflicts:

# HWADDR=00:16:3e:xx:xx:xx

Restart the network interface:

ifdown eth0
ifup eth0

Verify connectivity:

ip addr show eth0
ping -c 4 10.0.0.1

Exit the console with Ctrl + ].

Step 5: Post-Configuration

Reset the VM from Dom0 to apply any remaining system changes:

xl reset 10.0.0.213

Reconnect to verify the system boots cleanly:

xl console 10.0.0.213

Troubleshooting

VM fails to start: Check the configuration file syntax and verify the disk path is correct.

xl create -c /home/xen/vm-10.0.0.213/vm.run

The -c flag attaches the console immediately, showing boot errors.

Network connectivity issues: Ensure the bridge interface exists on Dom0:

brctl show

Disk I/O errors: If the source disk was corrupted or the copy was incomplete, verify the target disk:

ls -lh /home/xen/vm-10.0.0.213/vmdisk0

Automation Considerations

For repeated cloning, consider writing a shell script that:

This reduces manual steps and human error, especially when managing multiple VM deployments.

← All posts