#!/sbin/runscript depend() { provide dev need sysfs } start() { ebegin "Mounting /dev (mdev)" # First umount /dev and friends if it is already mounted. # It may be leftover from initramfs mount --move, we don't # want to use it. umount /dev/pts /dev/shm /dev >/dev/null 2>&1 if fstabinfo --quiet /dev ; then mount -n /dev else mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" mdev-tmpfs /dev fi # Create a file so that our rc system knows it's still in sysinit. # Existance means init scripts will not directly run. # rc will remove the file when done with sysinit. touch /dev/.rcsysinit # Avoid race conditions, serialize hotplug events. touch /dev/mdev.seq # Some basic nodes. [ ! -e /dev/console ] && mknod /dev/console c 5 1 [ ! -e /dev/null ] && mknod /dev/null c 1 3 [ ! -e /dev/tty ] && mknod /dev/tty c 5 0 [ ! -e /dev/tty1 ] && mknod /dev/tty1 c 4 1 [ ! -e /dev/urandom ] && mknod /dev/urandom c 1 9 [ ! -e /dev/random ] && mknod /dev/random c 1 8 [ ! -e /dev/zero ] && mknod /dev/zero c 1 5 ln -snf /proc/self/fd /dev/fd ln -snf fd/0 /dev/stdin ln -snf fd/1 /dev/stdout ln -snf fd/2 /dev/stderr [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core mkdir -m 0755 /dev/pts /dev/shm /dev/mapper if [ -e /proc/sys/kernel/hotplug ] ; then ebegin "Setting up mdev as hotplug agent" echo /sbin/mdev > /proc/sys/kernel/hotplug eend 0 fi ebegin "Loading kernel modules for detected hardware" env -i /sbin/mdev -s # mdev -s does not poke network interfaces or usb devices so we need to do it here. for i in /sys/class/net/*/uevent; do printf 'add' > "$i"; done 2>/dev/null; unset i for i in /sys/bus/usb/devices/*; do case "${i##*/}" in [0-9]*-[0-9]*) printf 'add' > "$i/uevent" ;; esac done; unset i # Load kernel modules, run twice. find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a 2>/dev/null find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a 2>/dev/null eend 0 ebegin "Mounting /dev/pts" if ! fstabinfo --mount /dev/pts; then mount -n -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts fi eend "$?" ebegin "Mounting /dev/shm" if ! fstabinfo --mount /dev/shm; then mount -n -t tmpfs -o noexec,nosuid,nodev,mode=1777 shm-tmpfs /dev/shm fi eend "$?" } stop() { ebegin "Disabling mdev hotplug agent." [ -e /proc/sys/kernel/hotplug ] && echo '' >/proc/sys/kernel/hotplug eend 0 }