Opened 8 years ago

Last modified 8 years ago

#10045 accepted defect

openwrt trunk does not use hotplug2

Reported by: anonymous Owned by: amain
Priority: critical Milestone: milestone:next-release
Component: openwrt Version: 12.09
Severity: severity 1 Keywords:


The preinit script is unable to find devices because openwrt/trunk does not use hotplug2 anymore. Adapting to the new toolchain may work but introduces lots of dependencies for simple device creation that Debian will do later on again. Therefor I'd suggest to do device creation manually:

Index: openwrt/files/package/base-files/files/etc/preinit
--- openwrt/files/package/base-files/files/etc/preinit  (revision 639)
+++ openwrt/files/package/base-files/files/etc/preinit  (working copy)
@@ -18,14 +18,35 @@
 mount -t tmpfs tmpfs /dev -o mode=0755,size=512K
 mount -t tmpfs tmpfs /tmp -o size=3m,nosuid,nodev,mode=1777
 [ -c /dev/console ] || mknod /dev/console c 5 1
-/sbin/hotplug2 --set-worker /lib/hotplug2/ --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
-/sbin/hotplug2 --set-worker /lib/hotplug2/ --set-rules-file /etc/hotplug2-init.rules --persistent &

+mkdev() {
+    # argument is /sys/block/sdX or /sys/block/sdX/sdXN
+    devpath="${1}"
+    if [ -f ${devpath}/dev ]; then
+        devname=$(basename ${devpath})
+        if [ ! -e /dev/${devname} ]; then
+            mknod /dev/${devname} b $(cat ${devpath}/dev | sed "s/:/\ /g")
+        fi
+    fi
+find_blockdevs() {
+    for bdev in /sys/block/*; do
+        if [ -e ${bdev}/dev ]; then
+            mkdev ${bdev}
+            for subdev in ${bdev}/*/dev; do
+                mkdev $(dirname ${subdev})
+            done
+        fi
+    done
 wait_for_root_device() { # return: (default) root device
    local n=0
    local dev=""

    while [ $n -lt $WAIT ]; do
+      find_blockdevs
       dev=$(blkid -t LABEL=$ROOT_LABEL)
       if [ "" != "$dev" ]; then
@@ -49,7 +70,6 @@
    # pivot_root to it and run /sbin/init
    # or kexec if /boot/vmlinux.elf is found on the new root

-   killall hotplug2
    mount $dev /mnt

    if [ -f /mnt/boot/vmlinux.elf ] && ! grep -q "kexec=1" /proc/cmdline; then

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by amain

  • Owner set to amain
  • Status changed from new to accepted

Thanks you very much for supplying this patch. I'll apply it if I don't have the time to find a easy solution to fully restore the original functionality.

comment:2 Changed 8 years ago by amain

  • Component changed from other to openwrt
  • Severity changed from severity 4 to severity 1

comment:3 Changed 8 years ago by amain

  • Priority changed from minor to critical

Add Comment

Modify Ticket

as accepted The owner will remain amain.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.