What is a Root File System in Linux?

Beaglebone black board






In this article, we explain what a root file system in linux is.

The root file system is a file system which linux mounts to the "/" (root).

A file system is a collection of files organized in a standard tree structure.

There is a standard for the linux file system and this is referred to as the "File system Hierarchy Standard".

A typical file system in linux will have the following folders shown below, even though all these folders are not required for linux to boot and mount the file system successfully.


bin/

The bin directory contains essential command binaries.

The directory contains binaries of linux commands which are used by both the system admins and users. Using the commands in this folder does not require privileges from the System admin to execute these commands, neither do they require root access. Know that this folder does not contain binaries for all of the linux commands and there is a restriction on what types of commands have to be placed in this directory, because these binaries are those which can be executed by the common user (one without special privileges or root access).

Some of the commands you will find in the bin directory includes cat (command to concatenate files to standard output), chgrp (command to change file group ownership), chmod (command to change file access permissions), chown (command to change file owner and group), cp (command to copy files and directories), date (command to print or set the system data and time), dd (command to convert and copy a file), df (command to report file system disk space usage), dmesg (command to print or control the kernel message buffer), echo (command to display a line of text), hostname (command to show or set the system's host name), kill (command to send siganls to processes), in (command to make links between files), login (command to begin a session on the system), ls (command to list directory contents), mkdir (command to create a directory), mknod (command to make block or character special files), more (command to page through text), mount (command to mount a file system), mv (command to move/rename files), ps (commadn to report process status), and pwd (command to print the name of a current working directory).

Other commands that have to do with installing, removing, recovering, restoring, repairing, or configuring are not found in this directory.


boot/

The boot directory contains the static files of the boot loader. These are the files needed to boot the linux kernel.

This directory contains the boot related files, which are required to boot linux. This directory may be read by the boot loader to read the boot images like the linux kernel image, dtb, initramfs, etc.

So this directory may be accessed by the boot loader even before the kernel boots and mounts the file system.


dev/

This is directory where you can find the device files.

In Unix/Linux, devices are treated like file access.

If you want access to any network device, memory device, serial device, parallel device, or I/O (input/output) device such as a keyboard, mouse, display, everything will be treated like a file.

So this directory will have the file entry for every device.

For example, the ram may have a device file entry like dev/ram0

The 2 partitions of the SD card may have entries such as /dev/mmcblk0p1 or /dev/mmcblk0p2

The serial devices may have entries such as /dev/ttyS0, /dev/ttyS1, and /dev/ttyO0

The I2C devices may have file entries such as /dev/i2c-0 and /dev/i2c-1

It is the responsibility of the respective drivers to populate this directory with the device files.


etc/

This is the directory which contains host-specific system configuration files.

This is where all start-up scripts, networking scripts, scripts to start and stop networking protocols like NFS, networking configuration files, various other configuration files like passwd, hostinfo, etc., and different run level scripts will be stored.


lib/

The lib directory stands for libraries. This directory contains essential shared libraries and kernel modules.

This directory contains dynamically loadable kernel modules. When we compile the kernel modules and run the "modules install" command, all the kernel modules will go and sit in this directory under the subdirectory "modules".

the lib directory is also used to store the essential shared libraries (.so.*) for dynamic linking. Examples of these include the 'C' shared library (libc), math library, etc.


media/

The media directory ist he mount point for removable media like USB devices, SD cards, etc.

For example, if you plug in a USB, it will be automatically mounted under the /media directory.


mnt/

This is the directory where you can mount the temporary file system.

The system admins can use linux commands to temporarily mount and un-mount the file system.


opt/

"opt" stands for "optional".

This directory is used to store any installed packages in linux. e

So if you run the command sudo apt-get install package-name, that package will be stored in this directory.


sbin/

The commands which come in the category of system administration wil be stored in this directory, which is used by sys admins for the purpose of doing high-privilege activities such as network configurations, repairing, restoring, and recovering.

This directory has root only commands.


home/

The /home directory contains a home folder for each user.

This directory will be used to store personal data of the user.


srv/

The /srv directory contains "data for services provided by the system".

If you are using the Apache HTTP server to serve a website, you'd likely store your website's files in a directory inside the /srv directory.


tmp/

Applications store temporary files in the /tmp directory.


usr/

This is a secondary hierarchy in terms that it contains several subdirectories.

These subdirectories are shown below.

The bin directory contains most user commands.

The lib directory contains libraries.

The sbin directory contains non-vital system binaries.

The /usr/bin contains binaries of the commands for user programs.

For example, if you have chrome on your system, then it would be available under "/user/bin", not /bin. This is because it is a user-installed program.

So the root file system is nothing other than all the directories that mount to the root (/) directory operating system of linux.



Related Resources





HTML Comment Box is loading comments...