[Top][All Lists]

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

Re: Labels in grub2

From: Barry Jackson
Subject: Re: Labels in grub2
Date: Thu, 04 Nov 2010 19:27:07 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-UK; rv: Gecko/20101104 Lightning/1.0b2 Lanikai/3.1.7pre

On 04/11/10 12:12, Andrey Borzenkov wrote:
On Wed, Nov 3, 2010 at 2:57 AM, Barry Jackson<address@hidden>  wrote:

In the meantime I have made some patches to demonstrate this idea in grub
1.98 which I have attached.

gmail does not make it easy to quote patches :(

--- /usr/sbin/grub2-mkconfig    2010-11-02 22:38:20.610505816 +0000
+++ grub2-mkconfig      2010-11-02 22:35:32.000000000 +0000
+GRUB_DEVICE_LABEL=$(blkid ${GRUB_DEVICE}| grep "LABEL=" |tr -s 'LABEL=' '*' | cut 
-d* -f2 | cut -d'"' -f2)

This is very elaborate way to implement

GRUB_DEVICE_LABEL="$(blkid -s LABEL -o value ${GRUB_DEVICE})"


Neat thanks, I forgot that the latest blkid has that feature :-(
In the latest beta grub, grub-probe can be used instead of blkid for this.

And you have to check whether blkid exists ...

Yes. I suppose it's possible that it may not be available. I was only thinking of Mandriva.

@@ -226,6 +233,8 @@

  if test "x${grub_cfg}" != "x"; then

You probably should not introduce unrelated formatting changes.

I don't understand what you mean by that. Ah - those blank lines?
OK, yes, that was accidental. Must be more careful.

--- /etc/grub.d/10_linux        2010-11-02 22:25:19.849508548 +0000
+++ 10_linux    2010-11-02 22:05:31.000000000 +0000
@@ -42,11 +42,17 @@
+# If A label exists and GRUB_USE_LABEL=true is in /etc/default/grub  (bcj)
+   if [ "x${GRUB_DEVICE_LABEL}" != "x" ]&&  [ "x${GRUB_USE_LABEL}" = "xtrue" 
]; then

Label may contain spaces as opposed to UUID, I think. Although I guess
in real life label with spaces will cause much more problem elsewhere.
  Same in grub-mkconfig_lib patch BTW

Yes labels can have spaces, but it's a bad idea and yes things do break, maybe LINUX_ROOT_DEVICE=LABEL="${GRUB_DEVICE_LABEL}" would be enough. Or maybe detect labels with spaces and exit 1 would be safer.
I will do more testing.

They work fine for me, with GRUB_USE_LABEL="true" set in /etc/default/grub
in my Mandriva-Linux systems.

A grub.cfg produced with a patched grub2 is attached also.

I am not a professional programmer, so I would appreciate any constructive
criticism, and your comments in general on this idea.

I think it is fine as option as long as it is not default
I agree

Labels have
much more chances to duplicate than UUIDs.

If users can't think of unique labels then it's time to give up :-(

I really hope that the grub developers pick up this idea and run with it.

Thanks for your input.

Grub-devel mailing list

reply via email to

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