mount script doesn't poll if root device has been initialized, preventing udev+mdadm/lvm/cryptsetup to do its job

Bug #83025 reported by Dominik Sauer
14
Affects Status Importance Assigned to Milestone
initramfs-tools
Fix Released
Undecided
Unassigned
initramfs-tools (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

script '/usr/share/initramfs-tools/scripts/init-premount/udev' launches cold plugging of devices on background, then terminates immediately. this causes mdadm md array assembly to fail, because it doesn't see it's /dev/sd?? devices yet. Ugly hack is to sleep 20 after launching the coldplug.

The script that mounts the root fs should enter a loop checking if all the root device has come up, and if that has not happened for a while start an md device in degraded mode.

Something like
  If rootfs depends on a md device,
    while timeout not reached, do:
      if root md device has come up, continue booting
      wait 0.5 seconds
    done.
    if timeout has been reached:
      mdadm --run <root md device>

The udev lvm/crypt/ hotplug then goes on, so...
  if rootfs then depends on a lvm device
     while timeout not reached ....

(check https://wiki.ubuntu.com/BootDegradedRaid)

Revision history for this message
Daniele Pilenga (daniele-pilenga) wrote : Re: initramfs-tools script doesn't wait for device initialization, cryptoroot doesn't find any device to attach

The scripts in initramfs that should attach the root volume do not find any device as the kernel has not yet finished probing. Adding a little sleep helps, but it's not a solution.

Revision history for this message
Nicolas Schmerber (nschmerber) wrote : Re: initramfs-tools script doesn't wait for device initialization, preventing mdadm to assemble md arrays

Hi,

I have the same problem on raid1 initialization at startup. Config is :

Kernel : 2.6.20-13 of feisty
HW : 2 Sata drive on a ata_piix module dependand card, assembled in soft raid1

At grub prompt, without a break=premount, the kernel launches and tries to assemble the raid1 array, without seeing the 2 drives, the ata_piix module is only loaded 3seconds later but too late.
with the break point i can load the module i need, and just continue without any problems.

Regards

Revision history for this message
darthvader (sarmbruster) wrote :

I can confirm this bug. It should be considered as a blocker for the Feisty release.

Revision history for this message
Dominik Sauer (dominik-sauer) wrote : Re: [Bug 83025] Re: initramfs-tools script doesn't wait for device initialization, preventing mdadm to assemble md arrays

The sleep 20 would not be a solution, but busy waiting, like

wait=yes
while [ $wait == yes ] ; do
  (do some mdstuff)
  if [ $? == 0 ]; then
    wait=no
  else
    sleep 3
  fi
done

would do.
IMHO.

Revision history for this message
Dominik Sauer (dominik-sauer) wrote : Re: initramfs-tools script doesn't wait for device initialization, preventing mdadm to assemble md arrays

The sleep 20 would not be a solution, but busy waiting, like

wait=yes
while [ $wait == yes ] ; do
  (do some mdstuff)
  if [ $? == 0 ]; then
    wait=no
  else
    sleep 3
  fi
done

would do.
IMHO.

Revision history for this message
Christoph Rauch (christoph-rauch) wrote :

I get the same effect (mdadm does not start arrays), similar setup as Dominik (ata_piix, raid1), but apparently a different cause for the problem.

According to ps udevd is not started at all when mdadm bails out. If I start the udev start script manually the device nodes appear and the mdadm script can initialize the arrays.

Changed in initramfs-tools:
status: Unconfirmed → Confirmed
Revision history for this message
Christoph Rauch (christoph-rauch) wrote :

I solved my problem by adding "auto=yes" to the device section in mdadm.conf and afterwards rerunning
update-initramfs -u -k all

The system boots now, a pristine Feisty installation although would not boot.

Revision history for this message
Dominik Sauer (dominik-sauer) wrote : Re: [Bug 83025] Re: initramfs-tools script doesn't wait for device initialization, preventing mdadm to assemble md arrays

well, the udev is started up (and the "coldplug" events triggered) in
/usr/share/initramfs-tools/scripts/init-premount/udev; which is the very
script i add the sleep 20 at the end of.

On 4/11/07, Christoph Rauch <email address hidden> wrote:
>
> I get the same effect (mdadm does not start arrays), similar setup as
> Dominik (ata_piix, raid1), but apparently a different cause for the
> problem.
>
> According to ps udevd is not started at all when mdadm bails out. If I
> start the udev start script manually the device nodes appear and the
> mdadm script can initialize the arrays.
>
>
> ** Changed in: initramfs-tools (Ubuntu)
> Status: Unconfirmed => Confirmed
>
> --
> initramfs-tools script doesn't wait for device initialization, preventing
> mdadm to assemble md arrays
> https://bugs.launchpad.net/bugs/83025
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
ceg (ceg) wrote : Re: initramfs-tools script doesn't wait for device initialization, preventing mdadm to assemble md arrays

To fix the issue the md, cryptsetup, etc. scripts that set up the root device need to wait for their device to get set up by udev and timeout after a while (possibly running a degraded raid).

https://wiki.ubuntu.com/HotplugRaid
https://wiki.ubuntu.com/BootDegradedRaid

Revision history for this message
ceg (ceg) wrote :

md and lvm devices are actually handled by udev rules.

For one, cryptsetup handling needs go into a waiting loop (Bug #247153), or also be handled by udev rules.

For two, the initramfs script that mounts the rootfs needs go into a waiting loop (0.5 sec intervals) for their devices (going on quickly when device gets available) and timeout after a while.

ceg (ceg)
description: updated
Revision history for this message
ceg (ceg) wrote :

/usr/share/initramfs-tools/scripts/local in 8.04 contains a checking loop.

Changed in initramfs-tools:
status: Confirmed → Fix Released
Revision history for this message
ceg (ceg) wrote :

initramfs/scripts/local in 8.04 does have a timeout loop for the root device.

The remaining mdadm bug numbers are listed on https://wiki.ubuntu.com/BootDegradedRaid

Changed in initramfs-tools:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.