Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
UEFI not loading initramfs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Thu Jun 08, 2017 6:26 am    Post subject: UEFI not loading initramfs Reply with quote

eccerr0r wrote:
If you're insisting on using direct EFI boot without a bootloader,
That's what I do.

eccerr0r wrote:
you will have to embed the initramfs inside the kernel (CONFIG_INITRAMFS_SOURCE).
My fresh installation (still without lvm) can use the dracut generated initramfs with CONFIG_INITRAMFS_SOURCE="". But I had to learn that efibootmgr, for the initramfs attribute has to be given the -u, (--UCS-2) option:
https://wiki.gentoo.org/wiki/EFI_stub_kernel#Optional:_Initramfs wrote:
#efibootmgr --create --part 1 --label "Gentoo" --loader '\efi\gentoo\vmlinuz-4.9.16-gentoo.efi' -u initrd='\efi\gentoo\initramfs.img'
Would this really need to be handled differently with lvm?

eccerr0r wrote:
The command line needed will depend on what initramfs you're using.
You mean CONFIG_CMDLINE, as already mentioned by szatox "(assuming you use genkernel's initramfs)"?
This may be most important information for me that I didn't see anywhere on the various wikis or other sources of documentation.


eccerr0r wrote:
But I don't know if there's any howtos out there with embedded initramfs though it should work...

Having a laptop be able to suspend/hibernate in Windows has no bearing of being able to do the same in Linux...
Good to know. Thanks for the warning. So I'll have to carefully check.

Edit:
Changing subject. - Moderators/Administrators, please cut here and move to a new topic.


Last edited by charles17 on Wed Jun 14, 2017 9:32 am; edited 2 times in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54098
Location: 56N 3W

PostPosted: Thu Jun 08, 2017 7:29 am    Post subject: Reply with quote

Split from LVM recommendations at the request of the OP -- NeddySeagoon

charles17,

Grub2 has become its own operating system so that it can support loading the kernel and optionally, the initrd from all sorts of exotic installs.
That's still all it does. Loads the kernel, loads the initrd, and exits by jumping to the kernel start address.
Then its just the kernel and the optional initrd to bring up the system. Just like it was in the days of running loadlin from a floppy disc :)

When you are bringing up a new system in a new configuration, its probably a bad idea to go for an EFI stub kernel with embedded initrd and embedded kernel commanh line.
Keep in mind it may not work first time and you may want to change things.
If you use a bootloader while you get it right, you can change the bits independently. With the EFI stub approach, its a kernel rebuild.

Start with a bootloader, then migrate to an EFI stub. Much like wifi. Start with modules, built it all in later.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.


Last edited by NeddySeagoon on Wed Jun 14, 2017 8:37 am; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Thu Jun 08, 2017 8:30 am    Post subject: Reply with quote

Looks like EFI does support some sort of extended attributes to plug in a location for the initramfs, so if it's been working, then there's no need to embed it. The kernel just needs some way to get at the initramfs contents.

I still think that grub is a good idea, at the very least you can muck with your root= option if it doesn't work the first time and not need to rebuild your kernel again. I was really disappointed with UEFI boxes that omit EFI shell (namely, pretty much all x86/amd64 boxes) because having EFI shell in firmware allows preboot manipulation of kernel files and setting kernel options (yes, can even rename, copy, delete files like having a sort of MSDOS in ROM). What's the next best thing to having a firmware shell to manipulate boot images?

Grub/Grub2.

Can't manipulate files, but can at least choose boot images and specify options before OS boot.

I've been using my own initramfs for booting my LVM over MDRAID (0.9 -- so at least half of the problem is autodetected). It happens to use root=XXX instead of a real_root=XXX as apparently the kernel will ignore root=XXX when initramfs is available (sort of makes sense!)... but it depends on how the initramfs is written as to how it deals with using your real root device.

(Incidentally, I had to code in real_init=YYY so my custom initramfs could boot either a sysvinit or a systemd rootfs... did not want autodetect...)
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Thu Jun 08, 2017 8:41 am    Post subject: Reply with quote

NeddySeagoon wrote:
Keep in mind it may not work first time and you may want to change things.
If you use a bootloader while you get it right, you can change the bits independently. With the EFI stub approach, its a kernel rebuild.

I am aware of this and kernel rebuild is fast enough.

NeddySeagoon wrote:
... Much like wifi. Start with modules, built it all in later.
Wifi works out of the box from the very first reboot thanks to dhcpcd and wpa_supplicant-2.6-r1 using the -M option and a functional /etc/wpa_supplicant/wpa_supplicant.conf copied from another laptop.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54098
Location: 56N 3W

PostPosted: Thu Jun 08, 2017 12:07 pm    Post subject: Reply with quote

eccerr0r,

Your custom initrd should mount /proc and parse whatever it needs from /proc/cmdline

If you want to use root=, you can.
The kernel no longer needs root=/dev/ram0 to find the initrd, so there is no need to use a special term like real_root.
That dates from the days when both were needed unless the initrd had some other way of finding the real root.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Fri Jun 09, 2017 4:19 pm    Post subject: Reply with quote

Problems.

My kernel cannot access the disk. Or is it the initramfs that fails? On boot I am getting those 8 little penguins as normal and then:
Code:
010e                4096 ram14  (driver?)
010f                4096 ram15  (driver?)
0800           250059096 sda  driver: sd
followed by partition details and
Code:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
The kernel has ahci as shown here. So I expect it to work as it does on the non-LVM partition. I can boot the lvm installation using sysresccd, but not with my own kernel+initramfs.
What am I missing? The disk is a SATA SSD (SAMSUNG SSD SM84).
Here is the kernel .config
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54098
Location: 56N 3W

PostPosted: Fri Jun 09, 2017 4:55 pm    Post subject: Reply with quote

charles17,

Your kernel can see sda, so the panic error message may be misleading.
Does it list all your partitions or only one?

Your initrd should have a shell. After the panic, it should offer to drop you to the shell.
Go into the shell and check that all your hard drives and partitions have been detected.

Then check the content of /dev/mapper/
All your logical volumes should be there.
If not try
Code:
/sbin/lvm lvchange -ay
and check again.
Post any error messages.

I suspect that your initrd and the initrd init script between them are not starting your logical volumes.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Fri Jun 09, 2017 6:23 pm    Post subject: Reply with quote

NeddySeagoon wrote:
charles17,

Your kernel can see sda, so the panic error message may be misleading.
Does it list all your partitions or only one?

Yep, it lists all partitions.

NeddySeagoon wrote:
Your initrd should have a shell. After the panic, it should offer to drop you to the shell.
Go into the shell and check that all your hard drives and partitions have been detected.

No shell here :-( (although initramfs generated by genkernel).
How can I know if initramfs gets loaded at all? That's all new stuff to me.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Fri Jun 09, 2017 7:11 pm    Post subject: Reply with quote

If the kernel panicked, it would not give you a shell :(

If it didn't scroll off the screen during initramfs running, looks like it did not initialize LVM (initramfs is needed)... The initramfs did not load. The initramfs should have a root and it should have loaded it.

Go check your efibootmgr and make sure the initramfs is specified properly... I'd rather use grub2 for this kind of stuff, it handles the initramfs and you can specify it preboot during debug, instead of postboot.

This is sort of where I am lost because I have never used genkernel initramfs... though first check of your .config seems like ti has what's necessary for generic initramfs usage...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?


Last edited by eccerr0r on Fri Jun 09, 2017 7:20 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54098
Location: 56N 3W

PostPosted: Fri Jun 09, 2017 7:19 pm    Post subject: Reply with quote

charles17,

NeddySeagoon wrote:
As your kernel is fully modular, modules are required to be loaded to see your HDD at all.
The kernel reports all your drives and partitions.

It follows that the initrd was loaded, the kernel mounted it as root and loaded the modules it needed to access your HDD.

I'm not sure where I got that from ... too many LVM problems on the go.

Your initrd has a shell, even if its only busybox. You need to take the initrd apart, fix its init script, so that when root fails to mount, it drops you to a shell, then put the initrd back together again.
With the initrd embedded in your kernel, that's hard. Its nol a fix either, its required for diagnostics

Heres an initrd init script that boots one of my KVMs
The key bits are
Code:
 rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec /bin/sh
}
...
# mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root"


When the automatics fail you need to be able to poke about.

I'm not a fan of automatic anything. When it breaks, you are left in the dark with no understanding of how it works.
So much so, I roll my own initrds.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Fri Jun 09, 2017 8:17 pm    Post subject: Reply with quote

Yes, it seems like I should make friends with grub2 again, at least for the initramfs stuff. I doubt that initramfs has ever got passed to the kernel - or maybe it's simply not been loaded by my kernel.
Instead of studying tons of documentation about handling those tools for creating an initramfs I should have better invested my time in learning to create my own one.

Your initrd init script, NeddySeagoon, does not look too complicated. I will read it more in detail this weekend.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Fri Jun 09, 2017 8:26 pm    Post subject: Reply with quote

I may also be wrong here. It is possible that the genkernel initramfs is what prints out that block devices list and it actually does get loaded (but lvm does not get initialized)?

An initramfs is basically another root filesystem that's tiny (generally less than 8MB compressed) that for all intents and purposes, a filesystem whose sole purpose is to set up the machine before it switches over to the real root filesystem.

Again I've never used genkernel but it probably requires a flag to indicate you want lvm support as it would need to copy lvm binaries to the initramfs so it can set it up (if you don't need lvm, it will bloat your initramfs hence the flag, appear to be --lvm). Just wanted to make sure this happened?

oh btw, the initramfs is not loaded by the kernel if you didn't embed it. The bootloader needs to load it, and the kernel needs to be pointed to it. Then again even if you embed it, the kernel didn't "load" it as the bootloader loaded the kernel :) The hope is that the bootloader knows how to at least copy this first root filesystem into ram even if the bootloader does not know how to fully or at all handle any devices or drives.

Oddly enough it showed /dev/sda but not break out individual partitions...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Mon Jun 12, 2017 12:28 pm    Post subject: Reply with quote

Of course, the initramfs has been created as described with --lvm and there also is dolvm in CONFIG_CMDLINE.
Meanwhile I am one little step further now. My EFI stub kernel alone can boot the non-LVM system but seems to to be unable to load the initramfs. Enabling CONFIG_SATA_AHCI_PLATFORM does not help. Maybe I have to enable much more options to male it work.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Mon Jun 12, 2017 3:23 pm    Post subject: Reply with quote

It's up to EFI I/O routines to load the initramfs (which also means the initramfs needs to be on the ESP), there is no kernel option to actually load the file (unless you embed it).
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Mon Jun 12, 2017 4:05 pm    Post subject: Reply with quote

You mean it's the EFI I/O routines doing something wrong? Or did I make wrong entries with efibootmgr?
What I have is bzImageLVM.efi and initramfsLVM.img both in EFI :
tree -L 3 /boot:
/boot
├── EFI
│   ├── Gentoo
│   │   ├── bzImageLVM.efi
│   │   ├── initramfsLVM.img
│   │   └── vmlinuz-4.9.16-gentoo.efi
│   ├── Microsoft
│   │   ├── Boot
│   │   └── Recovery
│   ├── refind
│   │   ├── icons
│   │   ├── keys
│   │   ├── refind.conf
│   │   └── refind_x64.efi
│   └── tools
└── refind_linux.conf
and
efibootmgr -v:
Boot0000* Gentoo LVM   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\Gentoo\bzImageLVM.efi)i.n.i.t.r.d.=.E.F.I.\.G.e.n.t.o.o.\.i.n.i.t.r.a.m.f.s.L.V.M...i.m.g.
Boot0003* Gentoo   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\Gentoo\vmlinuz-4.9.16-gentoo.efi)
Boot0004* rEFInd Boot Manager   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\refind\refind_x64.efi)

"Boot0003* Gentoo" comes up immediately, whereas "Boot0000* Gentoo LVM" fails
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Mon Jun 12, 2017 6:49 pm    Post subject: Reply with quote

What if you omit -u when you call efibootmgr when passing the initramfs?
I suspect it's something with the efibootmgr call...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Tue Jun 13, 2017 5:03 pm    Post subject: Reply with quote

eccerr0r wrote:
What if you omit -u when you call efibootmgr when passing the initramfs?

Same problem. Kernel panic and no initramfs console.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Tue Jun 13, 2017 7:27 pm    Post subject: Reply with quote

What does efibootmgr -v report now (wondering why the first \ disappeared...) ?
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Wed Jun 14, 2017 9:50 am    Post subject: Reply with quote

eccerr0r wrote:
What does efibootmgr -v report now (wondering why the first \ disappeared...) ?
Must have been a typo :-(
Just tested both versions:
efibootmgr -v | grep Gentoo:
Boot0000* Gentoo LVM   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\Gentoo\bzImageLVM.efi)initrd=\EFI\Gentoo\initramfsLVM.img
Boot0002* Gentoo LVM -u   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\Gentoo\bzImageLVM.efi)i.n.i.t.r.d.=.\.E.F.I.\.G.e.n.t.o.o.\.i.n.i.t.r.a.m.f.s.L.V.M...i.m.g.
Boot0003* Gentoo   HD(1,GPT,1729a003-cf0d-4bd4-88c9-cc24d8d418c4,0x800,0x2f000)/File(\EFI\Gentoo\vmlinuz-4.9.16-gentoo.efi)
None of i.n.i.t.r.d.=.\.E.F.I.\.G.e.n.t.o.o.\.i.n.i.t.r.a.m.f.s.L.V.M...i.m.g. or initrd=\EFI\Gentoo\initramfsLVM.img works.
Maybe initramfs to be loaded directly by UEFI needs certain content or certain format?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Wed Jun 14, 2017 3:11 pm    Post subject: Reply with quote

How about typing 'ro' first (yeah, trying to cheese this, but seeing if efibootmgr is doing something strange.)

#efibootmgr --create --part 1 --label "Gentoo" --loader '\efi\gentoo\vmlinuz-4.9.16-gentoo.efi' -u 'ro initrd=\efi\gentoo\initramfs.img'

Dangit I need to get some more EFI machines...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Fri Jun 16, 2017 11:44 am    Post subject: Reply with quote

eccerr0r wrote:
How about typing 'ro' first (yeah, trying to cheese this, but seeing if efibootmgr is doing something strange.)

#efibootmgr --create --part 1 --label "Gentoo" --loader '\efi\gentoo\vmlinuz-4.9.16-gentoo.efi' -u 'ro initrd=\efi\gentoo\initramfs.img'

Just tried - it doesn't change anything.

As I am not even getting the initramfs shell, isn't there some possibility for debugging the EFI boot itself, whatever hard-/soft-/firmware is involved?
From reading the sys-boot/refind ebuild (and /usr/portage/profiles/base/package.use.force) I can see it pulls-in >=sys-boot/gnu-efi-3.0.2. But no clue what I could do with it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum