4

I have a fairly old debian machine that I need to migrate to KVM-Qemu.

What I started is to make a tarball of the root filesystem:

tar -cpf rootfs.tar  --exclude='dev/*' --exclude='proc/*' --exclude='sys/*' --exclude='home/*' /

scp tar file to a running kvm machine, make small changes, then hope it works. Anybody knows a better solution than this?

Kyle
  • 494
  • 1
  • 5
  • 13
qemu55
  • 41
  • 2

3 Answers3

4

Why not use the actual software created for this use case? What you need is virt-p2v

dyasny
  • 18,482
  • 6
  • 48
  • 63
0

If you want the size of the virtual disk on the VM to be the same as the physical disk you were using on your physical machine, then you can simply copy the entire disk to a disk image. You put this disk image on the host system while the VM is down. The command to copy the disk could look like this:

ssh -C vhost dd of=/path/to/image < /dev/sda

It is best to run this with all file systems mounted read-only on the source.

kasperd
  • 29,894
  • 16
  • 72
  • 122
0

I wrote a step-by-step detailed answer of how I solved a very similar challenge on the question: Turning a running Linux system into a KVM instance on another machine. I hope it proves a useful answer for this question too.

Goal of the answer: 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 the V guest, because the target hypervisor (Proxmox 5) used ZoL/ZFS. Also wanted to mitigate downtime/reboots on the running P node.

Kyle
  • 494
  • 1
  • 5
  • 13