FS#18428 - [mkinitcpio] waiting for usb devices to settle
Attached to Project:
Arch Linux
Opened by Michael Gutmann (Gutnix) - Monday, 22 February 2010, 09:29 GMT
Last edited by Thomas Bächler (brain0) - Sunday, 27 February 2011, 11:33 GMT
Opened by Michael Gutmann (Gutnix) - Monday, 22 February 2010, 09:29 GMT
Last edited by Thomas Bächler (brain0) - Sunday, 27 February 2011, 11:33 GMT
|
Details
Description:
Booting a normal Arch installation from USB sticks makes problems with slow usb sticks and f.e. root fs on lvm. The lvm hook runs when the device has'nt appeared and therefore a root fs on lvm is not found. I propose to add a usb hook (there is none at the moment), which waits a configurable amount of seconds defined via a kernel commandline variable "usbdelay". A reasonable default could be 10 (at least it works with my usb stick ;-)). For it to work the usb hook should be put before mdadm, lvm2 and filesystems in HOOKS in mkinitcpio.conf. Package: mkinitcpio New file: /lib/initcpio/hooks/usb # vim: set ft=sh: run_hook () { if [ -z "${usbdelay}" ] || ! [ "${usbdelay}" -ge 0 ]; then export usbdelay=10 fi msg ":: waiting $usbdelay seconds for usb devices to settle..." sleep $usbdelay msg ":: waiting for usbdevices done." } Changes to: /lib/initcpio/install/usb 14c14 < SCRIPT="" --- > SCRIPT="usb" |
This task depends upon
1) Have LVM auto-assembled by udev. I have no idea if this is easily possible, and it probably requires changes in the upstream device-mapper code. This would be the most elegant solution as our usual poll_device logic will start working with slow devices.
2) Try vgscan && vgchange in a loop until a certain volume group has been found. This will be very ugly code.
3) Add a possiblity to specify a device to "wait" for before assembling LVM (using the poll_device method).
4) Add a generic "sleep" hook with which we can insert arbitrary sleeps in the mkinitcpio configuration. This would be similar to the solution propsed above, only that it would be done separately of the usb hook and thus be a more generic solution.
Solution 1) would be the most favorable, but is probably not possible right now. 2) is ugly and I don't want it. 3) seems like a good idea (you could use the UUID of the physical volume and specify lvmwait=/dev/disk/by-uuid/$uuid on the command line) as it would only wait as long as needed, but requires specific user configuration (in particular: knowledge of the UUID of the physical volume). 4) could be useful for many more things and should be implemented in any case.
On the other hand I was thinking about something like 4) too. It would be nice to have a method to delay booting between hooks, although I don't know, if a boot delay is necessary elsewhere than waiting for /.
Looking into 3) now.
Can you test this please? Just download the lvm2_install and lvm2_hook files from websvn and put them to /lib/initcpio/install/lvm2 and /lib/initcpio/hooks/lvm2 respectively.
3) works like a charm! But there is a problem with the uuid: the uudis from PVs are not shown in /dev/disk/by-uuid, although blkid reports a uuid for the device. Where does poll_wait look for the uuid?
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
to
ENV{ID_FS_USAGE}=="filesystem|other|crypto|raid", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
in /lib/udev/rules.d/13-dm-disk.rules and /lib/udev/rules.d/60-persistent-storage.rules. I don't know if that is a good idea, or a bad one, from what I see it shouldn't harm anyone. It probably won't be accepted upstream though. I may have to take this problem to the dm-devel mailing list.
Thomas: Feel free to remove lvm2/device-mapper from testing if the hooks changes are not ready yet.
Michael, can you please try this? The solution should be much cleaner: http://mailman.archlinux.org/pipermail/arch-general/2010-March/011746.html
It should work without any additional kernel parameters and replaces the lvm2 hook.
Closing.