You are not logged in.

#1 2016-09-09 21:31:13

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

[Solved] Parsing EFI variables

I have a feeling I'm missing something obvious but I haven't been able to find an answer either with google or in the wiki.

I've been trying to find a tool that parses efi variables, as in printing in clean plaintext the contents of a boot variable. I know I can use efivar -p to dump the contents of the variable (or just access it directly in /sys/firmware/efi/efivars) but it's full of what seems to be padding and you have to have a good idea of what is what.

I was wondering is there is any tool that will parse the contents of the variable and prints the label, loader, extra arguments and any other useful info in a clear easy to read (and copy paste) way.

Edit:
Typo in title

Last edited by R00KIE (2016-09-09 21:47:39)


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#2 2016-09-10 21:37:44

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 452

Re: [Solved] Parsing EFI variables

efibootmgr -v?

I'm not entirely sure I understand what you're asking. If I got it wrong, then please ignore me


AMD Ryzen 7 2700X | Asus TUF X570-Plus | GeForce GTX 2070S Super | 16G Ram | KDE Plasma | Stock Kernel
Until linuxcounter.com closed, I was registered linux user #560427

Offline

#3 2016-09-10 22:57:53

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Solved] Parsing EFI variables

That's close, better than the output of efivar but it still has some sort of padding, I would be nice to get a "clean" output.

Example output;

Boot0000* SED PBA	HD(1,GPT,5172ab62-b344-4f2a-8036-0904c95233f3,0x800,0xf7df)/File(\vmlinuz-linux)i.n.i.t.r.d.=./.i.n.t.e.l.-.u.c.o.d.e...i.m.g. .i.n.i.t.r.d.=./.l.i.n.u.x.p.b.a...i.m.g. .l.i.b.a.t.a...a.l.l.o.w._.t.p.m.=.1. .l.o.g.l.e.v.e.l.=.0. .q.u.i.e.t.

As you can see it is full of dots, it should be possible to get just plaintext. Maybe it is because I have added the extra parameters as ucs-2 as described in the wiki[1].

[1] https://wiki.archlinux.org/index.php/EFISTUB#efibootmgr


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#4 2016-09-11 00:10:20

HiImTye
Member
From: Nanaimo, BC, Canada
Registered: 2012-05-09
Posts: 1,061

Re: [Solved] Parsing EFI variables

you can just edit those out with, for instance, sed or awk, and likely awk is the tool you should look at since you want to parse the variables anyway

Offline

#5 2016-09-11 13:54:01

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Solved] Parsing EFI variables

The following does what I've been after

efibootmgr -v | awk 'match($0,/(.*File\(\\.*\))(.*)/,line){ line[2]=gensub(/(.)(\.)/,"\\1","g",line[2]); print line[1]" "line[2] }'

This will match only the entries where a file is loaded from disk, for what I want it is enough: easily copy paste extra parameters, loader and label.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB