How can I move a xen LVM based virtual machine from one server to another?

For those running servers with no back-end SAN, the following instructions detail the steps necessary to move an LVM-based virtual machine to a new physical host.

There may be more elegant ways to achieve this, but this is fine.

Environment Ok, so let’s set the scene:

•vmhost is a RHEL 5 server running several virtual machines using the Xen virtualization technology. Each virtual machine is allocated a 60 GB logical volume within an LVM volume group. One of these virtual machines, “win2k3vm”, needs to be moved to a new server.

•new-vmhost is almost identical to vmhost, but has updated hardware and more memory. This is the server that “win2k3vm” will be moved to. Migrate the Virtual Machine 1. Create a snapshot of virtual machine LVM volume. This can be run on a live virtual machine, but it is probably safer to perform a graceful shutdown of your virtual machine first.

[root@vmhost]# lvcreate -s -L 300m -n win2k3vm-snap VolGroup01

2. Export the snapshot of the guest VM to a file that can be moved between physical servers.

[root@vmhost]# dd if=/dev/VolGroup01/win2k3vm-snap of=/mnt/temp/win2k3vm.img bs=4096

3. Remove the snapshot LVM volume. [root@vmhost]# lvremove /dev/VolGroup01/win2k3vm-snap

4. Copy the file to the new VM host. Make sure you have sufficient free drive space. [root@vmhost]# scp /mnt/temp/win2k3vm.img user@new-vmhost:/mnt/temp/

5. On the new VM host, create an LVM volume that is at least as big as the guest VM file.

[root@new-vmhost]# lvcreate -n win2k3vm -L 60G VMGroup

6. Transfer the guest VM file to the new LVM volume.

[root@new-vmhost]# dd if=win2k3vm.img of=/dev/VMGroup/win2k3vm bs=4096

7. Copy the VM config file from the old VM host to the new VM host server.

[root@vmhost]# scp /etc/xen/win2k3vm user@new-vmhost:

8. Copy the file to the appropriate directory.

[usr@new-vmhost]$ sudo mv ~/win2k3vm /etc/xen/ Summary of Commands

[root@vmhost]# lvcreate -s -L 300m -n win2k3vm-snap VolGroup01

[root@vmhost]# dd if=/dev/VolGroup01/win2k3vm-snap of=/mnt/temp/win2k3vm.img bs=4096

[root@vmhost]# lvremove /dev/VolGroup01/win2k3vm-snap

[root@vmhost]# scp /mnt/temp/win2k3vm.img user@new-vmhost:/mnt/temp/

[root@new-vmhost]# lvcreate -n win2k3vm -L 60G VMGroup

[root@new-vmhost]# dd if=win2k3vm.img of=/dev/VMGroup/win2k3vm bs=4096

[root@vmhost]# scp /etc/xen/win2k3vm user@new-vmhost: [usr@new-vmhost]$ sudo mv ~/win2k3vm /etc/xen/

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Zombie Process Slayer - Script to kill defunct processes

Here is a small script that you can use to show you which processes are zombies and which user is...

How can i cancel my dedicated server?

How Do I Cancel My Dedicated Server & Account? To cancel your account you need to login to your...

How can i show my cpu info (linux)?

How can i show my cpu info? Log in to your server via SSH then typ;e the following command...

How can i sync hardware clock

How can i sync the hardware clock in cent os?   First make sure your clock is accurate you can...

How can i upgrade my Cent OS server without upgrading the kernel?

How can I upgrade my Cent OS server without upgrading the kernel?   You cando this by using the...