wait-for-root fails to wait for plain /dev/sdaX partitions.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
initramfs-tools (Ubuntu) |
Fix Released
|
Medium
|
Martin Pitt | ||
Precise |
Fix Released
|
Medium
|
Chris J Arges | ||
Quantal |
Fix Released
|
Medium
|
Chris J Arges | ||
Raring |
Fix Released
|
Medium
|
Chris J Arges |
Bug Description
SRU Justification:
[Impact]
* Boot failures can occur with the wait-for-root utility in P/Q/R due to a race condition.
* Because of this issue unattended reboots and boots can randomly fail.
* The original bug was submitted against Precise LTS.
[Test Case]
* Reboot machine and look for "ALERT! /dev/sda1 does not exist. Dropping to a shell!". Entering exit from prompt should boot system normally.
* We expect that continuous reboots should allow for the machine to boot normally without this alert.
[Regression Potential]
* This patch has already been uploaded into Saucy, and tested.
--
Moving the discussion from http://
to launchpad, for I think that this bug needs to be handled in initramfs-tools
package rather than in udev package.
----------
I'm experiencing random boot failures with wait-for-root utility in Ubuntu
12.04 ( ubuntu-
For example, wait-for-root waited for only 0.13 seconds before giving up at
FSTYPE=
line in scripts/local in the initramfs, and immediately enters into
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
line.
This is a race condition and manually entering "exit" from the panic prompt
boots the system normally. This is a critical bug for this environment because
it will randomly fail to perform unattended reboot (e.g. automatic reboot after
saving kdump).
----------
I examined main() in wait-for-root using debug fprintf() and it turned out that
udev_monitor_
wait-for-root is using blocking socket).
I examined udev_monitor_
and it turned out that recvmsg() in udev_monitor_
libudev-monitor.c in udev package) is returning ENOBUFS error before recvmsg()
returns information of the root partition.
The wait-for-root utility in initramfs-tools package is not expecting recvmsg()
to return ENOBUFS error. But since ENOBUFS is an inevitable error, I think that
wait-for-root (i.e. the caller of udev_monitor_
this error.
description: | updated |
tags: | added: verification-done-precise |
tags: | added: verification-done-quantal |
tags: | added: verification-done-raring |
tags: |
added: verification-done removed: verification-needed |
I confirmed that below patch fixes my problem.
---------- patch start ---------- for-root. c for-root. c receive_ device (udev_monitor)) != NULL) { receive_ device (udev_monitor)) == NULL) get_property_ value (udev_device, "ID_FS_TYPE");
--- a/src/wait-
+++ b/src/wait-
@@ -88,7 +88,9 @@ main (int argc,
/* When the device doesn't exist yet, or is still being processed
* by udev, use the monitor socket to wait it to be done.
*/
- while ((udev_device = udev_monitor_
+ while (1) {
+ while ((udev_device = udev_monitor_
+ sleep (1);
if (matching_device (udev_device, devpath)) {
type = udev_device_
if (type) {
---------- patch end ----------
But why need to handle udev_monitor_ receive_ device( ) errors?
I think that wait-for-root.c could be written as short as below code.
---------- simplified wait-for-root.c start ----------
#include <libudev.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void alarm_handler(int signum)
{
exit(1);
}
int main(int argc, char *argv[])
{
const char *devpath;
char path[PATH_MAX];
struct udev *udev;
if (argc != 3) {
fprintf(stderr, "Usage: %s DEVICE TIMEOUT\n", argv[0]);
exit(2);
}
devpath = argv[1]; by-uuid/ %s", devpath + 5); by-label/ %s", devpath + 6);
if (!strncmp(devpath, "UUID=", 5))
snprintf(path, sizeof(path), "/dev/disk/
else if (!strncmp(devpath, "LABEL=", 6))
snprintf(path, sizeof(path), "/dev/disk/
else
snprintf(path, sizeof(path), "%s", devpath);
signal(SIGALRM, alarm_handler); atoi(argv[ 2]));
alarm(
udev = udev_new(); devstat. st_mode) ) { new_from_ devnum( udev, 'b', devstat.st_rdev); get_property_ value(udev_ device, "ID_FS_TYPE"); device_ unref(udev_ device) ;
while (1) {
struct stat devstat;
const char *type;
struct udev_device *udev_device;
if (stat(path, &devstat) || !S_ISBLK(
sleep(1);
continue;
}
udev_device = udev_device_
if (!udev_device) {
sleep(1);
continue;
}
type = udev_device_
if (type)
printf("%s\n", type);
udev_
if (type)
break;
}
udev_unref(udev);
exit(0);
}
---------- simplified wait-for-root.c end ----------