Transferring virtual Linux install to physical drive
I have a Linux installation inside a VirtualBox VM (VDI file) that I would like to transfer to a physical hard disk. What would be the best way to do this? Could I mount the physical hard drive as a shared folder and use the dd command (booting the VM from a LiveCD) to transfer it? Note, both the VDI and the physical drive are the same size. Any ideas/advice would be appreciated.
|
The problem with the mounting is that you normally use dd on a raw-device,
not on a file-system. For the transfer you could use dd & netcat, or tar & netcat .... |
How would you use netcat to help do this? Also, what about allowing raw disk access to the destination volume? Potentially dangerous-I know but would it work better? Are there any other ways anyone would recommend?
|
That (raw device) is exactly what you'd be doing with netcat and dd ...
E.g. http://www.rajeevnet.com/hacks_hints...s_cloning.html for a how-to (there's heaps - search google for "netcat dd clone"). Cheers, Tink |
Note this method will only work if you have a static .vdi VirtualBox drive image; if you are using a dynamic .vdi drive, I'm still in the process of figuring out how to mount them. But if you happen to have a static .vdi drive, I think probably the easiest way to transfer your VirtualBox OS to a partition would be to mount it, and then copy its entire file system to its new partition with "cp -ax" to preserve all the proper permissions/ownerships of all files. Most VirtualBox .vdi files just have 3 sectors of VirtualBox header info at the beginning, and then the rest is the HDD image. So to mount a static .vdi file, you can usually do:
Code:
losetup -f --show -o $((512*3)) ~/.VirtualBox/HardDisks/HDD_image.vdi Code:
fdisk -lu /dev/loop0 Code:
mount -o loop,offset=$((512*63)) /dev/loop0 /mnt Code:
cp -ax /mnt/* /path_to_mounted_destination_partition/ Code:
blkid -c /dev/null Code:
tune2fs -U <VirtualBox partition UUID> /dev/<new partition device> |
All times are GMT -5. The time now is 08:57 PM. |