I'm already successfully booting the loop mounted arch installation iso (and couple of other isos) using grub on flashdrive. I have grub files in /boot/grub on the flash, iso files in /boot/iso (see https://wiki.archlinux.org/index.php/Multiboot_USB_drive). The relevant part of grub.cfg is


menuentry '[loopback]archlinux-2015.07.01-dual.iso i686' {
    set isofile='/boot/iso/archlinux-2015.07.01-dual.iso'
    loopback loop $isofile
    linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201507 img_dev=$imgdevpath img_loop=$isofile earlymodules=loop
    initrd (loop)/arch/boot/i686/archiso.img

This works fine - when the UUID in imgdevpath is correct. So, one has to manually update the line beforehand. Only then does it work.

I would like to read the UUID of the GRUB's root partition (which is also the partition where I store the iso files), from within grub, into a variable, at boot time. Can this be done?

It would simplify the booting from (loop mounted) iso file. "ls ($root)" already displays the UUID (among other things), but it can't be fed into a variable (or at least I don't know how). Ideally, I would like to do something like

foobar_readuuid ($root) --set=rootuuid

I'm not looking for a "search" command; as far as I can tell, it's output is always the "device,partition" i.e. something like hdX,msdosY. And I already know that, it's in $root. Just want to read the uuid, so I could feed it to the $imgdevpath


Got the answer from help-grub mailing list:

probe -u $root --set=abc

use $abc as uuid variable of $root.

So, in my specific case, the relevant part of grub.cfg became:

probe -u $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"

And it works great.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.