Replace mdev with udev, add some script to make udev works correctly.
This commit is contained in:
@@ -21,13 +21,79 @@ UDEV_CONFIG=/etc/udev/udev.conf
|
||||
test -r $UDEV_CONFIG || exit 6
|
||||
. $UDEV_CONFIG
|
||||
|
||||
# we need to unmount /dev/pts/ and remount it later over the devtmpfs
|
||||
unmount_devpts() {
|
||||
if mountpoint -q /dev/pts/; then
|
||||
umount -n -l /dev/pts/
|
||||
fi
|
||||
|
||||
if mountpoint -q /dev/shm/; then
|
||||
umount -n -l /dev/shm/
|
||||
fi
|
||||
}
|
||||
|
||||
# mount a devtmpfs over /dev, if somebody did not already do it
|
||||
mount_devtmpfs() {
|
||||
if grep -E -q "^[^[:space:]]+ /dev devtmpfs" /proc/mounts; then
|
||||
mount -n -o remount,nosuid,mode=0755 -t devtmpfs devtmpfs /dev
|
||||
return
|
||||
fi
|
||||
|
||||
if ! mount -n -o nosuid,mode=0755 -t devtmpfs devtmpfs /dev; then
|
||||
echo "udev requires devtmpfs support, not started"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
create_dev_makedev() {
|
||||
if [ -e /sbin/MAKEDEV ]; then
|
||||
ln -sf /sbin/MAKEDEV /dev/MAKEDEV
|
||||
else
|
||||
ln -sf /bin/true /dev/MAKEDEV
|
||||
fi
|
||||
}
|
||||
|
||||
make_static_nodes() {
|
||||
[ -e /lib/modules/$(uname -r)/modules.devname ] || return 0
|
||||
[ -x /bin/kmod ] || return 0
|
||||
|
||||
/bin/kmod static-nodes --format=tmpfiles --output=/proc/self/fd/1 | \
|
||||
while read type name mode uid gid age arg; do
|
||||
[ -e $name ] && continue
|
||||
case "$type" in
|
||||
c|b|c!|b!) mknod -m $mode $name $type $(echo $arg | sed 's/:/ /') ;;
|
||||
d|d!) mkdir $name ;;
|
||||
*) echo "unparseable line ($type $name $mode $uid $gid $age $arg)" >&2 ;;
|
||||
esac
|
||||
|
||||
if [ -x /sbin/restorecon ]; then
|
||||
/sbin/restorecon $name
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if ! mountpoint -q /dev/; then
|
||||
unmount_devpts
|
||||
mount_devtmpfs
|
||||
fi
|
||||
|
||||
make_static_nodes
|
||||
|
||||
# clean up parts of the database created by the initramfs udev
|
||||
udevadm info --cleanup-db
|
||||
|
||||
# set the SELinux context for devices created in the initramfs
|
||||
[ -x /sbin/restorecon ] && /sbin/restorecon -R /dev
|
||||
|
||||
printf "Populating %s using udev: " "${udev_root:-/dev}"
|
||||
[ -e /proc/sys/kernel/hotplug ] && printf '\000\000\000\000' > /proc/sys/kernel/hotplug
|
||||
/sbin/udevd -d || { echo "FAIL"; exit 1; }
|
||||
udevadm trigger --type=subsystems --action=add
|
||||
udevadm trigger --type=devices --action=add
|
||||
create_dev_makedev
|
||||
udevadm settle --timeout=30 || echo "udevadm settle failed"
|
||||
echo "done"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user