A better way of managing device nodes
Creating device nodes statically with mknod
is hard work and inflexible. However, there are other ways to create device nodes automatically on demand:
devtmpfs
: This is a pseudo filesystem that you mount over/dev
at boot time. The kernel populates it with device nodes for all the devices that the kernel currently knows about. The kernel also creates nodes for new devices as they are detected at runtime. The nodes are owned byroot
and have default permissions of0600
. Some well-known device nodes, such as/dev/null
and/dev/random
, override the default to0666
. To see exactly how this is done, look at thedrivers/char/mem.c
file in the Linux source tree and observe howstruct memdev
is initialized.mdev
: This is a BusyBox applet that is used to populate a directory with device nodes and create new nodes as needed. There is an/etc/mdev.conf
configuration file that contains rules for the ownership and mode of the nodes.
...