LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-04-2021, 08:51 AM   #151
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063

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...
 
Old 02-04-2021, 10:59 AM   #152
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,665

Rep: Reputation: Disabled
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:
Code:
timeout=5

menuentry 'My latest kernel' {
    root=hd0,1
    linux /boot/bzImage root=/dev/sda2
}
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.

Last edited by Emerson; 02-04-2021 at 05:41 PM.
 
1 members found this post helpful.
Old 02-05-2021, 12:00 PM   #153
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
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 View Post
...
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)
 
Old 02-05-2021, 12:11 PM   #154
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,665

Rep: Reputation: Disabled
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.
Code:
mv /boot/EFI/Boot/gentoo.efi /boot/EFI/Boot/gentoo_pre.efi
cp /usr/src/linux/arch/x86_64/boot/bzImage /boot/EFI/Boot/gentoo.efi
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.

Last edited by Emerson; 02-05-2021 at 12:24 PM.
 
Old 02-05-2021, 12:36 PM   #155
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Emerson View Post
...
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?
 
Old 02-05-2021, 12:54 PM   #156
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,665

Rep: Reputation: Disabled
You have it backwards, I am talking about 32-bit firmware not executing 64-bit EFI executables.
 
Old 02-06-2021, 08:36 AM   #157
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
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.
 
Old 02-06-2021, 11:48 AM   #158
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
Code:
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.
 
1 members found this post helpful.
Old 02-06-2021, 05:29 PM   #159
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
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.
 
Old 02-06-2021, 06:56 PM   #160
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
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
 
Old 02-07-2021, 07:12 AM   #161
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
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.
 
Old 02-10-2021, 11:19 PM   #162
JSB
Member
 
Registered: Dec 2020
Posts: 102

Rep: Reputation: 22
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).
 
Old 02-11-2021, 03:21 AM   #163
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Original Poster
Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
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
 
Old 02-11-2021, 03:42 AM   #164
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,392

Rep: Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594Reputation: 1594
Quote:
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.
 
  


Reply

Tags
development, kernel, lq wiki



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Web Served 7: Wiki wiki wiki! LXer Syndicated Linux News 0 02-19-2013 09:10 PM
Tip: for answers, "wiki, wiki!" sundialsvcs Linux - Newbie 1 01-18-2006 02:40 PM
Wiki: Show Printable Version / printer friendly version / wiki page setup Emmanuel_uk LQ Suggestions & Feedback 1 10-24-2005 08:09 AM
tutorial on wiki wiki web alix123 Programming 1 04-02-2005 02:08 PM
wiki: supposed to use the same wiki namespace? liquigel LQ Suggestions & Feedback 1 03-07-2004 10:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration