[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grub: eval vars for linux command / write config agnostic to other disks
From: |
Toerless Eckert |
Subject: |
grub: eval vars for linux command / write config agnostic to other disks |
Date: |
Sat, 28 Mar 2020 17:56:33 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
I would like to have a grub config that will work even
if the disk is re-plugged into a different SATA port
and independent of whether other disks are plugged in.
Lets say i today have this config:
set root='hd5,gpt2'
search --no-floppy --fs-uuid --set=root 4bdb3675-62ff-499f-9fc4-e5fd8c7ba777
linux /vmlinuz root=/dev/sdf5 ro
The problem really is the "root=/dev/sdf5" when starting linux.
When the disk is plugged into a different slot, or if one of
the prior disks is removed, then /dev/sdf5 will be wrong.
I know, ideally inux should be able to solve the problem itself,
but it seemingly can't: LABEL=<label> or similar are not available
when choosing the root partition.
Is there a way to evaluate grub2 variables being passed to a
command like the linux command ?
E.g.: something like:
set root='hd5,gpt2'
search --no-floppy --fs-uuid --set=root 4bdb3675-62ff-499f-9fc4-e5fd8c7ba777
set linuxroot="/dev/sdf2"
if [ "x$root" = "hd4,gpt2" ]; then
set linuxroot="/dev/sde5"
fi
...
if [ "x$root" = "hd0,gpt2" ]; then
set linuxroot="/dev/sda5"
fi
linux /vmlinuz root="$linuxroot" ro
Of course, if grub supports shell style 'case' statement,
the string mapping would be easier, but the main question
is really if there is a way to pass the value of $linuxroot
to the linux command somehow.
Alas, couldn't figure out the ansewer to this question from
the grub2 manual ;-(
Thank you so much
Toerless
- grub: eval vars for linux command / write config agnostic to other disks,
Toerless Eckert <=
- Re: grub: eval vars for linux command / write config agnostic to other disks, Pascal Hambourg, 2020/03/28
- Re: grub: eval vars for linux command / write config agnostic to other disks, Felix Miata, 2020/03/28
- Re: grub: eval vars for linux command / write config agnostic to other disks, Pascal-liste, 2020/03/28
- Re: grub: eval vars for linux command / write config agnostic to other disks, Felix Miata, 2020/03/28
- Re: grub: eval vars for linux command / write config agnostic to other disks, Pascal Hambourg, 2020/03/28
- Re: grub: eval vars for linux command / write config agnostic to other disks, jmh6, 2020/03/29
- Re: grub: eval vars for linux command / write config agnostic to other disks, Pascal Hambourg, 2020/03/29
- Re: grub: eval vars for linux command / write config agnostic to other disks, Felix Miata, 2020/03/29
- Re: grub: eval vars for linux command / write config agnostic to other disks, jmh6, 2020/03/29
Re: grub: eval vars for linux command / write config agnostic to other disks, Pascal Hambourg, 2020/03/29