?
Solved

GRUB Syntax for selecting root device by UUID or LABEL

Posted on 2011-10-18
9
Medium Priority
?
829 Views
Last Modified: 2013-12-16
This is the first time I asked a related question so I don't know if the link back to the original question will work.  In short, I've tried to boot my computer using LABEL or the UUID.  Here's my blkid list for sda

/dev/sda1: LABEL="SYSTEM" UUID="3CC6B7D7C6B78F9E" TYPE="ntfs" 
/dev/sda2: LABEL="OS" UUID="9AF658B3F65890FD" TYPE="ntfs" 
/dev/sda3: LABEL="HP_RECOVERY" UUID="C890043490042B8E" TYPE="ntfs" 
/dev/sda5: UUID="43f8d2de-330c-43dd-9444-c2bb2abbf3db" SEC_TYPE="ext2" TYPE="ext3" LABEL="HOME" 
/dev/sda7: UUID="74174238-8e07-4606-ba69-6d53455e1d10" SEC_TYPE="ext2" TYPE="ext3" LABEL="SLACK_12_2" 
/dev/sda8: UUID="0b54b547-3835-4e7d-b6c9-b44fefb1c2c6" TYPE="ext3" LABEL="Slack_13" 
/dev/sda10: UUID="aa07218c-e8ee-410d-a2a9-9fe8c576281c" TYPE="swap" 
/dev/sda6: LABEL="HOME64" UUID="c1a8cc6a-2a07-4f88-8c34-fb6205c91456" TYPE="ext3" SEC_TYPE="ext2" 
/dev/sda9: LABEL="SPARE" UUID="7832bdba-10b7-4daa-92ce-53738262897a" SEC_TYPE="ext2" TYPE="ext3" 

Open in new window


And here's my current menu.lst

# Start GRUB global section
#timeout 30
#color light-gray/blue black/light-gray
# End GRUB global section
# Linux bootable partition config begins
  title Linux on (/dev/sda7)
  root (hd0,6)
  kernel /boot/vmlinuz root=/dev/sda7 ro vga=773 
# Linux bootable partition config ends
# Other bootable partition config begins
  title Windows on (/dev/sda1)
  rootnoverify (hd0,0)
  makeactive
  chainloader +1
# Other bootable partition config ends
# Linux bootable partition config begins
  title bzImage on (/dev/sda7)
  root (hd0,6)
  kernel /boot/bzImage root=/dev/sda7 ro vga=773 
# Linux bootable partition config ends
# Linux bootable partition config begins
  title Linux on (/dev/sda8)
  root (hd0,7)
  kernel /boot/vmlinuz root=/dev/sda8 ro vga=773 
# Linux bootable partition config ends
# Linux bootable partition config begins
  title Linux on (Slack_13)
  root (hd0,7)
  kernel /boot/vmlinuz root=/dev/disk/by-uuid/0b54b547-3835-4e7d-b6c9-b44fefb1c2c6 ro vga=773 
# Linux bootable partition config ends
# Linux bootable partition config begins
  title bzImage on (/dev/sda8)
  root (hd0,7)
  kernel /boot/bzImage root=/dev/sda8 ro vga=773 
# Linux bootable partition config ends
title --- For help press 'c', type: 'help'
root (hd0)
title --- For usage examples, type: 'cat /boot/grub/grub.txt'
root (hd0)

Open in new window


Booting to the choice with the UUID fails.   Boot says it can't be found.  I also tried the root=UUID=<the UUID> format.  I also tried the by-label (instead of by-uuid) for Slack_13.

While I have my computer booting again, it would be nice if I could boot by something other that device names (since they seem to be unreliable).
0
Comment
Question by:Hugh McCurdy
  • 5
  • 2
  • 2
9 Comments
 
LVL 44

Assisted Solution

by:Darr247
Darr247 earned 400 total points
ID: 36990550
So you're saying

  title Linux on (Slack_13)
  root (hd0,7)
  kernel /boot/vmlinuz ro root=UUID=0b54b547-3835-4e7d-b6c9-b44fefb1c2c6 vga=773

won't work, but

  title bzImage on (/dev/sda8)
  root (hd0,7)
  kernel /boot/bzImage root=/dev/sda8 ro vga=773

and
  title Linux on (/dev/sda8)
  root (hd0,7)
  kernel /boot/vmlinuz root=/dev/sda8 ro vga=773

do work?



Did you try

  title bzImage on (/dev/sda8)
  root (hd0,7)
  kernel /boot/bzImage ro root=UUID=0b54b547-3835-4e7d-b6c9-b44fefb1c2c6 vga=773

 also?

The root commands in my grub menu point to the partition where grub is installed, on my machine... not the partition where the kernel is, for what it's worth.
0
 
LVL 13

Author Comment

by:Hugh McCurdy
ID: 36992191
I plan to try those later this morning.  Get kid to school time.
0
 
LVL 13

Author Comment

by:Hugh McCurdy
ID: 36992364
Doesn't the root command tell GRUB where to find the boot image?  If so, I couldn't use the vmlinuz on that partition (32bit) to boot a 64 bit partition.  Right?
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 44

Expert Comment

by:Darr247
ID: 36993377
What version grub are you using, by the way?
0
 
LVL 13

Author Comment

by:Hugh McCurdy
ID: 36994604
That might be the problem.  0.97 from Slackware 12.2.
0
 
LVL 41

Expert Comment

by:noci
ID: 36995590
It should have nothing to do with grub...

kernel Xfile params....

means load the Xfile on the location of the kernel start address and pass it the remainder as a command line string.

The kernel  should interpret the root=...
Sometimes the initramfs/initrd is needed to first start udev to support /dev/... with more info...
0
 
LVL 13

Author Comment

by:Hugh McCurdy
ID: 36995833
I wonder if there's a minimum kernel version needed to interpret.  Or if there's a flag I don't have set correctly.  The kernel is 2.6.35.4
0
 
LVL 41

Accepted Solution

by:
noci earned 1600 total points
ID: 36996823

Here is an article on the background:
http://en.gentoo-wiki.com/wiki/Initramfs

There is still no support in the kernel:
Here is a excerpt from do_mounts.c (handling the root= part of the line).
---8<---

   /*
         * wait for the known devices to complete their probing
         *
         * Note: this is a potential source of long boot delays.
         * For example, it is not atypical to wait 5 seconds here
         * for the touchpad of a laptop to initialize.
         */
        wait_for_device_probe();

        md_run_setup();

        if (saved_root_name[0]) {
                root_device_name = saved_root_name;
                if (!strncmp(root_device_name, "mtd", 3) ||
                    !strncmp(root_device_name, "ubi", 3)) {
                        mount_block_root(root_device_name, root_mountflags);
                        goto out;
                }
                ROOT_DEV = name_to_dev_t(root_device_name);
                if (strncmp(root_device_name, "/dev/", 5) == 0)
                        root_device_name += 5;
        }

---8<---
Now earlier in this file there is a part (name_to_dev_t() ) that does recognize PARTUUID= if the kernel was configured with CONFIG_BLOCK, you may assume that this is done.
A partition UUID != Filesystem UUID .


For anything handling the filesystem you need to have an initial ramdisk as root= device and that one will find & mount the actual disk.
0
 
LVL 13

Author Closing Comment

by:Hugh McCurdy
ID: 36999735
Thanks both of you for your assistance.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question