This seems like it should be so easy yet I've been banging my head for over a week on it.
I have an installation of Debian on a separate partition of my harddrive (sda5)
I have copied this filesystem using dd if=/dev/sda5 of=test.img and I get a nice image of the partition. I can -o loop mount it no problem.
However, if I convert this test.img -> vdi using VBoxManage createfromraw it says GRUB geometry error and won't boot.
SOO these are my attempts thus far to fix this:
First attempt was to just extract the MBR from the harddrive bying using
a) dd if=/dev/sda of=MBR.img bs=512 count=1
b) I tried to use CAT MBR.img test.img > new-test.img then partition it with parted.
c) Parted says "Error: Can't have a partition outside the disk!"
Second attempt
a) Joined the MBR.bin and test.img using dd if=MBR.bin of=test.img bs=1 conv=notrunc
b) Parted says exact same error "Error: Can't have a partition outside the disk!"
What am I doing wrong here ????
Adding a MBR to a Partition Image before converting to VDI
-
david_vmm12
- Posts: 1
- Joined: 23. Dec 2009, 01:53
- Primary OS: Debian Lenny
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Debian Lenny
-
Etepetete
- Posts: 400
- Joined: 7. Oct 2009, 10:19
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Slackware 14.2
- Location: Berlin
Re: Adding a MBR to a Partition Image before converting to VDI
You can use the CloneVDI tool from mpack. If I remember correctly, it will create a boot sector of the partition you cloned. The disk will still be missing a boot loader. That you will have to take care of after creating your VDI.
-
mpack
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Mostly XP
Re: Adding a MBR to a Partition Image before converting to VDI
The MBR contains the sector offset to the first partition, and if that offset is not correct in the virtual image then it can't boot. In any case you quite likely have grub boot stuff in track 0 that you neglected to copy.david_vmm12 wrote:First attempt was to just extract the MBR from the harddrive bying using
a) dd if=/dev/sda of=MBR.img bs=512 count=1
b) I tried to use CAT MBR.img test.img > new-test.img then partition it with parted.
If possible you should find out what LBA your first partition actually starts on, however... In most cases the first partition on starts at sector 63, so if you try what you did before, but copy the first 63 sectors of your host drive (instead of just the first sector) then it may work.
Etepetete mentioned using my CloneVDI tool for this: unfortunately that will very probably not work in this case, because the feature in question only knows how to supply the missing data for orphaned Dos/Windows partitions. Linux partitions are more complex (all that grub boot stuff in track 0, and quite possibly a missing swap partition as well), so I don't even attempt to fix that. My suggestion above deals with the grub boot problem, but not the latter problem.