Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
Well if you ever change your mind Emerson, I'd still love to read it
Anyhow, and after much tango with efibootmgr, I've managed to boot a kernel directly from UEFI! I left the CONFIG_INITRAMFS_SOURCE kernel config option blank, as from what I've read, you only need to put something between the double quotes if you actually want to embed an initrd image into the kernel (I think). In any case, it still booted up fine with leaving the CONFIG_INITRAMFS_SOURCE kernel config option blank.
I actually built two kernels, one that I've confirmed boots directly from UEFI without any embedded parameters (I used efibootmgr to tell the UEFI firmware to pass the kernel parameters), and another one that was built with embedded kernel parameters. But I'm yet to test the one with the embedded parameters, so I'll have to let ya's know about that.
I'll make a start on adding a sub-section to the Tips and tricks section of the article about booting directly from UEFI without a bootloader probably over the weekend sometime, now that I've got the steps down on how exactly to do it.
So in any case, take that GRUB... you have been replaced! But the novelty will probably wear off, as it usually does...
Grub2 is great for binary distros which have automated kernel updates. As soon as you do something manually with your kernel Grub2 has no advantage any more. It is possible to write grub.cfg by hand and it is not complicated, just never run grub-mkconfig or it will overwrite your handcrafted file. Example grub.cfg with one entry:
Not too cumbersome, right?
You still need some middleman in case you are installing in one of those boxes with 32-bit EFI, 64-bit EFI stub kernel cannot be booted directly by 32-bit EFI. Then it can be rEFInd or Grub2, to my knowledge they both can do the job.
Edit: I just noticed you already have Grub2 manual entry in your article. I suggest using PARTUUID instead of UUID. Linux kernel can find root filesystem by PARTUUID without initrd. To find the root filesystem by UUID initrd is required. Makes difference if you want to drop initrd with your custom kernel.
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
Yeah, I'll keep GRUB around for the same reasons you said Emerson, as I do use a binary distro and kernel package updates do also update GRUB to add an entry for the new kernel. But I must say it's quite the novelty to use UEFI in-place of GRUB though Although, I'm not a Gentoo user, so I don't really know what the deal is with that as far as kernel updates are concerned.
Anyhow, I've just added the bit about booting directly from UEFI instead of using a bootloader, and have tested the method again today. But it would help if others could also verify the steps I've added for doing it. I must say it's been a fun little learning exercise, and I've learnt a few things about UEFI through this. So thanks for that suggestion Emerson!
(I couldn't get the kernel with the embedded kernel parameters to work but - so the bit I added to the wiki article only cover using the UEFI firmware itself to pass whatever kernel parameters to the kernel)
Quote:
Originally Posted by Emerson
...
Edit: I just noticed you already have Grub2 manual entry in your article. I suggest using PARTUUID instead of UUID. Linux kernel can find root filesystem by PARTUUID without initrd. To find the root filesystem by UUID initrd is required. Makes difference if you want to drop initrd with your custom kernel.
It sounds like yet another good idea from yourself Emerson, so I'll add something about PARTUUID/change it to like you suggest. Thanks again.
(I didn't see your edit until after I'd already logged out of the wiki though - since LQ accounts don't work in the wiki)
Manual kernel install is not exactly a Gentoo thing, Gentoo users do 'make install' also, which installs new kernel and renames it by version. Manual install is mere cp command, here is what I do in my desktop.
This way my kernel has always the same name and there is never need to reconfigure bootloader, or mess with efibootmgr.
Edit: You could add a warning about 32-bit EFI firmwares, I lost good many hair trying to figure out why my Intel NUC won't recognize my UEFI kernel, and finally I learned my NUC has 32-bit UEFI. Why Intel is doing that - I do not know. Also I hear some Apple hardware has 32-bit EFI firmware. As I wrote before, rEFInd and Grub2 can boot 64-bit kernels in EFI mode on this kind of hardware.
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
Quote:
Originally Posted by Emerson
...
Edit: You could add a warning about 32-bit EFI firmwares, I lost good many hair trying to figure out why my Intel NUC won't recognize my UEFI kernel, and finally I learned my NUC has 32-bit UEFI. Why Intel is doing that - I do not know. Also I hear some Apple hardware has 32-bit EFI firmware. As I wrote before, rEFInd and Grub2 can boot 64-bit kernels in EFI mode on this kind of hardware.
I did already put this bit at the end of the section about UEFI booting the kernel:
Quote:
64-bit UEFI firmware does not support executing 32-bit EFI executables.
but not sure that really covers what you're talking about though - and I don't personally have any experience at all with Intel NUC's myself. What content would you suggest?
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
Thanks Emerson. I've changed the bit that I quoted above about 32-bit UEFI not booting 64-bit EFI executables to just that. I've also changed the bits about GRUB and LILO to include PARTUUID instead of the filesystem UUID.
Again, it would be nice if people could verify the bit about booting kernels directly from UEFI, and provide some feedback on that.
Again, it would be nice if people could verify the bit about booting kernels directly from UEFI, and provide some feedback on that.
A slackware huge kernel on hard metal, with root=/dev/ kernel option compiled into it and copied to the efi partition as vmlinuz.efi. I used the firmware/bios "boot from file" option and it booted it with no problems. I'm now attempting to use an initrd in a vm, as it is more involved and I don't won't to brick my system with a bad command to the firmware/bios.
Followed https://wiki.archlinux.org/index.php...ng_for_EFISTUB
In a vm, copied the kernel and initrd.gz to EFI/BOOT/ and renamed kernel as BOOTX64.EFI used efibootmgr to submit the entry in the firmware/bios according to the link, booted like a charm. As far as hard metal is concerned it will probably be mixed results for not all manufacture firmware is the same.
If you rebuilding a stock kernel and paring it down to as small of a kernel one can get it,
this option comes in handy to keep from damaging the default install of /lib/modules/<kernel version> if make modules_install is ran.
Code:
General setup --->
() Local version - append to kernel release │
[ ] Automatically append version information to the version string
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
colorpurple21859,
Where you talking about the steps in the wiki article in post #158 (assumed you where before seeing your following posts above)? As I was asking if others could try the steps I wrote in the wiki article itself about booting directly from UEFI. Does it work for you?
Although, I did figure it out through both posts by you guys in this thread in combination with the Arch Linux (the page you linked to above) and Gentoo wiki's.
I have suggestion.
please add information about initrd error, because after initrd error system not boot anymore.
wiki has very many kernel page, please remove old (2.6).
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Original Poster
Rep:
colorpurple21859,
Wouldn't be able to get your thoughts about the bit in the article about booting directly from UEFI would I? Did it work for you, following the steps in the article itself?
I also have to apologize, as I wrote "where" instead of "were" in my last post, my apologies for that once again
Wouldn't be able to get your thoughts about the bit in the article about booting directly from UEFI would I? Did it work for you, following the steps in the article itself?
yes I was able to boot a kernel stub directly from the uefi firmware, used the huge kernel and add a root=/dev/???. No bootloader of any sort was used,
I followed the link in post #159 to add a kernel with an initrd and root option in the firmware bios, using a guest in vbox. I was also able to get it to boot without a bootloader of any sort.
I used a recompiled slackware kernel as a test.
Last edited by colorpurple21859; 02-11-2021 at 03:47 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.