help-grub
[Top][All Lists]
Advanced

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

Re: Finding the root device of a labeled partition


From: Andrei Borzenkov
Subject: Re: Finding the root device of a labeled partition
Date: Thu, 2 Jun 2016 20:58:12 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

02.06.2016 14:34, Simon Wydooghe пишет:
> Hi,
> 
> I have a specific problem I'm trying to solve. I'm trying to chainload the
> MBR of a USB stick based on the label of one of the partitions on the USB
> stick. I can search and set the root partition as follows:
> 
> search --set=root --label MYLABEL
> 
> This sets root to 'hd1,msdos3' for instance. However, I can't chainload
> this because I need to chainload the device (hd1), not the partition
> (hd1,msdos3).
> 

What's wrong with installing bootloader on partition 3?

> So chainloader ($root)+1 will not work. Chainloader (hd1)+1 does work. So
> my question is, how can I find the device automatically and assign it to a
> variable? As this USB stick will be used on a variety of hardware, I can
> never know in advance if it will be hd1, hd2, etc.
> 

You can use regexp to extract drive name.

regexp --set chain '([^,]*)(,.*|)$' $root
chainloader ($chain)+1

I suppose more elaborate regex is possible to account for escaped '\,',
but I doubt we see it in practice.



reply via email to

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