grub2 & persistent partition naming

My OpenSuse 12.2 server went down due to power loss, and when power came back, the bootloader had failed:’(

From grub2, I edited root=UUID=a1691ea1-f20a-4bd4-85f8-84b9003d209a to root=/dev/sdb1, and it booted!
(I was also surprised to see grub2, as I had installed grub1 specifically because grub2 didn’t work for me)

Transcription of boot error:

Waiting for device /dev/root to appear: .............................................Could not find /dev/root.
Want me to fall back to /dev/disk/by-id/ata-WDC_WD800BB-00FJA0_WD-WMAJ94160934-part1? (Y/n)
y
Waiting for device /dev/disk/by-id/ata-WDC_WD800BB-00FJA0_WD-WMAJ94160934-part1 to appear: .............................................not found -- exiting to /bin/sh
sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
$

I have checked that both /dev/disk/by-{uuid/a1691ea1-f20a-4bd4-85f8-84b9003d209a,id/ata-WDC_WD800BB-00FJA0_WD-WMAJ94160934-part1} indeed point at …/…/sdb1.

I really want to use persistent partition names. How to debug/troubleshoot that?

I made some progress.

I have this (patch) to say about /etc/default/grub:

-# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
-#GRUB_DISABLE_LINUX_UUID=true
+# The line below needs to be exactly like this if you want to boot at all. Specifically, in order for GRUB to pass "root=/dev/sdXY" instead of "root=UUID=xxx" which doesn't work at the moment.
+GRUB_DISABLE_LINUX_UUID="true"

I ran grub2-mkconfig -o /boot/grub2/grub.cfg as the file says, and I can see that the resulting /boot/grub2/grub.cfg now has root=/dev/sdb1. So in theory, my bootloader should work now.

Unfortunately, the file also says it will be overwritten by YaST2 & perl-Bootloader, so this may not the smartest place to put the fix. But I’m stupid, so I’m going to git-checkout this config and re-run grub2-mkconfig on shutdown, and periodically. For boot safety.

A little guessing here.

It probably took you a minute or two to make that edit change.

My guess: It was the time delay, rather than the edit change, that fixed the problem. You might check for failing hardware.

So indeed if you edit the Grub 2 menu, it will get over written, but not the file /etc/default/grub as changes there will stick. Normally using UUID should not be a problem, but as the master of your domain, you can use what you want. Designations such as sda and sdb will change as drives get added or removed while the settings such as disk by-id will not. For help in using Grub 2, have a look at my bash helper script here, I think you will like the help it provides.

GNU Grub2 Command Listing Helper with --help & Input - Blogs - openSUSE Forums

Thank You,

Oh yes. I guess 15 mins before I remembered (it has actually happened once before). Needless to say, it was about time for a fix.

I will keep that in mind, but the changes I did in my previous post turned out to work.:slight_smile:

@jdmcdaniel3: Wow, those scripts look awesome (I might try you systemd helper script too). I think grub2 is a complicated beast (compared to legacy grub). I will try your grub2 helper script sooner or later.

But at this point, I think it looks more like the initramfs is to blame. According to gentoo forumers, the kernel can not by itself interpret UUIDs; it is a feature in initramfs.
Is this how it works: When the kernel sees UUID=<something>, it looks for /dev/disk/by-uuid/<something>, which is supposed to be a symlink set up by initrd?

Here is what I found to say how this all works: openSUSE 12.3: Chapter 12. Dynamic Kernel Device Management with udev

A UUID (Universally Unique Identifier) is a 128-bit number for a file system that is unique on both the local system and across other systems. It is a randomly generated with system hardware information and time stamps as part of its seed. UUIDs are commonly used to uniquely tag devices.

So a UUID is assigned to a Partition when it is created. Use this command to list them all:

ll /dev/disk/by-uuid

OR

/usr/sbin/blkid

Disk by-id pertains to the name given the hard drive by the manufacture and then differentiates the partition by using a part# at the end where part1 is the first partition up to the total number of existing partitions. You can find disk-by id this way:

ls -l /dev/disk/by-id/

I think that disk/by-id is the default used in Grub 2. at least foe me it has been.

Thank You,

On 2013-07-21 14:26, anordal wrote:
> But at this point, I think it looks more like the initramfs is to
> blame. According to ‘gentoo forumers’
> (http://forums.gentoo.org/viewtopic-t-931972-start-0.html), the kernel
> can not by itself interpret UUIDs; it is a feature in initramfs.
> Is this how it works: When the kernel sees UUID=<something>, it looks
> for /dev/disk/by-uuid/<something>, which is supposed to be a symlink set
> up by initrd?

It looks reasonable, yes; otherwise the symlinks would not exist, they
would use some other (direct) method.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)