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. _______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
