News for hackers. Stuff that matters.
Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by spease on Sunday November 03, 2019 @10:27AM (#21434383)
Is there a way to write a kernel directly to a boot sector and boot directly from it?
Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by tsuraan on Sunday November 03, 2019 @10:40AM (#21434478)
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/...

Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by Boulth on Sunday November 03, 2019 @11:26AM (#21434776)
That's right. I'm using this kind of setup on Arch (including Secure Boot signing of the EFI kernel).
Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by AnIdiotOnTheNet on Sunday November 03, 2019 @02:42PM (#21436078)
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.
Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by newnewpdro on Sunday November 03, 2019 @01:24PM (#21435596)
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...

Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by kevinoid on Sunday November 03, 2019 @10:40AM (#21434473)
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....

Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by charlesap on Sunday November 03, 2019 @12:40PM (#21435303)
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?

Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by nineteen999 on Sunday November 03, 2019 @06:59PM (#21437677)
> who doesn't have EFI these days?

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

Re:Kexecboot: Linux-As-a-Bootloader implementation based on ... by grapeli23 on Sunday November 03, 2019 @11:29AM (#21434803)
Minimal bootloader can fit in MBR. http://sebastian-plotz.blogspot.com/