When the Linux kernel boots, it needs to be told what to run next. That program, the “init process”, a.k.a. “PID 1”, is the first process that will run, and is responsible for readying the system for all of the other processes that will be run. Normally this is System V Init or System D, a fully-featured system that does quite a lot.
But at the core, what does the init process need to do, to provide a “fully-operational” Linux system? It needs to do a few things, in order:
- Dig through
/systo see what devices exist
/devwith nodes (not files) that represent hardware devices.
- (Maybe start some background processes (daemons)?)
- (Maybe do some login stuff?)
/dev directory is a core part of POSIX, that Operating System standard that Unix and Linux conform to. But if having
/dev is core to POSIX, and the Linux kernel doesn’t handle it itself, is the kernel really POSIX?
Note also that
/sys don’t exist until the init process mounts them. This is a single Kernel API call. So why doesn’t the kernel do it?
I’m sure the answer to this is “because modularity”, but does it really make sense for such basic functionality to be swapped out or replaced? It seems that originally, Linux distros (if such a thing existed, and people weren’t cobbling Linux installs together from scratch) just had a hard-coded
/dev/tty1, etc. Or maybe people manually created them. Who knows. In about 1995, however, someone wrote
devfs, a tool for auto-populating
/dev. In 2000, it was included in the kernel itself. At some point later, it was replaced by
devtmpfs, which seems functionally equivalent.
- Linux Filesystem Hierarchy – Binh Nguyen [Linux+Filesystem+Hierarchy.pdf]
- The Linux Device File-System – Richard Gooch [devfs.pdf]
- Using DevFS – Alessandro Rubini [Using+Devfs.pdf]
- Devtmpfs source code – Kay Sievers. others [devtmpfs.c – drivers/base/devtmpfs.c – Linux source code (v5.11.3) – Bootlin]