Page 1 of 1

how to clone physical machine

Posted: 14. May 2007, 09:12
by Anteo
I have physical linux server what i want convert to virtual can i and how i can do that ??

Posted: 14. May 2007, 10:09
by michael
This is still a bit tricky (we are working on letting you use physical disk partitions in a virtual machine, but this is not in the current release).

One way of doing this in the current version would be to create a virtual hard drive of the same size as the physical one you want to duplicate, starting the VM from a live CD and copying the host's /dev/hdax to the guest's /dev/hdax (using scp or shared folders or something on those lines).

Posted: 14. May 2007, 11:56
by Anteo
OK sound really tricky (My physical server hda is 250G and virtual one is 120G) :shock:

Is there any kind tool (at least third party) which can take image and use it in VB?? (ghost and convert some how)

Posted: 14. May 2007, 17:43
by abcuser
Hi,
this is probably only the solution if using physical and virtual machine on the same hardware. But what if I would like to move operating system from physical machine to virtual machine on different hardware. As I see VMware Workstation has this option. I have tested it and it is working fine. But I haven't found equivalent option in VirtualBox. Have I missed something or this option is not yet available in VirtualBox?

Posted: 17. May 2007, 16:08
by bodhi.zazen
abcuser wrote:Hi,
this is probably only the solution if using physical and virtual machine on the same hardware. But what if I would like to move operating system from physical machine to virtual machine on different hardware. As I see VMware Workstation has this option. I have tested it and it is working fine. But I haven't found equivalent option in VirtualBox. Have I missed something or this option is not yet available in VirtualBox?
This may be a little off topic, but you can convert a VMWare appliance to VirtualBox.

http://doc.gwos.org/index.php/VirtualBo ... _appliance

Posted: 17. May 2007, 22:14
by abcuser
bodhi.zazen it is little of the topic, but it is somehow work around. So if I understand correctly with WMware converter (free product) I can convert physical machine to virtual machine in first step. And in the second step convert VMware virtual machine to VirtualBox virtual machine.

Is there any direct solution available to convert physical machine to VirtualBox virtual machine?

Re: how to clone physical machine

Posted: 30. Jun 2010, 20:51
by FXCreativity
SelfImage or gparted would do the trick if it's not your host drive no?

http://majorgeeks.com/SelfImage_d5588.html

I'm trying to figure out a way with the combination to upgrade the host system w/ virtual.

Re: how to clone physical machine

Posted: 30. Jun 2010, 21:22
by DR I
Well, in theory, it's not so difficult:

Made an hot snapshot of the complete system.
Apply this snapshot remotly to your VM.

But in RL, it's a little bit difficult but not so far.

You can use an alternative method which is to use the "dd" software to perform a complete bit to bit raw image, then when you've got it, just use the VBoxManage CMDLine named convert RAW to VDI or other.

I've got realise this operation a lot of time and worked fine all the times.

Re: how to clone physical machine

Posted: 1. Jul 2010, 10:41
by mpack
Use Disk2VHD, then either use the resulting VHD file directly (not recommended), or convert it to VirtualBox's native .VDI format using CloneVDI. 'dd' is not a good suggestion for imaging a Windows platform.

Regardless of the method used, run MergeIDE on the XP installation before imaging it. In general, prepare it for transfer to different hardware using the techniques described here. XP and later will almost certainly need to be reactivated on the new virtual hardware.

Re: how to clone physical machine

Posted: 2. Jul 2010, 19:30
by crash0veride
Example P2V linux system

This is a barebones example it may not represent the exact partitioning or layouts of your disk however the same process applies in general.
I'll give an easy example using a separate "/boot" partition, it is possible to have "/boot" within "/" however this can confuse people.
I am also assuming a good working knowledge of linux.

- Physical server prep -
Grab any a liveDVD or use the install dvd of your favorite distro and boot "linux rescue".
Within the rescue system mount your partitions:

mkdir /mnt/sys
"/boot" = /dev/sda1
"swap" = /dev/sda2
"/" = /dev/sda3

mount /dev/sda3 /mnt/sys
mount /dev/sda1 /mnt/sys/boot

There are many ways to go about now replicating the data including actually attaching your real drive and it's partitions to the VM.
For this example to keep it simple I'll just use a simple NFS share for temporary storage of the data we need to transition.

Use ifconfig to bring up the network:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0

mount a temporary nfs share --> mount 192.168.1.100:/nfsshare /mnt/nfsshare
create a temp dir to store the data on the share --> mkdir /mnt/nfsshare/p2v
copy the mounted contents to the share cp -a /mnt/sys/ /mnt/nfsshare/p2v/
while this data copies move on to your virtual server

- Virtual Server -
First create a new VM with it's guest OS as the same type as the physical linux server.
Allocate enough disk space to the drive to ensure you can fit the physical servers exisiting used space plus some headroom.
Take the iso of your favorite distros liveDVD or install dvd attach it to the VM and boot "linux rescue".

Once you are booted into rescue mode use fdisk or parted to partition the virtual disk with "/boot", swap and "/" partitions.
When all said and done you should end up with something like this:

/dev/sda1 ("/boot", 100MB)
/dev/sda2 (swap, 1GB)
/dev/sda3 ("/", 20GB)

check the fstab and the "/boot/grub/grub.conf" on the physical server to see if you were using labels, disk-ids, or absolute paths to mount partitions.
Make a note of what you were using.

For my example we'll assume labels were used.
So the /etc/fstab looked like:
LABEL=boot /boot ext3 defaults 1 1
LABEL=root / ext3 defaults 1 2

Format the "/boot" and "/" partitions: --> mkfs.ext3 /dev/sda1, mkfs.ext3 /dev/sda3
Format swap --> mkswap /dev/sda2

re-label the partitions:
e2label /dev/sda1 boot
e2label /dev/sda3 root

Mount the partitions you have created.

mkdir /mnt/sys
"/boot" = /dev/sda1
"/" = /dev/sda3

mount /dev/sda3 /mnt/sys
mkdir /mnt/sys/boot
mount /dev/sda1 /mnt/sys/boot

Now we will want to retrieve the data you copied to the nfsshare.

Use ifconfig to bring up the network:
ifconfig eth0 192.168.1.2 netmask 255.255.255.0

mount the temporary nfs share --> mount 192.168.1.100:/nfsshare /mnt/nfsshare
copy the data to the new virtual disk: --> cp -a /mnt/nfsshare/p2v/ /mnt/sys/

Once this finishes we will need to re-install grub

First you need to mount proc and dev from the rescue system to /mnt/sys

mount -t proc none /mnt/sys/proc
mount -o bind /dev /mnt/sys/dev

This will allow grub to see the drives.

now we need to chroot into /mnt/sys: --> chroot /mnt/sys

Next we need to fire up grub: run--> grub
Since we know that we created a "/boot" partition this means that the partition which contains the grub files is hd(0,0)
This translates to disk 0 partition 0, and tells grub where it can find it's files. EG: hd(0,0)/grub/stage1
Knowing this type "root (hd0,0)" into the grub console and hit enter
Next type "setup (hd0)" and hit enter

The outputs of those commands should have resulted in grub locating it's files and installing itself into the MBR of sda
type "quit" to get out of grub

type exit to get out of your chrooted jail.
Next you'll want to unmount all of your mounted stuff.
umount /mnt/sys/dev
umount /mnt/sys/proc
umount /mnt/sys/boot
umount /mnt/sys

Reset your VM, if everything went well you should now see your physical server happily booting as a VM.

Re: how to clone physical machine

Posted: 15. Oct 2010, 09:05
by Scoox
For a windows system, I guess using something like Norton Ghost whould do the trick. You can clone the partition your OS is running from, and then write it to a physical partition. Hardware drivers will need to be installed once the image is written to the physical partition so that things work properly on the new system.

Re: how to clone physical machine

Posted: 15. Oct 2010, 12:23
by mpack
Scoox wrote:For a windows system, I guess using something like Norton Ghost whould do the trick
To P2V a Windows system, use Disk2VHD as already said. It's a one step quick process instead of a n-step slow one, so I can't think of anybody who would prefer to use Ghost et al for this task.

Re: how to clone physical machine

Posted: 24. Oct 2010, 04:25
by Winipulator
I converted my old Drive Image floppies to an ISO. Burned the ISO to a bootable CD. Booted to the CD, Copied my C: drive to PQI files onto another partition. Booted back into Windows. Used an ISO editor to add the PQI files to my ISO. Made a new DOS VM and used it to load the ISO, which loaded Drive Image into VirtualBox. Used drive image to copy the PQI files onto the VDI. Created a new Windows XP VM, loaded that VDI into it, and XP loaded perfectly. Google my name for my blog post about this that goes into much more detail, and I provide the ISO for download. I know this involves a few steps, but the results are excellent.