4 # Required-Start: mountvirtfs
8 # Short-Description: Start udevd, populate /dev and load drivers.
11 # we need to unmount /dev/pts/ and remount it later over the tmpfs
13 if mountpoint -q /dev/pts/; then
17 if mountpoint -q /dev/shm/; then
22 # mount a tmpfs over /dev, if somebody did not already do it
24 if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then
28 # /dev/.static/dev/ is used by MAKEDEV to access the real /dev/ directory.
29 # /etc/udev/ is recycled as a temporary mount point because it's the only
30 # directory which is guaranteed to be available.
31 mount -n -o bind /dev /etc/udev
33 if ! mount -n -o size=$tmpfs_size,mode=0755 -t tmpfs tmpfs /dev; then
35 echo "udev requires tmpfs support, not started."
39 mkdir -p /dev/.static/dev
40 chmod 700 /dev/.static/
41 # The mount options in busybox are non-standard...
42 if test -x /bin/mount.util-linux
44 /bin/mount.util-linux --move /etc/udev /dev/.static/dev
45 elif test -x /bin/busybox
47 busybox mount -n -o move /etc/udev /dev/.static/dev
49 echo "udev requires an identifiable mount command, not started."
56 # I hate this hack. -- Md
58 if [ "$(echo /lib/udev/devices/*)" != "/lib/udev/devices/*" ]; then
59 cp -a /lib/udev/devices/* /dev/
62 [ -e /etc/udev/links.conf ] || return 0
63 grep '^[^#]' /etc/udev/links.conf | \
64 while read type name arg1; do
65 [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
67 L) ln -s $arg1 /dev/$name ;;
68 D) mkdir -p /dev/$name ;;
69 M) mknod -m 600 /dev/$name $arg1 ;;
70 *) echo "links.conf: unparseable line ($type $name $arg1)" ;;
77 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
78 2.6.1[01]|2.6.1[01][!0-9]*) return 1 ;;
83 set_hotplug_handler() {
85 2.6.1[0-4]|2.6.1[0-4][!0-9]*) HANDLER='/sbin/udevsend' ;;
87 echo $HANDLER > /proc/sys/kernel/hotplug
90 # shell version of /usr/bin/tty
92 [ -x /bin/readlink ] || return 0
93 [ -e /proc/self/fd/0 ] || return 0
94 readlink --silent /proc/self/fd/0 || true
97 warn_if_interactive() {
98 if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then
103 if [ -z "$TTY" -o "$TTY" = "/dev/console" ]; then
107 printf "\n\n\nIt has been detected that the command\n\n\t$0 $*\n\n"
108 printf "has been run from an interactive shell.\n"
109 printf "It will probably not do what you expect, so this script will wait\n"
110 printf "60 seconds before continuing. Press ^C to stop it.\n"
111 printf "RUNNING THIS COMMAND IS HIGHLY DISCOURAGED!\n\n\n\n"
115 ##############################################################################
117 PATH="/sbin:/bin:/usr/bin"
119 [ -x /sbin/udevd ] || exit 0
126 . /etc/udev/udev.conf
128 if ! supported_kernel; then
129 echo "udev requires a kernel >= 2.6.12, not started."
133 if [ ! -e /proc/filesystems ]; then
134 echo "udev requires a mounted procfs, not started."
138 if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
139 echo "udev requires tmpfs support, not started."
143 if [ ! -d /sys/class/ ]; then
144 echo "udev requires a mounted sysfs, not started."
148 if [ ! -e /proc/sys/kernel/hotplug ]; then
149 echo "udev requires hotplug support, not started."
153 ##############################################################################
155 # When modifying this script, do not forget that between the time that
156 # the new /dev has been mounted and udevsynthesize has been run there will be
157 # no /dev/null. This also means that you cannot use the "&" shell command.
161 if [ -e "$udev_root/.udev/" ]; then
162 if mountpoint -q /dev/; then
165 echo ".udev/ already exists on the static $udev_root!"
171 echo "Starting the hotplug events dispatcher" "udevd"
176 if [ -z "$TMPFS_MOUNTED" ]; then
179 [ -d /proc/1 ] || mount -n /proc
182 # if this directory is not present /dev will not be updated by udev
183 mkdir -p /dev/.udev/ /dev/.udev/db/ /dev/.udev/queue/ /dev/.udevdb/
184 # /dev/null must be created before udevd is started
187 echo "Synthesizing the initial hotplug events"
190 # wait for the udevd childs to finish
191 echo "Waiting for /dev to be fully populated"
192 while [ -d /dev/.udev/queue/ ]; do
194 udevd_timeout=$(($udevd_timeout - 1))
195 if [ $udevd_timeout -eq 0 ]; then
200 if [ $udevd_timeout -eq 0 ]; then
206 echo "Stopping the hotplug events dispatcher" "udevd"
207 start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5
210 restart|force-reload)
211 echo "Stopping the hotplug events dispatcher" "udevd"
212 if start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5; then
216 echo "Starting the hotplug events dispatcher" "udevd"
221 echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}"