UEFI bootmanager and writing to nvram

| Written by CodeAsm

I had some experience with installing Windows on my Lenovo Thinkpad E530 and later also Ubuntu as a multi-boot environment next to windows. It all works fine.And somehow I managed to install an uefi shell aswell, but after I got an SSD and installing windows and Ubuntu, I was unable to recreate a working uefi shell, the Uefi partition i created was stored on the SSD instead of the hdd.

I dont know if moving the files to a hdd partion has serios speed implications, but I want the freedom to replace the now "Data and personal files" disk anytime in the future without destroying the ssd boot options.

So, anyway. I think I fixed it by finding out how efibootmgr works, the man pages can be found here :http://linux.die.net/man/8/efibootmgr
And maybe using bcdedit you could do it from windows, but I had a hardtime getting acces to the uefi boot partition (linux is a lot easier if you happen to be Root)

So, basicly one can list all bootoptions stored inside the uefi nvram using just


You get the following result for example:

BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0004,0000,0001,0002,0003
Boot0000* UEFI Shell
Boot0001  Boot Menu
Boot0002* Windows Boot manager
Boot0003  Lenovo Diagnostics

but thats not all (if you are not root, add sudo) efibootmgr requires that the kernel support access to EFI non-volatile variables (through /proc/efi/vars on 2.4 kernels, /sys/firmware/efi/vars on 2.6 kernels). modprobe efivars should do the trick.

and to get more info: type -v (verbose)

efibootmgr -v

Now the output will be slightly bigger:

BootCurrent: 0013
Timeout: 0 seconds
BootOrder: 0004,0000,0001,0002,0003
Boot0000* UEFI Shell    HD(2,96800,32000,24d8753a-ba2c-4cda-8ef9-8e115d00d4f4)File(\EFI\Shell.efi)
Boot0001  Boot Menu   
Boot0002  Windows Boot manager
Boot0003  Lenovo Diagnostics

You properbly notice that my shell shows up with more info. You can find more info at the man page. but ill show you one for my ubuntu aswell windweos

Boot0013* ubuntu    HD(2,96800,32000,2ff9953a-ba4c-4cda-8ef9-8e235d01d4e4)File(\EFI\ubuntu\shimx64.efi)

so well, il explain what these entry mean, because maybe your say HD(1, ... something something

I exlained that My boot partition is stored on the SSD and I noticed in Linux that my SSD is a second drive device, the HDD is first, so no problem, sda and sdb under linux. sdb is my ssd.

But how was I supposed to add the second partition of my ssd? just /dev/sdb dint work and /dev/sdb2 also not.

-p | --part PART
Partition number containing the bootloader (defaults to 1)

so, I need to use P to specify the partition number if they are not 1 ;)

to add my Shell efi file that was stored in this partition, i used the following command:

sudo efibootmgr -c -d /dev/sda -p 2 -l '\EFI\Shell.efi' -L Shell

where -c means Create a new entry, -d means where the loaders is located (on wich disk) -p specifies wich partition, you could leave this away if its partition 1. -l (small L) means the location of the loader in the filesystem on the partition. and -L means label (using ' ' is also allowed)

To remove a entry

sudo efibootmgr -b 3 -B

-b | --bootnum XXXX
Modify BootXXXX (hex)
-B | --delete-bootnum
Delete bootnum (hex)

you get that HEX number from the list of boot entries.


Good luck and use google (leave a comment or mail me if you want help from me, but hey, Im no expert yet, this just worked :D )