VDI to Hard Drive

7,930

Solution 1

There is probably a utility to do this, but you can do it rather easily without any special software, which is always a useful trick to know, as it will work with any type of virtualization software.

Simply boot up a live image in the virtual machine with .vdi attached. Make sure networking is enabled and the machine with the target disk and guest can see each other. Then, dd the virtual partition and pipe to netcat on the guest, and receive it on the host system with netcat and write to the partition with dd.

On the target machine run:

netcat -l -p 4444 | dd of=/dev/<target partition or disk>

It will wait. Inside the guest run:

dd if=/dev/<source partition or disk> | netcat <target-machine-ip> 4444

This is assuming the source and target devices are exactly the same size, which they probably are not.

Note that the target machine does not have to be the virtualization host machine, it can be any machine that the guest machine can reach over the network.

For special software to manipulate .vdi images in a variety of ways see: Mount a VirtualBox drive image (vdi)?

Solution 2

You should copy the contents of the file system instead of writing an image to a physical disk in bitwise mode. This is especially recommended for SSDs with TRIM support, because when TRIM kicks in it will delete files that it doesn't know about (it just starts to clean blocks where it assumes that no files are stored, which is the case for everything that is written in bitwise mode to a SSD). Additionally, copying files to a new file system automatically defragments the files for you.

You can use cp or rsync with the -a parameter as root to preserve permissions and ownership.

At last you need to re-install the boot loader, to have a functional booting operating system. GRUB and GRUB2 can be re-installed via live CD with the --boot-directory option, Windows should provide similar functionality on its installation disk.

Solution 3

You can convert VDI file into RAW format, then use dd command to copy the image into partition.

For example:

VBoxManage clonehd --format RAW file.vdi file.img
dd if=./file.img of=/dev/<partition_here>

Note: Use sudo if required. Be careful when specifying the right device in /dev.

Related:

Share:
7,930

Related videos on Youtube

RARvolt
Author by

RARvolt

Updated on September 18, 2022

Comments

  • RARvolt
    RARvolt over 1 year

    Is any way to copy file system from VirtualBox .vdi file (or others like that) to physical partition on a hard drive?