1

How can I use dd command on a Linux Red Hat Server 5 to obtain a disk image and then use it eventually in Virtual Box?

1

Haven't tested this myself but this is how I have understood it to be possible.

Live boot to server and mount big enough external hard drive where you can store image. Image server's hard drive:

dd if=/dev/sdX bs=4k conv=noerror,sync of=/mount_point_of_extHDD/serverIMG.dd

Then let's zero out unused blocks:

file /path/to/serverIMG.dd

Check startsector value in file command output, multiply it by 512. There is your "offset" value. Mount image:

mount -o loop,rw,offset=<counted_value_here> -t <partitions_filesystem_type> /path/to/serverIMG.dd /mnt/tmp
cat /dev/zero > zeroes.file
rm zeroes.file

Then unmount the image. Boot into machine where you have virtualbox installed so you can modify raw image to vhd:

VBoxManage convertfromraw serverIMG.dd serverIMG.vhd --format VHD
0

VirtualBox - convert RAW image to VDI

dd if=/dev/sdb of=./sdb.raw

To use it with VirtualBox we need to convert it to the VDI format:

$ VBoxManage convertdd sdb.raw sdb.vdi --format VDI

OR

$ VBoxManage convertdd sdb.raw sdb.vmdk --format VMDK

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.