You are not logged in.
Hi there,
so 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/Mu … _USB_drive ). The relevant part of grub.cfg is
imgdevpath="/dev/disk/by-uuid/CF3D-EC7C"
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
initrd (loop)/arch/boot/i686/archiso.img
}
This all works as intended - but it was necessary to set up the UUID in imgdevpath by hand, which feels inconvenient and not really necessary.
My intention is to read the UUID of the GRUB's root partition (which is also the partition which holds the iso files), from within grub, at boot time. Can this be done? It would simplify the booting from (loop mounted) iso file.
"ls ($root)" already displays the UUID in grub cmdline (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 (supposing there would be a "readuuid" command)
readuuid ($root) --set=rootuuid
imgdevpath="/dev/disk/by-uuid/$rootuuid"
...
I'm not looking for a "search" command; as far as I can tell, it's output is always the "device,partion" 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
Thanks in advance for any clue.
EDIT: zapped "earlymodules=loop" (it is not necessary)
Last edited by renergy (2015-07-12 08:01:05)
Offline
Got the answer from help-grub mailing list:
probe -u $root --set=abc
use $abc as uuid variable of $root.
So the grub.cfg for booting loop mounted arch iso looks like (assuming the iso file is on the same partition as grub itself)
probe -u $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"
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
initrd (loop)/arch/boot/i686/archiso.img
}
menuentry '[loopback]archlinux-2015.07.01-dual.iso x86_64' {
set isofile='/boot/iso/archlinux-2015.07.01-dual.iso'
loopback loop $isofile
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201507 img_dev=$imgdevpath img_loop=$isofile
initrd (loop)/arch/boot/x86_64/archiso.img
}
Works like a charm, no need to hand code the uuid beforehand now.
Will update the wiki too, this is very practical - one step less, no need to adjust grub.cfg on different flashdrives.
Last edited by renergy (2015-07-12 08:00:22)
Offline
Nice solution. I'm using label myself.
Online
Nice solution. I'm using label myself.
Thanks!
UUID is more reliable than partition label (in principle), and with the above it is arguably even easier to use. So I'd advocate using UUID
Offline