Gentoo Archives: gentoo-user

From: Sid Spry <sid@××××.us>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] EFI booting problem - understanding it
Date: Fri, 03 Jul 2020 20:58:13
Message-Id: ad63ee1b-6284-443b-ad6c-29fd36e29035@www.fastmail.com
In Reply to: Re: [gentoo-user] EFI booting problem - understanding it by Peter Humphrey
1 On Fri, Jul 3, 2020, at 9:52 AM, Peter Humphrey wrote:
2 > On Friday, 3 July 2020 03:05:34 BST Andrew Udvare wrote:
3 > > On 02/07/2020 06:56, Peter Humphrey wrote:
4 > > > But then,
5 > > > # bootctl set-default 30-gentoo-5.7.7.conf
6 > > > Failed to update EFI variable: Invalid argument
7 > >
8 > > Probably the kernel is blocking write access to EFI. This is on purpose
9 > > for safety as you can damage your firmware quite easily. systemd-boot
10 > > and others do not have this restriction.
11 >
12 > Is there some way for me to remove this restriction temporarily?
13 >
14 > > You also should be careful writing to the EFI too much as the NVRAM flash may
15 > > not be of high quality.
16 >
17 > Yes, I do only write to it when I have to. I hope Asus would use decent-
18 > quality components though.
19 >
20
21 They may not have a choice. The flash memory made for "embedded" applications can be very low quality.
22 Typically I see write capability maxing out at 100k. Some devices only offer 10k due to inappropriate cost optimization. These numbers can be particularly visible if there is no wear levelling, which there usually isn't.
23
24 Anything higher seems to be only available for storage applications.
25
26 > > https://lwn.net/Articles/674940/
27 >
28 > Interesting - thanks.
29 >
30 > > You can try using `chattr -i` against the files like:
31 > >
32 > > chattr -i /sys/firmware/efi/efivars/Boot*
33 > >
34 > > Then you can try with bootctl and others, but this is not guaranteed to
35 > > work.
36 >
37 > Those files were already among the 17 that were mutable. It seems I
38 > need to find
39 > which of the other 117 files I need to make mutable.
40 >
41 > > On my ASUS motherboard I haven't been able to write to EFI variables
42 > > from within Linux for a long time. I have to add my keys in the BIOS and
43 > > set the default in systemd-boot.
44 >
45 > Looks like I'm in the same boat. Except that setting the default in systemd-
46 > boot is exactly what I can't do!
47 >
48 > > The logic to write to a file in efivars is here:
49 > >
50 > > https://github.com/torvalds/linux/blob/master/fs/efivarfs/file.c#L15
51 > >
52 > > If you use strace with bootctl you'll probably see one of these errno
53 > > values.
54 >
55 > I think what I'm seeing comes from this:
56 >
57 > if (attributes & ~(EFI_VARIABLE_MASK))
58 > return -EINVAL;
59 >
60 > Perhaps I should just stop here and revert to setting the default at the UEFI
61 > boot-choice screen.
62 >
63 > Many thanks for your help, Andrew.
64 >
65 > --
66 > Regards,
67 > Peter.
68 >
69 >
70 >
71 >
72 >