1. Test the disc image mounts sucessfully
mount -t loop <disc image.img> <mountpoint>
cd <mountpoint>
ls # should show disc image contents as expected
2. Create a VMDK image referencing your disc image
VBoxManage internalcommands createrawvmdk -filename <vmdk filename>.vmdk -rawdisk <disc image.img>
3. Create a VirtualBox machine
Select the VMDK file, created in the previous step, as your disc image.
Alternatives
Other virtualisation technologies are available. For example, you could also use qemu
for this task:
https://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu
If you still have the source disk it may be easier to just create an VDI image from the partitions as described here.
– Robert – 2020-02-09T12:09:23.107@Robert No I only have these 2 files – Rembo – 2020-02-09T12:26:01.550
@MichaelHarvey I am missing /dev/sda2 and /dev/sda3 – Rembo – 2020-02-09T12:32:42.237
@MichaelHarvey I dont have access to original disk to make a dd images of them. I have only /dev/sda1 which contain grub boot loader and /dev/sda4 which has home folder. sda2 and sda3 had just some files in them and 200GB of free space so i didn't use dd on them. – Rembo – 2020-02-09T13:03:11.157
@MichaelHarvey create a virtualbox image that can boot the system without having sda2 and sda3 – Rembo – 2020-02-09T13:09:02.750
1Have you successfully managed to mount the files to a directory on your system? (
sudo mount -oloop <FN> <mountpoint>
) if you can do this, you can set the mountpoint up as a virtualbox disc location – Mark – 2020-02-09T13:21:42.083I dont need sda2 and sda3. that is why i didn't create a dd image from them. – Rembo – 2020-02-09T13:22:11.557
@Mark Yes I can mount it and see the files. but I want to boot the OS. – Rembo – 2020-02-10T13:01:47.997
@Rembo you need to have a look at the VBoxManage CLI command to create the disk. Something like:
– Mark – 2020-02-10T14:27:11.973VBoxManage internalcommands createrawvmdk -filename "</path/to/file>.vmdk" -rawdisk <diskimg.img>
https://mobile.serverwatch.com/server-tutorials/using-a-physical-hard-drive-with-a-virtualbox-vm.html