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?
Asked
Active
Viewed 612 times
1
-
2Not a duplicate of [Transferring Operating System from VM to Physical System](http://unix.stackexchange.com/questions/102466/transferring-operating-system-from-vm-to-physical-system), but the opposite of it. Google for `p2v` or `physical to virtual`. – cas May 24 '16 at 08:24
2 Answers
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
MKT
- 5,751
- 1
- 14
- 7
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
Ops
- 21
- 2