Hacker News new | past | comments | ask | show | jobs | submit login
Kexecboot: Linux-As-a-Bootloader implementation based on kexec (github.com/kexecboot)
64 points by mmastrac on Nov 3, 2019 | hide | past | favorite | 17 comments



Interesting. A kexecboot patch is widely available on Android, it gets used to provide a hackish multi-OS functionality. (The early boot environment brings up a multi-boot GUI, and the user can choose to continue booting or kexec a different kernel and system image.)


Still requires installing twrp?


Could anyone familiar with this project comment on how it compares to kboot and petitboot?

http://kboot.sourceforge.net/

https://github.com/open-power/petitboot


From a first glance, kboot seems to be unmaintained since 2007. Petitboot looks pretty good but doesn't do x86.

Edit: https://www.plop.at/en/plopkexec/download.html might be a better alternative!


Petitboot does do x86 - we're using it on an AMD x86-64 network appliance.

https://opengear.com/products/om2200-operations-manager/



Is there a way to write a kernel directly to a boot sector and boot directly from it?


Somewhat; if your system boots through EFI (as opposed to the ancient BIOS boot), then you can compile your kernel with the EFI_STUB option[0]. That kernel can be placed in EFI/Boot/bootx64.efi (or whatever you've configured your EFI to boot), and the EFI boot loader will run it without any other boot loader. IME, this goes very well with a built-in initramfs (INITRAMFS_SOURCE[1]), so you have a single-file kernel and ramfs that boots directly from EFI.

[0] - https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.... [1] - https://github.com/torvalds/linux/blob/master/Documentation/...


That's right. I'm using this kind of setup on Arch (including Secure Boot signing of the EFI kernel).


I'm curious why there kernel needs to be specially compiled for this. Is it somehow impossible to build an EFI program that boots whatever is concatenated to the end of it? Is it similarly impossible to have the kernel boot an initramfs concatenated to the end of it? This would make it trivial to swap out the individual components without recompilation.


The Linux kernel used to be a bootable MBR image, but I believe support for this was removed at some point.

I used to build custom Linux kernels for rescue floppies that had no boot loader and a bundled rescue initramfs at an ISP back in the late 90s. They booted very quickly despite being 3.5" floppy disks, it was kind of epic for the time.

http://tldp.org/HOWTO/Linux-i386-Boot-Code-HOWTO/bootsect.ht...

Edit: It looks like 2.6.23 is when it vanished as part of the arch/i386/* -> arch/x86/* migration:

Present @ 2.6.22:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...

Gone in 2.6.23:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...


For EFI systems, the kernel includes a boot stub which allows it to be booted directly by the firmware without an additional bootloader. AFAIK it's not possible to boot directly via BIOS/MBR.

https://www.kernel.org/doc/html/latest/admin-guide/efi-stub....


Or just turn on paging and page in your kernel from the MBR, ignoring the BIOS: https://github.com/charlesap/bootpager

EFI eliminates the need for such trickery though, and who doesn't have EFI these days?


> who doesn't have EFI these days?

VM's hosted on VMware ESX with the default settings comes to mind.


Minimal bootloader can fit in MBR. http://sebastian-plotz.blogspot.com/


Hi there! I'm one of kexecboot contributors. Just realized it's > 11 years old already! We're not active for last years but we're still alive. Feel free to adopt kexecboot to your device and make PR back! Thank you for raising attention too :)

-- Jay7x


I've been using this kexec-reboot utility for years.

https://github.com/error10/kexec-reboot




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: