# Linux Root Filesystem The root filesystem is the last component of embedded Linux. ## Requirements To make a minimal rootfs, these components are essential: - **init**: The init script is an executable binary which kicks everything off. More about it, in the [Initramfs section](./Initramfs.md). - **Shell**: A shell is needed for command prompts and running functions in the init script. - **Daemons**: Background programs providing services to others. E.g. dockerd, syslogd, sshd, ... - **Shared libraries**: Most programs depend on shared libraries - **Config files**: Series of files needed to configure systemd, init, etc. Usually present in */etc* - **Device nodes**: Special files giving access to device drivers. - **proc, sys fs**: Pseudo filesystem running in RAM and representing the Kernel structure as a hierarchy of files - **Kernel modules**: If kernel modules are used, they are (most of the time) stored in */lib/modules/[kernel version]* - **Device specific applications**: Apps that make the device do the job it is intended to do :::{note} The init file doesn't have to be the initial script. In case a developer has created his very own init script (e.g. /custom-init), it can replace the default init script by passing it to the kernel command line: **init=/custom-init** ::: ## Base structure The rootfs usually has the following base structure: - **/bin** => Symlink to /usr/bin: executable binaries. - **/dev** => Devices (Disks, tty, ...). - **/etc** => Static system configs. - **/home** => Home directory for system users. - **/lib** => Symlink to /usr/lib: Libraries, shared objects (.so files, ...). - **/proc** => Pseudo filesystem for kernel status and hardware info. - **/sbin** => symlinks /usr/sbin: System executables. - **/sys** => RAM-based pseudo filesystem to get info about the system. - **/tmp** => Temporary files. Gets wiped after reboot. - **/usr** => UnixSystemResources. Manpages, scripts, executables, ... - **/var** => Changing variables: Log-files, Game progress, printer queue, ... ## Additional: - **/boot** => Everything needed for booting, mounted on another partition. - **/lost+found** => Lost files and fragments that have been found by e.g. recovering from system damage. - **/opt** => Usually used for additional, non-free licensed programms. - **/root** => Home directory for root user. - **/run** => /var/run symlinks this. Used for daemons in early rootfs. More base information about the Linux rootfs [here](https://www.youtube.com/watch?v=rrB13utjYV4)! *sources:* - Mastering Embedded Linux Programming - Third Edition By Frank Vasquez, Chris Simmonds - [Linux in 100 seconds](https://www.youtube.com/watch?v=rrB13utjYV4)