I have two physical machines that I wish to virtualize.
I can not (physically) plug the hard drives from either machine into the new machine that will act as their VM host, so I think that copying the entire structure of the system over using dd
is out of the question.
How can I best go about migrating these machines from their hardware to the KVM environment? I've set up empty, unformatted LVM logical volumes to host their filesystems, with the understanding that giving the VMs a real partition to work with achieves higher performance than sticking an image on the filesystem.
Would I be better off creating new OS installs and rsyncing the differences over?
FWIW, the two machines to be VM'd are running CentOS 5, and the host machine is running Ubuntu Server 10.04 for no particularly important reason. I doubt this matters too much, as it's still going to be KVM and libvert that matter.
P2V Linux physical to virtual KVM - no automated tools
Live migration of
P
running Debian Wheezy 7.11 toV
KVM on Proxmox VE v5.4mdadm software RAID1
P
disks to KVM virtio disksmigrate from large
P
disks to smallerV
disksForeword
The goal of these steps was to take a physical Linux
P
node running live-production and virtualise it. Without having to create and allocate multi terabyte disks, nor have to use md raid in theV
guest, because the target hypervisor (Proxmox 5) used ZoL/ZFS. Also wanted to mitigate downtime/reboots on the runningP
node.These steps might not be perfect, but it should get you close to a solution and cites useful links I found along the way.
I chose to post an answer on this question after careful google searching on https://unix.stackexchange.com and https://serverfault.com. This seemed like the most relevant question for my answer, even though its 9+ years old at the time of writing this.
Here are some related questions I found, which this answer also aims to solve too:
P2V with rsync
How to create a virtual machine from a live server?
How to migrate a physical system to a KVM virtual server with only network access?
Converting physical machine into virtual without shutdown it
Migrating physical machine to KVM
vmware conversion linux physical machine
How to migrate a bare metal Linux installation to a virtual machine
STEP 1
virtio support
STEP 2
KVM prep - BIOS partition(s)
STEP 3
KVM prep - BOOT and DATA partition(s)
step 4
rsync data
step 5
update grub
step 6
test kvm and make changes required post P2V
step 7
final tests and verification's
Redhat made a utility called p2v to do exactly this.
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/V2V_Guide/chap-V2V_Guide-P2V_Migration_Converting_Physical_Machines_to_Virtual_Machines.html
You could possibly pipe the output from dd through an SSH tunnel to your target machine. I've known it to be done relatively successfully into a VMWare virtual machine.
Good details in the main answer here, and provides instructions for what to do if SSH isn't running (a number of liveCDs have SSH server on them anyway, so shouldn't be a problem): How to set up disk cloning with dd, netcat and ssh tunnel?
You can copy the disk images to the LVM logical volumes and provide this as the disk image for the VM. Make sure you disable NTP and NTPDATE on the virtual servers.
I converted some old images using Mondo to create bootable recovery images. This allowed me to resize the partitions during reinstall.