FS#40029 - [grub] ${cmdpath} expansion in GRUB shell is wrong

Attached to Project: Arch Linux
Opened by Dan Liew (delcypher) - Tuesday, 22 April 2014, 14:31 GMT
Last edited by Tobias Powalowski (tpowa) - Tuesday, 29 March 2022, 19:30 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Ronald van Haren (pressh)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I'm currently doing a UEFI install of Arch Linux and I was following instructions on the wiki to switch to using GRUB2 to load the kernel because of the EFISTUB bug in the kernel and I came across an issue where the ${cmdpath} variable in the shell was not being expanded correctly.

grub> echo ${cmdpath}
(hd0,msdos2)EFI/Boot

The weird thing is I can do this...

grub> ls ${cmdpath}
bootx64.efi hashTool.efi loader.efi grub.cfg

But then this fails

grub> cat ${cmdpath}/grub.cfg
error:invalid file name `EFI/Boot/grub.cfg'.

grub> configfile ${cmdpath}/gru.cfg
# The file is not loaded.

However if I manually correct cmdpath like so (notice the slash before the 'E' in 'EFI')
set cmdpath=(hd0,msdos2)/EFI/Boot

then the cat and configfile comands work.

Additional info:
* grub 1:2.02.beta2-2 (version on live usb image 201404)

Steps to reproduce:
Sorry, it's probably easier to do this on an installed GRUB shell but I don't have an installed Arch system I can test this on yet.

1. Create Arch live usb using: https://wiki.archlinux.org/index.php/USB_Flash_Installation_Media#BIOS_and_UEFI_Bootable_USB

2. Follow the instructions at https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Using_GRUB

Basically this involves creating a standalone version of GRUB on the liveusb and setting the embedded grub.cfg load an external grub.cfg by doing

configfile ${cmdpath}/grub.cfg

3. Boot from the Arch live usb. The config file won't be loaded and the user will be dropped to the GRUB shell. Running the configfile commands manually in the GRUB shell confirms problem with the value of ${cmdpath}.
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Tuesday, 29 March 2022, 19:30 GMT
Reason for closing:  Works for me
Comment by Keshav Amburay (the.ridikulus.rat) - Wednesday, 30 April 2014, 02:59 GMT
@delcypher: Can you please try grub-1:2.02.beta2-3 in [testing]?
Comment by Dan Liew (delcypher) - Thursday, 01 May 2014, 13:42 GMT
I'll give it a try at the weekend.
Comment by Dan Liew (delcypher) - Saturday, 03 May 2014, 14:20 GMT
Okay I just tried using 1:2.02.beta2-3 to install a standalone GRUB image onto the live CD installed to a USB stick. These are the steps I took

# wget http://mirror.aarnet.edu.au/pub/archlinux/iso/2014.04.01/archlinux-2014.04.01-dual.iso
# dd if=archlinux-2014.04.01-dual.iso bs=4M of=/dev/sdb
# partprobe
# mount /dev/sdb2 /mnt
# cd /mnt/EFI/boot
# echo 'configfile ${cmdpath}/grub.cfg' > /tmp/grub.cfg
# mv loader.efi old-loader.efi
# grub-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --modules="part_gpt part_msdos" --fonts="unicode" --locales="en@quot" --themes="" -o ./loader.efi "/boot/grub/grub.cfg=/tmp/grub.cfg" -v
# vim grub.cfg # Add configuration file. Its contents doesn't matter because GRUB fails to load it!
# cd /
# umount /mnt

Now reboot and do UEFI boot from USB. Loading the configuration file fails (mine contained menu entries) and

grub> echo ${cmdpath}
(hd0,msdos2)EFI/Boot

grub> ls ${cmdpath}
bootx64.efi hashTool.efi loader.efi grub.cfg

grub> cat ${cmdpath}/grub.cfg
error:invalid file name `EFI/Boot/grub.cfg'.

grub> configfile ${cmdpath}/grub.cfg
# The file is not loaded, if it was a menu would appear.

Interestingly GRUB2 is also installed on my system and when I drop into the shell and do

grub> echo ${cmdpath}
(hd0,gpt1)/EFI/grub

in this case GRUB has correctly put the leading slash in place.
Comment by Keshav Amburay (the.ridikulus.rat) - Monday, 12 May 2014, 00:58 GMT
I think this might be some issue specific to part_msdos grub module in uefi systems, or some issue due to your specific firmware. Please file an upstream bug and provide the bug report link here for us to keep track of it.
Comment by Tobias Powalowski (tpowa) - Monday, 31 January 2022, 17:45 GMT
Is this still valid? We are already on 2.06 now.
Comment by Christian Hesse (eworm) - Monday, 31 January 2022, 19:29 GMT
This is eight years old... I guess we can just close it, no?

Loading...