You are not logged in.

#1 2012-08-30 03:52:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

[Solved] EFI Stub Loader: efibootmgr entry issues

So I have been using bios/gpt Grub2 on my Lenovo E430 (Pheonix SecureCore Tiano) up until today.  I have been reading quite a bit lately about the EFI Stub Loader and noticed that in an article on the "Rod's Books" site, Rod mentioned that the most reliable way he has found to boot Linux is using the EFI Stub Loader. This piqued my interest, and I have decided to give it a try. 

I had made an EFI System Partition when I installed Arch for just this case.  So I had it ready to go on sda1, filesystem and everything.  I mounted it to /boot/efi in order to preserve my bios settings, created /boot/efi/EFI/arch and copied the kernel and intramfs over to that directory, appending .efi to the kernel name as instructed by the wiki.  I then downloaded and copied Shell.efi to the root of my ESP (/boot/efi/Shell.efi) also as instructed by the wiki.  This is so that I could test that all kernel parameters woked before making a boot manager entry.

So I booted into the arch installer in uefi mode and added the Shell with

# efibootmgr -c -L "UEFI Shell" -l '\Shell.efi'

 
After this I booted into the shell and used that environment to successfully boot into Arch using the stub loader. 

fs0: \EFI\arch> vmlinuz-linux.efi root=/dev/sdb4 ro add_efi_memmap initrd=\EFI\arch\initramfs-linux.img quiet

So far so good!

But when I went to put the same parameters in the efibootmgr entry using the --append-binary-args it didn't work

# echo "root=/dev/sdb4 ro add_efi_memmap initrd=\\EFI\\arch\\initramfs-linux.img quiet" | iconv -f ascii -t ucs2 | efibootmgr -c -g -L "Archlinux" -l '\EFI\arch\vmlinuz-linux.efi' --append-binary-args - 

I modeled this entry after the example from Rod's Books, trying various things like "root-/dev/disk/by-uuid" and using single backslashes in the "echo" command, as well as taking it down to just "root", "ro", and "initrd" but everytime it tells me that it cannot read the initrd file. 

I wish I could supply more debug info, but since it occurs before anything even happens, I don't think there is anything.  Does anyone know why my initramfs is readable when booting from the shell but not from a bootloader entry?

I am perplexed, and any help would be greatly appreciated.

Last edited by WonderWoofy (2012-08-30 23:21:55)

Offline

#2 2012-08-30 04:17:27

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Maybe because in your shell you used initramfs-linux.img and in the boot entry initramfs-linux.efi ?


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2012-08-30 04:54:40

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Only the kernel needs to be .efi, hence my kernel is named vmlinuz-linux.efi.  The efi is needed for the actual program being launched, which in this case is the kernel.  Hence, it works when I use the Shell.efi. 

So I guess what I am asking is, have I formated something incorrectly in my efibootmgr entry, or is there something funny about my uefi firmware?

Offline

#4 2012-08-30 05:06:06

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

In your code snippets you used different extensions for the ramdisk image. The kernel name is fine.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2012-08-30 05:08:51

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Ahhhh I see what you are saying.... yeah that was just a typo in my example.  That wasn't copy and pasted from an actual entry.  I'll fix it in the post, thanks.  Good eyes though.

So you think that an entry like that *should* work though?  I can see nothing wrong with what I have there (as long as it is initramfs-linux.img)

Offline

#6 2012-08-30 05:15:39

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

So I just added this entry and I am about to reboot and see if it works... I guess at least I have no confidence, so if it does, it will be extra great...

# echo "root=/dev/sdb4 ro add_efi_memmap initrd=\EFI\arch\initramfs-linux.img quiet" | iconv -f ascii -t ucs2 | efibootmgr -c -g -L "Archlinux UEFI" -l '\EFI\arch\vmlinuz-linux.img' --append-binary-args -

BTW, this one was copy and pasted.

Offline

#7 2012-08-30 05:18:21

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

I can't see anything wrong. Except you'll have to use double backslashes.

$ echo "root=/dev/sdb4 ro add_efi_memmap initrd=\EFI\arch\initramfs-linux.img quiet"
root=/dev/sdb4 ro add_efi_memmap initrd=\EFIrch\initramfs-linux.img quiet

Last edited by progandy (2012-08-30 05:20:21)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#8 2012-08-30 05:22:28

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Yeah, I figured doing something different was worth a try...


Edit: So I used double backslashes in the command line parameters, as well as trying various combinations of double and single backslashes in the efibootmgr command with and without quotes around it (ie '\\EFI\\arch\\vmlinuz-linuz.efi').  None of them worked, but two variations got me again the the point where it says "Failed to open initrd file" where it just gets stuck.

I am going to take a little break from this project and go to bed.  I will pick back up in the morning before work.  Thanks for your input progandy, if you have any more ideas, I would love to hear about them.

Last edited by WonderWoofy (2012-08-30 05:39:43)

Offline

#9 2012-08-30 20:29:47

89c51
Member
Registered: 2012-06-05
Posts: 741

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Don't you need a parameter --disk that specifies where the loader is?? ie /dev/sd(whatever)

Last edited by 89c51 (2012-08-30 20:30:12)

Offline

#10 2012-08-30 20:42:45

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

that is a really good point!  I knew there must be *something* I was f*cking up!

Offline

#11 2012-08-30 21:06:34

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

okay, so that didn't help.  I am still getting the "Unable to open initrd file"... though I probably do, in fact, need to include the --disk and --part options to the command, especially since I have two drives and therefore two ESP's (one unused and blank)


Edit: so this is what I tried

# echo "root=/dev/sdb4 ro add_efi_memmap initrd=\\efi\\arch\\initramfs-linux.img quiet" | iconv -f ascii -t ucs2 | efibootmgr --create --gpt --disk /dev/sda --part 1 --label "Archlinux" --loader '\efi\arch\vmlinuz-linux.efi' --append-binary-args -

I also noticed an option w/ efibootmgr to "pass extra args as UCS-2 (defualt is ASCII)" so I tried w/ and w/o the relevant flag (-u), not go either way.

Last edited by WonderWoofy (2012-08-30 21:11:28)

Offline

#12 2012-08-30 21:30:37

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

So just as a test, I installed rEFInd, made an entry with efibootmgr, created \efi\arch\refind_linux.conf with the SAME cmdline parameters, and it booted just fine. 

I am just really perplexed now, and think it has to be something with the UEFI firmware on my machine.  I know that cfr had an issue with his Lenovo x220, but he solved it by making his ESP FAT16, and my system is recognizing FAT32 just fine.  But maybe that speaks to the quirks still present from machine to machine, manufacturer to manufacturer.

So even though I now have two working implementations, this is still not ideal.  though rEFInd is not a bootloader, as a boot manager, I still feel like I am just chainloading one things to another unnecessarily. 

But I guess if that is the only way I can get it to boot, then it is actually necessary, isn't it?

Offline

#13 2012-08-30 22:04:17

89c51
Member
Registered: 2012-06-05
Posts: 741

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

WonderWoofy wrote:

okay, so that didn't help.  I am still getting the "Unable to open initrd file"... though I probably do, in fact, need to include the --disk and --part options to the command, especially since I have two drives and therefore two ESP's (one unused and blank)


Edit: so this is what I tried

# echo "root=/dev/sdb4 ro add_efi_memmap initrd=\\efi\\arch\\initramfs-linux.img quiet" | iconv -f ascii -t ucs2 | efibootmgr --create --gpt --disk /dev/sda --part 1 --label "Archlinux" --loader '\efi\arch\vmlinuz-linux.efi' --append-binary-args -

I also noticed an option w/ efibootmgr to "pass extra args as UCS-2 (defualt is ASCII)" so I tried w/ and w/o the relevant flag (-u), not go either way.

you use sdb4 in the begining and sda in the --disk

also i think you should use double \ in the loader as well

could you also post your fstab?

Offline

#14 2012-08-30 22:15:11

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

I have two drives, my ESP is on sda1 while my actual root partition is sdb4.  Since the part after the efibootmgr command is just regular shell command, rather than being stdin/stdout, single backslashes are okay as long as I surround it with single or double quotes.  If there are no quotes, the first backslash is teh delimiter.

Don't worry though, I too thought that maybe I was fudging this up, so i tried double backslashes with and without both single and double quotes and single backslashes with and without single and double quotes.  The only time it even gets to the point of telling me it is unable to open initrd file is when I use double backslashes without quotes or single backslashes with either double or single quotes.

To verify my use of sdb4 and so forth, here is my fstab as requested:

# <file system>	                          <dir>	                         <type>   <options>	                                <dump>   <pass>
 tmpfs	                                   /tmp	                          tmpfs    nodev,nosuid,noatime                           0        0
 UUID=2cef9260-c269-4b71-96a5-e1224002b9ea /var                           ext4     defaults,noatime,discard                       0        2      # sdb5
 UUID=75c42198-6b6b-4474-b81f-c2f986d93877 /                              ext4     defaults,noatime,discard                       0        1      # sdb4
 UUID=12a7eda8-a9b0-4803-ac76-88c5999e02bc /boot                          ext2     defaults,noatime                               0        2      # sdb3
 UUID=bd9d8185-42be-406b-bd4d-d4cca704da91 swap                           swap     defaults,noatime                               0        0      # sda4
 UUID=9b7b8212-64f4-42e6-be22-5d80c57a6d36 /home                          ext4     defaults,noatime,discard                       0        2      # sdb6
 UUID=8f81909c-713d-4c12-bf41-2226ad303d03 /home/hdd                      ext4     defaults,noatime                               0        2      # sda5
 UUID=F683-F6F7                            /boot/efi                      vfat     defaults,noatime                               0        0      # sda1

Pretty isn't it?


Edit: also, as you can see I use uuid's, so I labeled each uuid with sdX if you scroll right.

Last edited by WonderWoofy (2012-08-30 22:16:14)

Offline

#15 2012-08-30 22:18:43

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Here is more confirmation... maybe I really an just f*ing something royally!

$ lsblk -f

NAME   FSTYPE LABEL           UUID                                 MOUNTPOINT
sda                                                                
├─sda1 vfat   SYSTEM_DRV      F683-F6F7                            /boot/efi
├─sda2                                                             
├─sda3 ntfs   Windows7_OS     BA82894B82890CD7                     
├─sda4 swap   swap            bd9d8185-42be-406b-bd4d-d4cca704da91 [SWAP]
├─sda5 ext4   media           8f81909c-713d-4c12-bf41-2226ad303d03 /home/hdd
├─sda6 ext3   bkup            a75d496c-0140-44a5-9450-18b4265cda5f 
└─sda7 ntfs   Lenovo_Recovery C83E0BFC3E0BE1F4                     
sdb                                                                
├─sdb1 vfat                   BD10-4621                            
├─sdb2                                                             
├─sdb3 ext2                   12a7eda8-a9b0-4803-ac76-88c5999e02bc /boot
├─sdb4 ext4                   75c42198-6b6b-4474-b81f-c2f986d93877 /
├─sdb5 ext4                   2cef9260-c269-4b71-96a5-e1224002b9ea /var
├─sdb6 ext4                   9b7b8212-64f4-42e6-be22-5d80c57a6d36 /home

I think I have rebooted my system more in the last few days than the sum of the rest of the time I have had it.

Last edited by WonderWoofy (2012-08-30 22:20:04)

Offline

#16 2012-08-30 22:20:58

caskale13c
Member
From: Colleyville, TX, US
Registered: 2008-12-29
Posts: 33

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

This is what workes for me.  In a cursory glance, the key difference I see is that I used single slashes.

# echo "initrd=\arch\initramfs-linux.img root=/dev/vg/arch ro quiet" | iconv -f ascii -t ucs2 | efibootmgr --create --disk /dev/sda --part 1 --label "Arch Linux" --loader '\arch\vmlinuz-linux.efi' --append-binary-args -

Offline

#17 2012-08-30 22:28:26

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Unfortunately, I already tried that, and when I do, it doesn't even get me to the point where it tells me that it cannot load the initrd...

Since I am getting to a point where it is trying to load the initrd, it makes me think that there must be something wrong with the firmware itself, like a bug or seomthing.  It doesn't make sense that I can load the initramfs from the uefi shell as well as from parameters passed to refind, but cannot with the same paramaters from a bootloader entry.

Offline

#18 2012-08-30 22:40:33

89c51
Member
Registered: 2012-06-05
Posts: 741

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Try adding rootfstype=ext4 just in case.

# echo "root=/dev/sdb4 rootfstype=ext4 ro add_efi_memmap initrd=\\EFI\\arch\\initramfs-linux.img quiet" | iconv -f ascii -t ucs2 | efibootmgr --create --gpt --disk /dev/sda --part 1 --label "Archlinux" --loader "\\EFI\\arch\\vmlinuz-linux.efi" --append-binary-args -

Offline

#19 2012-08-30 22:41:03

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

okay, seeing if compiling those options into the kernel will make a difference.  I really don't want to have a compile a new kernel everytime there is a release, but I just want to see if it works.

Offline

#20 2012-08-30 22:41:20

caskale13c
Member
From: Colleyville, TX, US
Registered: 2008-12-29
Posts: 33

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

WonderWoofy wrote:

I had made an EFI System Partition when I installed Arch for just this case.  So I had it ready to go on sda1, filesystem and everything.  I mounted it to /boot/efi in order to preserve my bios settings, created /boot/efi/EFI/arch and copied the kernel and intramfs over to that directory, appending .efi to the kernel name as instructed by the wiki.  I then downloaded and copied Shell.efi to the root of my ESP (/boot/efi/Shell.efi) also as instructed by the wiki.  This is so that I could test that all kernel parameters woked before making a boot manager entry.

So, if you created /boot/efi/EFI/arch, then you need to reference the EFI directory in the paths.  At least I think I rememebr having to do that when I set it up the first time.  I read somewhere that that it was not longer necessary to have the EFI directory in your efi partition.  I am pretty sure that when I removed that EFU directory, I had to go back and remove the EFI from my UEFI entries.  So you have 2 waysw to try this:
1. move arch to the root of the efi partition and leave your commands alone
2. adjust the command to reference the path properly including the EFI dir.

Hope that works for you

Edit:  Now I see that you did reference EFI.  Not sure what I was looking at before when I thought you had left it off.

Last edited by caskale13c (2012-08-30 22:45:44)

Offline

#21 2012-08-30 23:07:48

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

Yeah, unfortunately as far as I can tell, everything (in terms of referencing the \EFI and the paths and such) are correct.  But maybe if I put the initramfs in the root of the ESP, maybe that will work.  I don't see why it wouldn't be working as is, but hey, worth a try I guess.  I have tried everything else I can think of, so I figure why not this.

Offline

#22 2012-08-30 23:21:32

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

IT WORKED!!!

I put it in the root of the EFI System Partition, and like f*cking magic that sh*t totally worked!  @caskale13c you inadvertantly pointed m in the right direction! 

Thanks so much progandy, 89c51, and caskale13c!  I appreciate the help and patience.  It sill perplexes me why this would work and having its own directory wouldn't.  But working is working, so what the heck, I'm gonna go with it.

Offline

#23 2012-08-31 00:12:49

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

One more thing to add... I noticed that many people like to use the root=/dev/disk/by-label method of identifying.  So I wanted to use /dev/disk/by-uuid, figuring it should work as well as by-label would.  But for whatever reason (and maybe this is only applies to Lenovo E430's) it did not like that method of input.  But it does happily accept "root=UUID=xxxxxx-xxxx-xxxx-xxxx-xxxxxxx".

Just thought that might help another frusterated soul...

Happy UEFI-ing!

Offline

#24 2013-02-20 21:28:21

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

I'm bumping this because I think I found out why this wasn't working for OP. I was having the exact same trouble, but a careful examination with efibootmgr revealed the culprit

# efibootmgr -v
...
.i.n.i.t.r.d.=.\.E.F.I...r.c.h.\.i.n.i.t.r.a.m.f.s.-.a.r.c.h...i.m.g...

See the problem? The \a in the path to the image was interpreted as an escape character! Weirdly, this occurred even with the double backslashes.

The solution is to make it a triple backslash for just that character:

# echo "root=UUID=$(blkid /dev/sda1 -o value -s UUID) ro rootfstype=ext4 add_efi_memmap initrd=\\EFI\\\arch\\initramfs-arch.img" | iconv -f ascii -t ucs2 | efibootmgr -c -g -d /dev/sda -p 1 -L "Arch Linux" -l '\EFI\arch\vmlinuz-arch.efi' -@ -

I shall update the wiki accordingly.

Offline

#25 2013-02-21 00:08:40

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [Solved] EFI Stub Loader: efibootmgr entry issues

silverhammermba wrote:

The solution is to make it a triple backslash for just that character:

You should just use "echo -E". Some shells implement the -e (enable backslash escapes) option as default instead of -E (disable backslash escapes)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB