From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1PDQj6-0003W3-M4 for mharc-grub-devel@gnu.org; Tue, 02 Nov 2010 19:57:16 -0400 Received: from [140.186.70.92] (port=51537 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDQj3-0003Vs-Am for grub-devel@gnu.org; Tue, 02 Nov 2010 19:57:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDQj1-0006oM-NN for grub-devel@gnu.org; Tue, 02 Nov 2010 19:57:13 -0400 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:46770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDQj1-0006o2-EV for grub-devel@gnu.org; Tue, 02 Nov 2010 19:57:11 -0400 Received: from [82.69.3.149] (helo=[192.168.1.65]) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1PDQiy-0006dt-MN; Tue, 02 Nov 2010 23:57:08 +0000 Message-ID: <4CD0A554.5060404@zen.co.uk> Date: Tue, 02 Nov 2010 23:57:08 +0000 From: Barry Jackson User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-UK; rv:1.9.2.13pre) Gecko/20101102 Lightning/1.0b2 Lanikai/3.1.7pre MIME-Version: 1.0 To: grub-devel@gnu.org Content-Type: multipart/mixed; boundary="------------040302080701070405030007" X-Originating-Smarthost01-IP: [82.69.3.149] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Andrey Borzenkov Subject: Labels in grub2 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:57:15 -0000 This is a multi-part message in MIME format. --------------040302080701070405030007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, I spoke to Colin Watson on IRC recently and asked if the use of labels could be made an option in grub2 in the future. He suggested I mention it on this list. In the meantime I have made some patches to demonstrate this idea in grub 1.98 which I have attached. 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. Thanks, Barry Jackson --------------040302080701070405030007 Content-Type: text/plain; name="10_linux.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="10_linux.patch" --- /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 @@ ;; esac +# If device has no uuid OR GRUB_DISABLE_LINUX_UUID is true OR search for dev with uuid fails (bcj) if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else - LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} +# 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 + LINUX_ROOT_DEVICE=LABEL=${GRUB_DEVICE_LABEL} + else + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} + fi fi linux_entry () @@ -111,7 +117,6 @@ version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" - initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \ "initrd-${version}" "initrd.img-${alt_version}" \ --------------040302080701070405030007 Content-Type: text/plain; name="grub2-mkconfig.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub2-mkconfig.patch" --- /usr/sbin/grub2-mkconfig 2010-11-02 22:38:20.610505816 +0000 +++ grub2-mkconfig 2010-11-02 22:35:32.000000000 +0000 @@ -122,6 +122,11 @@ GRUB_DEVICE="`${grub_probe} --target=device /`" GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true +# In grub 1.98 "grub-probe --target=fs_label" is not supported so using blkid (bcj) +if blkid ${GRUB_DEVICE}| grep -q "LABEL=";then +GRUB_DEVICE_LABEL=$(blkid ${GRUB_DEVICE}| grep "LABEL=" |tr -s 'LABEL=' '*' | cut -d* -f2 | cut -d'"' -f2) +fi + # Device containing our /boot partition. Usually the same as GRUB_DEVICE. GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true @@ -199,6 +204,8 @@ # override them. export GRUB_DEVICE \ GRUB_DEVICE_UUID \ + GRUB_DEVICE_LABEL \ + GRUB_USE_LABEL \ GRUB_DEVICE_BOOT \ GRUB_DEVICE_BOOT_UUID \ GRUB_FS \ @@ -226,6 +233,8 @@ GRUB_INIT_TUNE \ GRUB_SAVEDEFAULT + + if test "x${grub_cfg}" != "x"; then rm -f ${grub_cfg}.new exec > ${grub_cfg}.new --------------040302080701070405030007 Content-Type: text/plain; name="grub-mkconfig_lib.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub-mkconfig_lib.patch" --- /usr/lib/grub/grub-mkconfig_lib 2010-10-23 15:16:16.000000000 +0100 +++ grub-mkconfig_lib 2010-11-02 22:31:03.000000000 +0000 @@ -120,10 +120,15 @@ # If there's a filesystem UUID that GRUB is capable of identifying, use it; # otherwise set root as per value in device.map. +# If a label is available and GRUB_USE_LABEL=true then use label (bcj) +if [ "x${GRUB_DEVICE_LABEL}" != "x" ] && [ "x${GRUB_USE_LABEL}" = "xtrue" ]; then + echo "search --no-floppy --label --set ${GRUB_DEVICE_LABEL}" +else echo "set root='`${grub_probe} --device ${device} --target=drive`'" if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then echo "search --no-floppy --fs-uuid --set ${fs_uuid}" fi +fi } grub_file_is_not_garbage () --------------040302080701070405030007 Content-Type: text/plain; name="grub.cfg" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub.cfg" # # DO NOT EDIT THIS FILE # # It is automatically generated by /usr/sbin/grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then load_env fi set default="0" if [ ${prev_saved_entry} ]; then set saved_entry=${prev_saved_entry} save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z ${boot_once} ]; then saved_entry=${chosen} save_env saved_entry fi } insmod ext2 search --no-floppy --label --set 2010_1_64_root if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=auto insmod gfxterm insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of terminal.mod that don't # understand terminal_output terminal gfxterm fi fi insmod ext2 search --no-floppy --label --set 2010_1_64_root set locale_dir=($root)/boot/grub2/locale set lang=en insmod gettext set timeout=5 ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/10_linux ### menuentry "Mandriva GNU/Linux, with Linux 2.6.33.7-desktop-69mib" --class mandriva --class gnu-linux --class gnu --class os { set gfxpayload=keep insmod ext2 search --no-floppy --label --set 2010_1_64_root echo Loading Linux 2.6.33.7-desktop-69mib ... linux /boot/vmlinuz-2.6.33.7-desktop-69mib root=LABEL=2010_1_64_root ro splash=verbose echo Loading initial ramdisk ... initrd /boot/initrd-2.6.33.7-desktop-69mib.img } menuentry "Mandriva GNU/Linux, with Linux 2.6.33.7-desktop-2mnb" --class mandriva --class gnu-linux --class gnu --class os { set gfxpayload=keep insmod ext2 search --no-floppy --label --set 2010_1_64_root echo Loading Linux 2.6.33.7-desktop-2mnb ... linux /boot/vmlinuz-2.6.33.7-desktop-2mnb root=LABEL=2010_1_64_root ro splash=verbose echo Loading initial ramdisk ... initrd /boot/initrd-2.6.33.7-desktop-2mnb.img } menuentry "Mandriva GNU/Linux, with Linux 2.6.33.7-desktop-1mnb" --class mandriva --class gnu-linux --class gnu --class os { set gfxpayload=keep insmod ext2 search --no-floppy --label --set 2010_1_64_root echo Loading Linux 2.6.33.7-desktop-1mnb ... linux /boot/vmlinuz-2.6.33.7-desktop-1mnb root=LABEL=2010_1_64_root ro splash=verbose echo Loading initial ramdisk ... initrd /boot/initrd-2.6.33.7-desktop-1mnb.img } menuentry "Mandriva GNU/Linux, with Linux desktop" --class mandriva --class gnu-linux --class gnu --class os { insmod ext2 search --no-floppy --label --set 2010_1_64_root echo Loading Linux desktop ... linux /boot/vmlinuz-desktop root=LABEL=2010_1_64_root ro splash=verbose echo Loading initial ramdisk ... initrd /boot/initrd-desktop.img } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/90_persistent ### ### END /etc/grub.d/90_persistent ### --------------040302080701070405030007--