Command:
sudo dd if=DRIVE | VBoxManage convertfromraw stdin FILENAME BYTES
Real Example
sudo dd if=/dev/sda | VBoxManage convertfromraw stdin MyLinuxImage.vdi 120034123776
Notes:
1- To get the number of bytes in partition, you can use the following command
sudo fdisk -l /dev/sda
2- You need to use /dev/xxx not /dev/xxx1 or xxx2 so that the image contains MBR records
For more information check the following link:
https://www.virtualbox.org/wiki/Migrate_Windows
Tweet
Thanks, useful post.
ReplyDeleteso the 120034123776 number is the size of the (for example sda1) partition I want copy?
ReplyDeleteYes, please read the 2 notes @ the end of the post, good luck
ReplyDeleteAny idea how to do things the other way around? Create a linux iso to install on a physical machine from a virtual box image?
ReplyDeleteI don't know a solution for that
ReplyDeleteKarim. your post helped me too. Thanks!
ReplyDeleteFor Scott MacDonald's vdi-to raw see:
http://blog.mybox.ro/2010/11/03/how-to-use-a-raw-disk-image-file-in-virtualbox/
Hi, some idea to convert vdi image to real physical partition?
ReplyDeleteI didn't face this case before, if you found a solution please post it here for other people
ReplyDeleteAnswering previous question(my own question), to convert from vdi to physical real partition. In my case I wanted to migrate from vdi files to lvm partitions on Linux, for it I created a logical volume with exact size of the vdi file, to see the exact size of the vdi file I used:
ReplyDelete$ VBoxManage list hdds # it will show disks files with UUIDs
$ VBoxManage showhdinfo <UUID> # it will show the logical size in Mb
Then create the lvm partition with retrieved size
# lvcreate -n <lvm-name> -L <size>M <lvm-group>
Now convert the vdi file to raw format
$ VBoxManage internalcommands converttoraw <vdi-file>.vdi <raw-file>.raw
Create the vmdk file to use the lvm partition
$ VBoxManage internalcommands createrawvmdk -filename <vmdk-file-name>.vmdk -rawdisk /dev/<lvm-partition>
Copy the raw image to the lvm physical partition
# dd if=<raw-file>.raw of=/dev/<lvm-partition>
Is important to use dd to copy, it will copy as disk image. Then as last in the settings of the VM change the disk from vdi file to the vmdk create file.
Thanks Cesar
ReplyDeleteThanks for this.
ReplyDeleteHow can we do virtual to physical.
On Macosx, How with one command,
migrate a mounted raw image of Windows to a NTFS Bootcamp partition ?
I used this tutorial: huguesval.com/blog/2012/02/installing-windows-7-on-a-mac-without-superdrive-with-virtualbox
And like the last step I want to copy the raw mounted image to the Bootcamp partition.
Thx!
I have a problem when I use dd it errors out after the file reaches 4GB. Any help I need a point in the right direction.
ReplyDeleteI answered my own question. Formated my external to NTFS. I forgot that FAT can't handle anything over 4GB. hehehe silly newbie mistake.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIs there a command that can grab only the space used in the physical partition instead of the whole drive?
ReplyDeletefor example, if I am only using 15 GB of space on my (500 GB) hard drive, then I only want to convert those 15GB from rawtovdi instead of the whole 500 GB.
Greatly appreciated!
how do when already have a image of a single partition. sda1.bin for example
ReplyDeletethanks