rootdelay=60 has no effect; booting unreliable due to race condition

Asked by Steve Newcomb

I'm using an mdadm-style software RAID 5 for my root filesystem partition (/).

On this particular system, the disks evidently aren't as fast as they are on my other systems with the same configuration.
Sometimes they're ready in time for booting to proceed. Sometimes they aren't. When they're not ready in time, I find myself at an (initramfs) prompt, with the message: /sbin/init not present (or something like that).

In hope of getting more reliable boot-up operation, I added "rootdelay=60" to /etc/default/grub. The actual line looks like this:
GRUB_CMDLINE_LINUX_DEFAULT="rootdelay=60 max_loop=256 "
Then I ran grub-mkconfig -o /boot/grub/grub.cfg in the usual way, and grub-install as well. Both seemed to work OK.

But there's no discernable impact on booting. As before, sometimes it boots, and sometimes it doesn't. Booting always proceeds very fast, and there's certainly no 1-minute wait during the boot process. (Booting is so fast now on 10.04 that this distro gives me a fresh understanding of the term "race condition"! (;^)

When booting fails, at the (initramfs) prompt I can run mdadm which says the RAID (/dev/md1) is fine. I can run blkid /dev/md1 and it says the root filesystem is available. It seems clear that it just wasn't ready on time.

I just have to keep trying until, by chance, the disks were ready in time for the boot process to proceed. My question is: is there a better way? I hate to have to buy faster disks just because Ubuntu now boots so fast! And why doesn't the rootdelay= commandline argument have any effect?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
Steve Newcomb
Solved:
Last query:
Last reply:
Revision history for this message
Sam_ (and-sam) said :
#1

-quote on-
 Check rootdelay= implies there was not enough time for the system to initialize the devices. As a workaround, which is indeed mentioned in a number of threads, you may want to add a short delay to allow the system enough time to identify and initialize the devices.

To affect this change, you need to append rootdelay=XXX to the kernel line in the GRUB menu. XXX is a timeout in seconds the system will wait before trying to load the kernel. Various forum threads suggest 120 seconds or more.
-quote off-
http://www.dedoimedo.com/computers/ubuntu-initrd-bug.html

> Then I ran grub-mkconfig -o /boot/grub/grub.cfg in the usual way, and grub-install as well.

A simple
sudo update-grub
is fine to update edited /etc/default/grub.

-quote on-
No changes made in the configuration files will take effect until the update-grub command is also run.
-quote off-
https://help.ubuntu.com/community/Grub2

Revision history for this message
Steve Newcomb (srn-coolheads) said :
#2

Sam, thanks for your message, but alas it doesn't help.

As my question says, I tried all that and it didn't work.

and "grub-mkconfig -o /boot/grub/grub.cfg" is exactly the same as "update grub". (If you read the manual on update-grub, that's what it says.)

Revision history for this message
Steve Newcomb (srn-coolheads) said :
#3

While looking for the answer to *another* problem I ran across the answer to my problem (although the mystery as to why the Linux command-line argument "rootdelay=XXX" doesn't do anything remains).

The answer was to create a script in /usr/share/initramfs-tools/scripts/local-premount/sleepAWhile which looks like this:

#! /bin/sh
echo
echo "sleeping for 240 seconds while udevd and mdadm settle down"
sleep 240 ## just waste time while things quiet down

and then to run

update-initramfs -u

This adds 6 minutes (!) to the boot process, at exactly the right moment, to allow mdadm, udevd, etc to get their act together before attempting to mount the RAID.

The whole issue and solution is beautifully described at

 http://async.com.br/~kiko/diary.html?date=09.12.2009

Note: I would not be able to tell what was going on if I had not edited my

/etc/default/grub

(and then run grub-mkconfig -o /boot/grub/grub.cfg) so it looks like this (note the rootdelay=60 in it that mysteriously still has no effect):

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="rootdelay=60 max_loop=256 "
GRUB_CMDLINE_LINUX=""
GRUB_TERMINAL=console