Skip to contentSkip to conversation

Qemu Booting a PC without an MBR?

Qemu-devel Peter Lieven 4 participants 6 messages Aug 30, 2013 – Sep 2, 2013

lore
Share & tools
lore
#0 lore raw

Hi all,

today I had the second incidence of a migrated system (copied with DD) to qemu which won't boot. (stuck after booting from harddisk message).

Looking at sector 0 I found out that it does not have an MBR. It seems that real hardware and I was told also vmware can cope with this.

Is there a way we can improve this? (maybe be using an open source mbr in case the mbr section is zeroed out?)

Thanks,
Peter

#1 lore raw

Il 30/08/2013 08:28, Peter Lieven ha scritto:

Quoted 7 lines

Hi all,

today I had the second incidence of a migrated system (copied with DD) to qemu which won't boot. (stuck after booting from harddisk message).

Looking at sector 0 I found out that it does not have an MBR. It seems that real hardware and I was told also vmware can cope with this.

Maybe because it's got a UEFI bootloader? In this case, you could try using OVMF as the firmware with the -bios command-line option.

Paolo

Quoted 2 lines

Is there a way we can improve this? (maybe be using an open source mbr in case the mbr section is zeroed out?)

#2 lore raw
Quoted 10 lines · Paolo Bonzini

Il 30/08/2013 08:28, Peter Lieven ha scritto:

Quoted 7 lines

Hi all,

today I had the second incidence of a migrated system (copied with DD) to qemu which won't boot. (stuck after booting from harddisk message).

Looking at sector 0 I found out that it does not have an MBR. It seems that real hardware and I was told also vmware can cope with this.

Maybe because it's got a UEFI bootloader? In this case, you could try using OVMF as the firmware with the -bios command-line option.

I will try, thanks for the pointer.

It seems that the partition marked as boot has a boot loader though.

Peter

#3 lore raw
Quoted 7 lines · Peter Lieven
Quoted 6 lines · Paolo Bonzini

Il 30/08/2013 08:28, Peter Lieven ha scritto:

Quoted 5 lines

Hi all,

today I had the second incidence of a migrated system (copied with DD) to qemu which won't boot. (stuck after booting from harddisk message).

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Looking at sector 0 I found out that it does not have an MBR. It seems that real hardware and I was told also vmware can cope with this.

Maybe because it's got a UEFI bootloader? In this case, you could try using OVMF as the firmware with the -bios command-line option.

I will try, thanks for the pointer.

It seems that the partition marked as boot has a boot loader though.

As a simple workaround you could boot with a GRUB iso and chainload the partition, when you are in the guest OS, fix the MBR.

Fam

#4 lore raw
In reply to Peter Lieven
Quoted 5 lines · Peter Lieven

Hi all,

today I had the second incidence of a migrated system (copied with DD) to qemu which won't boot. (stuck after booting from harddisk message).

You should probably have looked at virt-v2v, but you are where you are now, so ...

Quoted 5 lines

Looking at sector 0 I found out that it does not have an MBR. It seems that real hardware and I was told also vmware can cope with this.

Is there a way we can improve this? (maybe be using an open source mbr in case the mbr section is zeroed out?)

(1) Use virt-rescue to open the disk image and then run whatever program is needed inside the guest (eg. grub-install).

Or:

(2) Use guestfish and add a syslinux boot loader. I don't have a direct example you can copy, but you could greatly simplify this:

https://rwmj.wordpress.com/2013/05/09/tip-convert-a-windows-dvd-iso-to-a-bootable-usb-key-using-guestfish/

It'll probably be something like:

Write a /tmp/syslinux cfg file (see EXTLINUX docs).

guestfish -a disk.img

Quoted 4 lines

<fs> upload /usr/share/syslinux/mbr.bin /dev/sda
<fs> mount /dev/sda1 /
<fs> extlinux /
<fs> upload /tmp/syslinux.cfg /syslinux.cfg

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
#5 lore raw
In reply to Peter Lieven

Actually assuming it's a Linux guest, a third option would be:

(3) Use an external kernel + initrd:

guestfish -a disk.img -i

Quoted 2 lines

<fs> download /boot/vmlinuz-... /tmp/kernel
<fs> download /boot/initrd-... /tmp/initrd

qemu -kernel /tmp/kernel -initrd /tmp/initrd -hda disk.img ...

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v