encrypted root initialisation races/fails on hotplug devices (does not wait)

Bug #247153 reported by Gaspar Sinai
4
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I installed ubuntu 8.0.4 to a USB flash drive. I have a volume group that contains encrypted root and swap logical volumes. On some machines the USB drive appears later than initramfs:/scripts/local-top/cryptroot enters /conf/conf.d/cryptroot.

As a hack I put in a 10 seconds delay:

*** scripts/local-top/cryptroot- 2008-07-09 00:26:36.000000000 +0900
--- scripts/local-top/cryptroot 2008-07-09 00:27:14.000000000 +0900
***************
*** 271,274 ****
--- 271,275 ----
  # Do we have any settings from the /conf/conf.d/cryptroot file?
  if [ -r /conf/conf.d/cryptroot ]; then
+ sleep 10
        while read mapping; do
                setup_mapping "$mapping"

This is only temporary, a better solution could be to wait in activate_vg for the device to appear before setting up the volume group, just like https://launchpad.net/bugs/85640.

If you can provide a patch that is better than this I could try it out. I will be offline for 3 weeks.

Revision history for this message
Gaspar Sinai (gazsi) wrote :

After reading my report I noticed that I was not quite clear on how I set up the system.
Here is my /conf/conf.d/cryptroot in initramfs:

target=sdc5_crypt,source=/dev/disk/by-uuid/139c41d5-3699-4032-a827-3e9fc45aac7a,key=none,lvm=UUID=eecf28c6-9f0c-46f1-a8b4-14268677c4c4
target=sdc5_crypt,source=/dev/disk/by-uuid/139c41d5-3699-4032-a827-3e9fc45aac7a,key=none,lvm=gaspar-swap

/dev/disk/by-uuid/139c41d5-3699-4032-a827-3e9fc45aac7a is the disk that is slow to appear.

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

IMHO the cryptsetup scripts in initramfs should go into a waiting loop (0.5 sec intervals) for their devices (going on quickly when device is available) and timeout after a while.

Lets get rid of long sleep workarounds and race conditions.

Revision history for this message
ceg (ceg) wrote : Re: encrypted root initialisation does not wait for its device to appear

Alternatively cryptsetup may be handled by udev rules, similar as md and lvm devices are.

Revision history for this message
ceg (ceg) wrote :

Just checked that the same applies for encrypted non-rootfilesystems on external disks, too. (/etc/init.d/cryptdisks*)

Since md and lvm devices are set up by udev, cryptdisks scripts need to contain a waiting loop for their disks, or need to be called by udev rules themselves.

Revision history for this message
ceg (ceg) wrote :

present in 9.10

summary: - encrypted root initialisation does not wait for its device to appear
+ encrypted root initialisation races/fails on hotplug devices (does not
+ wait)
Revision history for this message
ceg (ceg) wrote :

Current state of ubuntu systems with md raid: https://wiki.ubuntu.com/ReliableRaid

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.