3 UDEVSTART=/sbin/udevstart
9 [ -x $UDEVSTART ] || exit 0
13 ##############################################################################
15 # we need to unmount /dev/pts/ and remount it later over the tmpfs
17 if mountpoint -q /dev/pts/; then
21 if mountpoint -q /dev/shm/; then
26 # mount a tmpfs over /dev, if somebody did not already do it
28 if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then
32 # /dev/.static/dev/ is used by MAKEDEV to access the real /dev/ directory.
33 # /etc/udev/ is recycled as a temporary mount point because it's the only
34 # directory which is guaranteed to be available.
35 mount -n -o bind /dev /etc/udev
37 if ! mount -n -o size=$tmpfs_size,mode=0755 -t tmpfs tmpfs /dev; then
39 echo "udev requires tmpfs support, not started."
43 # using ln to test if /dev works, because touch is in /usr/bin/
44 if ln -s test /dev/test-file; then
47 echo "udev requires tmpfs support, not started."
53 mkdir -p /dev/.static/dev
54 chmod 700 /dev/.static/
55 # The mount options in busybox are non-standard...
56 if test -x /bin/mount.util-linux
58 /bin/mount.util-linux --move /etc/udev /dev/.static/dev
59 elif test -x /bin/busybox
61 busybox mount -n -o move /etc/udev /dev/.static/dev
63 echo "udev requires an identifiable mount command, not started."
70 # I hate this hack. -- Md
72 [ -e /etc/udev/links.conf ] || return 0
73 grep '^[^#]' /etc/udev/links.conf | \
74 while read type name arg1; do
75 [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
77 L) ln -s $arg1 /dev/$name ;;
78 D) mkdir -p /dev/$name ;;
79 M) mknod -m 600 /dev/$name $arg1 ;;
80 *) echo "links.conf: unparseable line ($type $name $arg1)" ;;
85 # this function is duplicated in preinst, postinst and d-i
88 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
89 2.6.1[01]|2.6.1[01][!0-9]*) return 1 ;;
94 # shell version of /usr/bin/tty
96 [ -x /bin/readlink ] || return 0
97 [ -e /proc/self/fd/0 ] || return 0
98 readlink --silent /proc/self/fd/0 || true
101 warn_if_interactive() {
102 if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then
107 if [ -z "$TTY" -o "$TTY" = "/dev/console" ]; then
111 printf "\n\n\nIt has been detected that the command\n\n\t$0 $*\n\n"
112 printf "has been run from an interactive shell.\n"
113 printf "It will probably not do what you expect, so this script will wait\n"
114 printf "60 seconds before continuing. Press ^C to stop it.\n"
115 printf "RUNNING THIS COMMAND IS HIGHLY DISCOURAGED!\n\n\n\n"
119 ##############################################################################
121 if ! supported_kernel; then
122 echo "udev requires a kernel >= 2.6.12, not started."
126 if [ ! -e /proc/filesystems ]; then
127 echo "udev requires a mounted procfs, not started."
131 if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
132 echo "udev requires tmpfs support, not started."
136 if [ ! -d /sys/class/ ]; then
137 echo "udev requires a mounted sysfs, not started."
141 if [ ! -e /proc/sys/kernel/hotplug ]; then
142 echo "udev requires hotplug support, not started."
146 ##############################################################################
148 # When modifying this script, do not forget that between the time that
149 # the new /dev has been mounted and udevstart has been run there will be
150 # no /dev/null. This also means that you cannot use the "&" shell command.
154 if [ -e "$udev_root/.udevdb" ]; then
155 if mountpoint -q /dev/; then
158 echo ".udevdb already exists on the old $udev_root!"
163 #echo /sbin/udevsend > /proc/sys/kernel/hotplug
164 echo "" > /proc/sys/kernel/hotplug
166 if [ "$UDEV_DISABLED" = "yes" ]; then
167 echo "udev disabled on the kernel command line, not started."
171 if [ ! "$TMPFS_MOUNTED" ]; then
174 [ -d /proc/1 ] || mount -n /proc
175 # if this directory is not present /dev will not be updated by udev
177 echo "Creating initial device nodes..."
184 start-stop-daemon --stop --exec /sbin/udevd --quiet
186 if [ -d /dev/.static/dev/ ]; then
187 umount -l /dev/.static/dev/ || true
189 echo "Unmounting /dev..."
190 # unmounting with -l should never fail
191 if ! umount -l /dev; then
195 restart|force-reload)
196 start-stop-daemon --stop --exec /sbin/udevd --quiet
197 log_begin_msg "Recreating device nodes..."
203 echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}"