Migrating physical machines to oVirt with relax-and-recover (p2v using rear)

Relax-and-recover offers a fairly easy way to migrate physical (UNIX) machines to a virtualized environment.

Preflight checks and todos...

  • The kernel on the source machine must support the new (virtio) devices.
  • Clean up your system (logs, temp files, database cache, session data, etc.).
  • You'll need an ISO storage domain and a working NFS server with a share for backup files (on your oVirt server).
  • Check the gnu parted manual (especially the mkpart commands).


  1. Install REAR (avaiable in package repos), e.g.: yum install rear
  2. Edit rear config (usually in /etc/rear/local.conf) and specify (for example)
    BACKUP_PROG_EXCLUDE=( "${BACKUP_PROG_EXCLUDE[@]}" "dirs you want to exclude" )
  3. See what rear knows about your system
    read dump | less
  4. Start the backup
    rear -v mkbackup
  5. Copy or symlink the ISO file (rear-hostname.iso) from the NFS share to the oVirt ISO domain
  6. Create a blank virtual machine with a big-enough disk image
  7. Start the VM with run-once and assign the rear ISO as first bootable device
  8. Log in as root and start the rear recovery
    You need to map the original drive (e.g. sda) to the virtual drive (vda).
    If you shrink the original disk, you may also need to specify partition sizes manually.
    Editing the diskrestore script is the easy way to fix mapping problems (see parted and mkfs lines).
  9. Check the results (log file and mounted filesystems)
  10. Reboot the machine from the hard drive
  11. The first boot may cause kernel panic (see below) or could take a long time due to hardware changes, SELinux relabeling, etc.

Problems and solutions

Moving to a smaller/different disk layout

Don't waste much time with manually specifying the disklayout.conf. Edit the diskrestore script during recovery instead. Parted has quite user friendly commands like:

parted -s /dev/vda mkpart primary 64s 100MiB   # this is for /boot
parted -s /dev/vda mkpart primary 100MiB 1GiB  # swap
parted -s /dev/vda mkpart primary 1GiB 100%    # the rest is /

Loosing network connection during recover

I had trouble with the virtio network driver. Sometimes it drops the connection. If this happens pause the restore process with CTRL+Z then

rmmod virtio_net
modprobe virtio_net
dhclient -r
df # waits until the NFS mount is OK
fg # continues the recovery process

It might be a good idea to avoid these problems by dropping virtio net and using the rtl8139 driver (oVirt: VM: edit network interfaces).

Fixing "no root device" kernel panic

If your system doesn't boot (kernel panic) due to wrong/missing root device then check grub, fstab and preloaded drivers in initrd. Boot it again with the rescue cd, mount your new partitions (e.g. at /mnt), then:

chroot /mnt ; su -  # now you have a working shell in your new filesystem
vi /etc/fstab /etc/grub.cfg
mkinitrd --preload virtio --preload virtio_pci --preload virtio_ring \
--preload virtio_blk --preload virtio_net --omit-scsi-modules \
--omit-raid-modules --without-multipath --without-dmraid
# you may also consider  --preload virtio_console --preload virtio_balloon --omit-lvm-modules
grub-install /dev/vda
Reboot after this. Hopefully, virtio drivers will be preloaded to mount your root filesystem in the virtual machine.

SELinux troubles

Since rear stores your files in a tar archive you may loose selinux labels.
You'll need to recreate them manually using semanage or chcon.
Symlinks can cause trouble during this, so you may want to use the -h flag.