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/
[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/
Credit goes to: http://www.alethe.com/brad/2008/04/move-an-lvm-based-virtual-machine-to-another-host/ who these instructions were created by.
These instructions were perfect. Thanks Brad!
No comments:
Post a Comment