Glam Prestige Journal

Bright entertainment trends with youth appeal.

efibootmgr is creating invalid entries in the EFI boot menu. For instance efibootmgr -c -d /dev/sdX -p Y -l /EFI/refind/refind_x64.efi -L "rEFInd Boot Manager" adds an unbootable japanese characters in the boot menu.

On the other hand bcfg boot add 3 fs0:\EFI\refind\refind_x64.efi "rEFInd" works just fine.

Now I would like to boot directly onto vmlinuz-linux instead of passing through refind. Does anyone have an idea on how to pass parameters to the kernel ? Without the paramaters it's : bcfg boot add 3 fs0:\vmlinuz-linux "linux" but what option do I need to use to add initrd=\initramfs-linux.img root=/dev/sda2 ?

Thanks

5 Answers

I've had similar issues on one particular (Supermicro) motherboard, and while Steve's suggestion of using a text file works, there's a bit more nuance. I've tried to document the process below:

  1. If you don't have bcfg available, you first need to get a copy of an EFI 2.x shell. The motherboard firmware probably has 1.x. The Arch wiki has more details, but for most 64-bit modern systems you'll want to grab the Shell.efi from here and rename it shellx64.efi and place it directly in the root of your EFI System Partition. If your motherboard provides a Launch EFI Shell from filesystem device, use it. Otherwise, you can use the built-in shell to launch the updated shell. See the wiki for further information.

  2. Once you're in the 2.x shell, you'll want to make sure your boot option exists. You can list options with bcfg boot dump -b (the -b enables the pager, like more). If it does not exist, you'll need to add one, preferably to the top of the list. You can browse around - list filesystems with map -b, look for entries starting with fs like fs0:, and then use ls like ls fs0:\, ls fs0:\EFI\, etc to explore the directories.

    Once you find the bootloader's path (and the correct fs device), add it (as in the original question):

    bcfg boot add 3 fs0:\EFI\refind\refind_x64.efi "rEFInd"

    This adds it as the 4th boot entry (counting from 0, 1, 2, 3)

  3. Once you have the boot option added (verify with bcfg boot dump -b) you need to add the optional data (boot parameters). As Steve briefly mentioned, the most robust way to do this is by saving these params to a file and then importing them with bcfg -opt. However, from what I can tell, this appends the options, so you're best off bcfg boot rming the boot option first and readding it as per step 2. Once you have a clean entry, you can add the optional data. For example:

    edit fs0:\EFI\refind\options.txt

    This will open a file editor. Type in your options (on a single line), and press F2 to save. Press F3 to exit. You can also edit this file from within an OS, but you must save it as UTF-16 (LE, little-endian). The EFI Shell's editor does that automatically.

    The next step is to import the options:

    bcfg boot -opt 3 fs0:\EFI\refind\options.txt

    Again, the 3 specifies the boot entry. This should match the one you added it as. Do not run this command multiple times - you must rm and re-add the entry before you can change options.

  4. Verify the boot options and optional data with bcfg boot dump -v -b.

I am encountering the same situation. I believe the solution will involve the use of the -opt parameter either in-line with the add or as an additional command. So far though I have not had success putting all of the parameters in a quoted string. My next attempt will be to create a file using edit and passing the filename using -opt.

If you succeed, please update this thread.

So, in the uefi shell I used edit to create an opt file on the media at the same location as the kernel. In it I placed the kernel options on a single line. I then used the command bcfg boot -opt 0 FS0:\filename You may need to use a different FS number, -opt number and filename to match your configuration.

1

The first command you typed is correct. You add options with another command. For your specific case, it is:

Shell> bcfg boot -opt 3 "initrd=\initramfs-linux.img root=/dev/sda2"
2

My documentation for efibootmgr shows that -p is for specifying the partition number, but in your question it looks like you're using Y for the value. If that wasn't a typo, it could explain why you get strange characters in the menu and had trouble booting.

As for passing parameters, there's a switch -@ which escaped my attention the first couple times I read the docs. If you supply a file name, it'll read a line of parameters from that file.

The docs also say you can use - as the file name, but when I tried that, I wasn't able to get it to proceed after inputting text; pressing enter or ^D seemed to have no effect, while ^C terminated the program without making changes.


If you wish to experiment in a VM before messing with your hardware, the following may be helpful - though you'll need to adjust the OVMF paths for your distro:

  • Install qemu and the ovmf firmware package.
  • Copy /usr/share/edk2-ovmf/OVMF_VARS.fd to the current directory - qemu will write efi config changes to this file.
  • Create a directory for qemu to use as Virtual VFAT (vvfat). I'll refer to it as hda from now on.
  • Copy a kernel which has the EFI stub into hda.
  • If that kernel doesn't have an embedded initrd with a shell and efibootmgr, locate or build an initrd which does, and place it in hda. (A generic initrd may work, since those generally let you enter an emergency mode if they can't find the root volume.)
  • start qemu; I use the following command:

    qemu-system-x86_64 -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/edk2-ovmf/OVMF_CODE.fd -drive if=pflash,format=raw,unit=1,readonly=off,file=OVMF_VARS.fd -enable-kvm -cpu host -m 1024 -usb -device usb-tablet -netdev user,id=mynet -device virtio-net-pci,netdev=mynet -hda fat:rw:hda -boot menu=on
    • Once booted, do not modify the hda dir from outside the VM - see the warning here.
    • Note the -boot menu=on part. If necessary, you can press ESC while it's booting, and you'll get into the uefi config. From there, you can boot particular entries or create/delete/edit.
  • You'll drop into an EFI Shell if it doesn't find a file to boot.

    • From there, you could use bcfg to view/edit entries.
    • Or, you could boot your linux kernel:

      fs0:
      bzImage.efi initrd=\absolute\path\to\initrd arg arg arg
    • ...at which point the kernel should load and boot with the provided initrd and args. Note that an absolute path is mandatory when using initrd - see efi-stub.txt
    • Now, you can poke around in the efi files under /sys/firmware/, try out efibootmgr, etc... all without risking your real hardware. Enjoy!

You should use it like this instead of /dev/sda you must also use partuuid or uuid like this:

--disk /dev/sdX --part Y --create --label "Arch Linux" --loader /vmlinuz-linux --unicode 'root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX rw initrd=\initramfs-linux.img' --verbose
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy