Re: [osv-dev] Booting Bare Metal

38 views
Skip to first unread message

Pekka Enberg

unread,
Nov 26, 2019, 1:30:26 AM11/26/19
to Matthew Weekley, OSv Development
Hi Matthew,

On Tue, Nov 26, 2019 at 2:51 AM Matthew Weekley <twee...@comcast.net> wrote:
How would one recommend doing so using grub? I have noticed that OSv doesn't support multiboot, or so it seems to me. I am not a grub expert by any means so that's why I am asking for some help. I am doing a school research project on Unikernels and am looking to show performance increase running that running a unikernel as a standalone provides.

Look arch/x64/boot32.S and you will see Multiboot 1 compatible boot header. My assumption is that "loader.bin" should be bootable under GRUB. You could look into "grub-mkrescue", for example, to generate a bootable ISO image:


Please also note that most OSes have moved over to Multiboot 2, which is not backward compatible with Multiboot 1. I think GRUB 2 supports the older variant, but if you hit unexpected problems, make sure it's not related to Multiboot 1/2 differences.

- Pekka 

twee...@comcast.net

unread,
Nov 26, 2019, 8:30:40 AM11/26/19
to OSv Development
I just looked and I do not have any of those files anywhere on my system (did the find command).

Pekka Enberg

unread,
Nov 26, 2019, 8:46:25 AM11/26/19
to Matthew Weekley, OSv Development, Waldek Kozaczuk
On Tue, Nov 26, 2019 at 3:30 PM <twee...@comcast.net> wrote:
I just looked and I do not have any of those files anywhere on my system (did the find command).

Aah, my tree was not up-to-date. Looks like Waldek removed Multiboot support:

commit 2a34f9f2acb582b8351c3ca7cac0ac2ad18dfe2a
Author: Waldemar Kozaczuk <jwkoz...@gmail.com>
Date:   Wed Jul 24 17:54:56 2019 -0400

    Remove obsolete loader.bin build artifact and related source files

    At some point long time ago the loader.bin artifact was added
    as a way to boot OSv on multiboot bootloaders. Unfortunately it got abandoned with time,
    then resurrected with the commit e44133273ebdbb305b045b6a74c347a96cab9943 to allow
    OSv boot on hyperkit in multiboot mode which never became fully functional.

    Given that now we have Linux-compatible vmlinuz.bin artifact generated
    than can be used to boot OSv on hyperkit, there is no need to keep this arifact
    around - the boot process and all kinds of its variation are complex enough.

    Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

But, GRUB should be able to boot to "vmlinuz.bin" if it's really compatible with Linux kernel.

- Pekka 

Waldek Kozaczuk

unread,
Nov 26, 2019, 8:50:59 AM11/26/19
to Pekka Enberg, Matthew Weekley, OSv Development
Pekka,

Thanks for finding this. From what I remember I found multiboot not that widely supported comparing to vmlinuz. 

Please note that OSv vmlinuz is not compressed so we simply wrap loader.elf

I really need to revise the boot wikis 

Sent from my iPhone

On Nov 26, 2019, at 08:46, Pekka Enberg <pen...@scylladb.com> wrote:


Message has been deleted

Matthew Weekley

unread,
Nov 26, 2019, 9:17:11 AM11/26/19
to Waldek Kozaczuk, Pekka Enberg, OSv Development
I’ve never used vmlinuz to boot. Any suggestions?? Currently looking but maybe you can provide a faster solution than I’ll be able to research. Thanks!

On Nov 26, 2019, at 8:51 AM, Waldek Kozaczuk <jwkoz...@gmail.com> wrote:

Pekka,

Pekka Enberg

unread,
Nov 26, 2019, 9:30:46 AM11/26/19
to Matthew Weekley, OSv Development
On Tue, Nov 26, 2019 at 4:14 PM <twee...@comcast.net> wrote:
I've never used vmlinuz to boot, but I see files that pertain to vmlinuz. Any suggestions for how to boot bare metal using vmlinuz? Currently looking for solutions now. Thanks!

Use GRUB, for example. See the previous links to "grub-mkrescue" how to generate an bootable ISO image. The only difference to Multiboot is that you need to remember to tell GRUB that the kernel follows the vmlinuz format, and that's it.

- Pekka 

Nadav Har'El

unread,
Nov 26, 2019, 9:40:31 AM11/26/19
to Matthew Weekley, Osv Dev
On Tue, Nov 26, 2019 at 2:51 AM Matthew Weekley <twee...@comcast.net> wrote:
I am looking to boot the kernel I generated from the build script. 

How would one recommend doing so using grub? I have noticed that OSv doesn't support multiboot, or so it seems to me. I am not a grub expert by any means so that's why I am asking for some help. I am doing a school research project on Unikernels and am looking to show performance increase running that running a unikernel as a standalone provides.

Besides the kernel format issues which I see that you're discussing with Pekka  and Waldek, there may be a more serious problem -
You're mentioning running OSv in grub, and "running a unikernel as a standalone". Does this mean you want to run OSv on an actual physical machine, not a VM inside a hypervisor?

If this is the case the bigger problem you'll encounter is that OSv will not have a driver for your network card, and probably also not for your disk drive. One of the things which simplified OSv's development is that we didn't need to implement a hundred drivers for different hardware. Doing this is not impossible, but will not be trivial either.

 

Thanks for any help provided!

--
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/531F2E6E-8EA3-48C8-9E4E-5DF9AAF4A023%40comcast.net.

Matthew Weekley

unread,
Nov 26, 2019, 9:50:07 AM11/26/19
to Nadav Har'El, Osv Dev
My current grub is 

menuentry “OSv” {
multiboot /boots/service/release.x64/vmlinuz.bin
boot
}

This returns “no multiboot header found. You need to load the kernel first”

Also, I don’t need any networking capabilities. Just trying to run a simple program and show it can boot bare metal :)

Think of it as me trying to run the “native-example” app that prints out “Hello”

Also, thanks for all the replies and help!!

On Nov 26, 2019, at 9:40 AM, Nadav Har'El <n...@scylladb.com> wrote:



Pekka Enberg

unread,
Nov 26, 2019, 9:56:10 AM11/26/19
to Matthew Weekley, Nadav Har'El, Osv Dev
On Tue, Nov 26, 2019 at 4:50 PM Matthew Weekley <twee...@comcast.net> wrote:
My current grub is 

menuentry “OSv” {
multiboot /boots/service/release.x64/vmlinuz.bin

   ^^^ this needs to "linux", instead of "multiboot".
 
boot
}

This returns “no multiboot header found. You need to load the kernel first”

Yes, because there's no Multiboot support in OSv anymore. The "vmlinuz" file follows the Linux boot protocol described here:


- Pekka 

Matthew Weekley

unread,
Nov 26, 2019, 10:06:12 AM11/26/19
to Pekka Enberg, Nadav Har'El, Osv Dev
Corrected that but that lead to a critical error when trying to boot it.

Do I need to specify any further files below the vmlinuz file?

On Nov 26, 2019, at 9:56 AM, Pekka Enberg <pen...@scylladb.com> wrote:



Matthew Weekley

unread,
Nov 26, 2019, 1:55:57 PM11/26/19
to Pekka Enberg, Nadav Har'El, Osv Dev
My current grub.cfg:

menuentry “OSv”{
linux /boot/service/release.x64/vmlinuz.bin
boot
}

When I go to boot from within grub, I get a critical error :(

Any thoughts why?? 

On Nov 26, 2019, at 10:06 AM, Matthew Weekley <twee...@comcast.net> wrote:



Matthew Weekley

unread,
Dec 3, 2019, 7:25:10 AM12/3/19
to Pekka Enberg, Nadav Har'El, Osv Dev
After further experimentation I still haven’t had any luck. When trying to boot it via USB, it appears I’m going into a kernel panic...

I can not tell if I am missing parameters in my grub.cfg or not... Does anyone have any thoughts about what could be causing that? 

What I am doing is making the iso, putting it on the usb (kind of cheating as I just say the usb is another partition, sdb) and then boot that partition from grub menu. 

Any help is much appreciated!

On Nov 26, 2019, at 1:56 PM, Matthew Weekley <twee...@comcast.net> wrote:


--
You received this message because you are subscribed to a topic in the Google Groups "OSv Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osv-dev/jEMfRZ0GtSc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/209F20AC-D16A-4BC3-9960-7BE14BA0CB03%40comcast.net.

Geraldo Netto

unread,
Dec 3, 2019, 7:37:00 AM12/3/19
to Matthew Weekley, Pekka Enberg, Nadav Har'El, Osv Dev
Hello!


I might be saying some non sense
But maybe we don't have all the bare minimum drivers to boot it up from bare metal
Maybe one strategy would be to DD the image to a disk and try to boot from it before trying grub configuration?


Keep Rocking,
Geraldo Netto

You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/88E15BA6-68EB-4108-9BFD-18262350E918%40comcast.net.

Matthew Weekley

unread,
Dec 3, 2019, 7:42:22 AM12/3/19
to Geraldo Netto, Pekka Enberg, Nadav Har'El, Osv Dev
Hello, 

Sorry, I should’ve been more specific! That is what I am doing. Would it be more help if I gave you the script I am running and my grub.cfg...When I reboot my system and pick that partition in BIOS, then it kernel panics. 

I’ve been trying to get it to work for some time now but I am stumped. Thanks for your help! 


On Dec 3, 2019, at 7:37 AM, Geraldo Netto <gerald...@gmail.com> wrote:



Pekka Enberg

unread,
Dec 3, 2019, 10:31:36 AM12/3/19
to Matthew Weekley, Geraldo Netto, Nadav Har'El, Osv Dev
Hi Matthew,

On Tue, Dec 3, 2019 at 2:42 PM Matthew Weekley <twee...@comcast.net> wrote:
Hello, 

Sorry, I should’ve been more specific! That is what I am doing. Would it be more help if I gave you the script I am running and my grub.cfg...When I reboot my system and pick that partition in BIOS, then it kernel panics. 

I’ve been trying to get it to work for some time now but I am stumped. Thanks for your help! 

There's not enough information here to help you.

Remember, there could be bugs that prevent booting on bare metals. I would suggest that you take the following incremental steps:

(1) Make sure you have the correct process for an ISO image that boots Linux with GRUB.

(2) Make sure your ISO image with OSv kernel boots under QEMU/KVM (with the same QEMU parameters as run.py uses now).

(3) Make sure your ISO image with OSv boots under QEMU (full emulation mode).

(4) Start experimenting with the above ISO image on bare metal.

(5) Insert printfs() to the kernel boot sequence to determine where it fails.

(6) Fix any bugs that appear then repeat step (5) until it boots.

- Pekka

Pekka Enberg

unread,
Dec 3, 2019, 10:35:03 AM12/3/19
to Matthew Weekley, Geraldo Netto, Nadav Har'El, Osv Dev
Btw, with this configuration, I can boot to Linux, but OSv just hangs (could be lack of VGA or something else):

# GRUB configuration:
mkdir -p build/iso/boot/grub
cat <<EOF > build/iso/boot/grub/grub.cfg
set timeout=0
set default="0"
menuentry "osv" {
    linux /boot/vmlinuz
    boot
}
EOF

# Copy kernel image:
cp build/release.x64/vmlinuz.bin build/iso/boot/vmlinuz
# ---- OR ----
cp /boot/vmlinuz-5.2.9-200.fc30.x86_64 build/iso/boot/vmlinuz 

# ISO image creation:
grub2-mkrescue -o build/os.iso build/iso/

# Boot under QEMU/KVM:
qemu-system-x86_64 -enable-kvm -cpu host,+x2apic -cdrom build/os.iso

- Pekka

Waldek Kozaczuk

unread,
Dec 4, 2019, 11:56:22 PM12/4/19
to OSv Development

The vmlinuz.bin was added fairly recently by me to make OSv boot on hyperkit (see this commit - https://github.com/cloudius-systems/osv/commit/1e460f5985c54496795f5aebea413881bc43ebd3). I am afraid that it might not be fully compliant per Linux boot protocol -  https://www.kernel.org/doc/Documentation/x86/boot.txt and may not be compatible with both qemu and grub2.

The key parameters are relocatable_kernel and pref_address which we set to OSV_KERNEL_BASE - 0x400 and hyperkit is able to deal with it.

I suspect that grub ignores relocatable_kernel (or I just misunderstand the spec) and loads the kernel at 0x100000 (as linux). The problem is that vmlinuz.bin wraps loader.elf. We could instead as an option make vmlinuz.bin wrap lzloader.elf just like usr.img does. But then the code in https://github.com/cloudius-systems/osv/blob/master/arch/x64/vmlinuz-boot32.S#L58-L64 would need to change to call uncompression routine. This all seems doable.

BTW I have found some other links from the past describing people booting OSv on bare metal - http://yushiomote.org/blog/?p=469 - years ago.

Waldek

PS. Do you see anything printed on the console?

Pekka Enberg

unread,
Dec 5, 2019, 12:21:30 AM12/5/19
to Waldek Kozaczuk, OSv Development
On Thu, Dec 5, 2019 at 6:56 AM Waldek Kozaczuk <jwkoz...@gmail.com> wrote:
PS. Do you see anything printed on the console?

Nope. I think I should have serial console enabled too to print to host stdout, but I honestly didn't spend any time debugging this.

- Pekka
Reply all
Reply to author
Forward
0 new messages