Tweaks to bootscripts
[linux_from_scratch.git] / bootscripts / lfs / init.d / udev
bloba1834891df9111d8bab98bb979bd87f4f4f28a29
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/udev
5 # Description : Udev cold-plugging script
7 # Authors : Zack Winkles, Alexander E. Patrakov
9 # Version : 00.02
11 # Notes :
13 ########################################################################
15 . /etc/sysconfig/rc
16 . ${rc_functions}
18 case "${1}" in
19 start)
20 boot_mesg "Populating /dev with device nodes..."
21 if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
22 echo_failure
23 boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE}
24 boot_mesg -n " devices without a SysFS filesystem"
25 boot_mesg -n "\n\nAfter you press Enter, this system"
26 boot_mesg -n " will be halted and powered off."
27 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
28 boot_mesg "" ${NORMAL}
29 read ENTER
30 /etc/rc.d/init.d/halt stop
33 # Mount a temporary file system over /dev, so that any devices
34 # made or removed during this boot don't affect the next one.
35 # The reason we don't write to mtab is because we don't ever
36 # want /dev to be unavailable (such as by `umount -a').
37 if ! mountpoint /dev > /dev/null; then
38 mount -n -t tmpfs tmpfs /dev -o mode=755
40 if [ ${?} != 0 ]; then
41 echo_failure
42 boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE}
43 boot_mesg -n " onto /dev, this system will be halted."
44 boot_mesg -n "\n\nAfter you press Enter, this system"
45 boot_mesg -n " will be halted and powered off."
46 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
47 boot_mesg "" ${NORMAL}
48 read ENTER
49 /etc/rc.d/init.d/halt stop
52 ln -s /run/shm /dev/shm
54 # Udev handles uevents itself, so we don't need to have
55 # the kernel call out to any binary in response to them
56 echo > /proc/sys/kernel/hotplug
58 # Copy the only static device node that Udev >= 155 doesn't
59 # handle to /dev
60 cp -a /lib/udev/devices/null /dev
62 # Start the udev daemon to continually watch for, and act on,
63 # uevents
64 /sbin/udevd --daemon
66 # Now traverse /sys in order to "coldplug" devices that have
67 # already been discovered
68 /sbin/udevadm trigger --action=add
70 # Now wait for udevd to process the uevents we triggered
71 /sbin/udevadm settle
72 evaluate_retval
77 echo "Usage ${0} {start}"
78 exit 1
80 esac
82 # End $rc_base/init.d/udev