I have an obsolete linux app-server running which I would like to migrate to a KVM virtual server with greater specifications.

I do not have physical access to the machine itself or its harddisks.

I only have access to the server across the network.

If it can be used for anything, I already have an empty spare HD installed in the server. This 2nd HD is about three times larger than then one where the data resides on.

Please ask for any other details you may need.

  • 2
    Which hypervisor?
    – Chopper3
    Oct 4 '12 at 12:15
  • 9
    This is called "Physical to Virtual" or "P2V" for short. Nearly every hypervisor has tools to do this, such as XenConvert or VMWare Converter
    – Dan
    Oct 4 '12 at 12:17
  • 2
    – gravyface
    Oct 4 '12 at 12:54
  • @Chopper3 I am open to any if I could get it migrated successfully. Preference is KVM or OpenVZ (Proxmox).
    – mr-euro
    Oct 5 '12 at 11:46
  • @gravyface Please ask for what details you need. Thank you.
    – mr-euro
    Oct 5 '12 at 11:46

Assuming you don't have remote console access, or it's through some crappy horrible useless Java applet:

  1. ssh to the remote system and shut down as many services as possible. Basically everything but the ssh server itself.
  2. From your local system, capture a copy of the running disk image back to your local system:

    ssh root@remote.example.com "dd if=/dev/sda bs=1024k" > p2v.img

    Wait several hours. Depending on the size of the hard disk and your available bandwidth, this may take a very long time.

  3. You will end up with a file p2v.img. Mount this to a KVM virtual machine as a raw disk image and fsck it, as there will be errors.

Since you do have remote console access to the server, I would do something like this:

  1. From the remote console, bring the system to single-user mode (init 1 as root, or reboot with 1 added to the boot command line).
  2. Bring up the network manually, e.g. with the appropriate ifconfig and route commands.
  3. P2V it to the remote hypervisor (or a storage server):

    dd if=/dev/sda bs=1024k | ssh root@kvmhost.example.com "cat > /path/to/p2v.img"
  4. Create a new KVM virtual machine using p2v.img as the disk, start it up and make any necessary changes.

The virt-v2v tool can also P2V a Linux server to a KVM virtual machine.

  • +1 nc is probably quicker, but likely both hosts are not on the same private network.
    – gravyface
    Oct 5 '12 at 13:31
  • @gravyface I don't worry too much about one-hour differences on 10-hour jobs, since in either case I'm going to look at it the next day anyway. Oct 5 '12 at 13:32
  • @MichaelHampton I do have access to a rescue system (via SSH) so I can entirely stop the system and still work on it. In which way could this change your suggested approach? Thank you.
    – mr-euro
    Oct 7 '12 at 10:13
  • @mr-euro I don't know if you ever saw my edits. From a rescue system the process would be about the same, except that you would connect to the rescue system instead of to your live system. Dec 19 '14 at 1:43

All major hypervisors have a native P2V tool. Pick a hypervisor and use its tool.

  • Thx MDMarra, I prefer KVM. Do you have any references on how to accomplish this with no physical access to the harddisk?
    – mr-euro
    Oct 5 '12 at 12:04

A command line that worked for me:

 dd if=/dev/sda1  | (ssh root@ of=/some-path-on-remote/file.img )

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.