help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub: eval vars for linux command / write config agnostic to other d


From: David Balažic
Subject: Re: grub: eval vars for linux command / write config agnostic to other disks
Date: Sun, 29 Mar 2020 13:49:51 +0200

I wrote a patch back then to support specifying root filesystem by its
label or UUID, see URL below.
But it was never merged (except into some versions of OpenWRT, google it).

The simpler way it to use an initrd, as already mentioned.

See: 
http://web.archive.org/web/20020820043702/http://linux-patches.rock-projects.com/v2.2-f/uuid.html

Regards,
David

On Sat, 28 Mar 2020 at 19:17, Toerless Eckert <address@hidden> wrote:
>
> 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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]