Chapter 5. The Linux Root Filesystem
In this chapter, you will learn about the root filesystem and its structure. You will also be presented with information about the root filesystem's content, the various device drivers available, and its the communication with the Linux kernel. We will slowly make the transition to the Yocto Project and the method used to define the Linux root filesystem's content. The necessary information will be presented to make sure that a user will be also able to customize the rootfs
filesystem according to its needs.
The special requirements of the root filesystem will be presented. You will be given information on its content, subdirectories, defined purposes, the various filesystem options available, the BusyBox alternative, and also a lot of interesting features.
When interacting with an embedded environment, a lot of developers would start from a minimal root filesystem made available by a distribution provider, such as Debian, and using a cross-toolchain will...
Interacting with the root filesystem
A root filesystem consists of a directory and file hierarchy. In this file hierarchy, various filesystems can be mounted, revealing the content of a specific storage device. The mounting is done using the mount command, and after the operation is done, the mount point is populated with the content available on the storage device. The reverse operation is called umount
and is used to empty the mount point of its content.
The preceding commands are very useful for the interaction of applications with various files available, regardless of their location and format. For example, the standard form for the mount
command is mount –t type device directory
. This command asks the kernel to connect the filesystem from the device that has the type
format mentioned in the command line, along with the directory mentioned in the same command. The umount
command needs to be given before removing the device to make sure the kernel caches are written in the storage point...
BusyBox was developed by Bruce Perens in 1999 with the purpose of integrating available Linux tools in a single executable. It has been used with great success as a replacement for a great number of Linux command line utilities. Due to this, and the fact that it is able to fit inside small embedded Linux distributions, it has gained a lot of popularity in the embedded environment. It provides utilities from file interactions, such as cp
, mkdir
, touch
, ls
, and cat
, as well as general utilities, such as dmesg
, kill
, fdisk
, mount
, umount
, and many others.
Not only is it very easy to configure and compile, but it is also very easy to use. The fact that it is very modular and offers a high degree of configuration makes it the perfect choice to use. It may not include all the commands available in a full-blown Linux distribution available on your host PC, but the ones that it does are more than enough. Also, these commands are just simpler versions of the full-blown ones used...
Now that all the information relating to the root
filesystem has been presented to you, it would be good exercise to describe the must-have components of the minimal root
filesystem. This would not only help you to understand the rootfs
structure and its dependencies better, but also help with requirements needed for boot time and the size optimization of the root
filesystem.
The starting point to describe the components is /sbin/init
; here, by using the ldd
command, the runtime dependencies can be found. For the Yocto Project, the ldd /sbin/init
command returns:
From this information, the /lib
directory structure is defined. Its minimal form is:
The following symbolic links to ensure backward compatibility and version immunity for the libraries. The linux...
Moving to the Yocto Project, we can take a look at the core-image-minimal to identify its content and minimal requirements, as defined inside the Yocto Project. The core-image-minimal.bb
image is available inside the meta/recipes-core/images
directory, and this is how it looks:
You can see here that this is similar to any other recipe. The image defines the LICENSE
field and inherits a bbclass
file, which defines its tasks. A short summary is used to describe it, and it is very different from normal package recipes. It does not have LIC_FILES_CHKSUM
to check for licenses or a SRC_URI
field, mostly because it does not need them. In return, the file defines the exact packages that should be contained in the root
filesystem...
In this chapter, you have learned about the Linux rootfs
in general, and also about the communication with the organization of the Linux kernel, Linux rootfs
, its principles, content, and device drivers. Since communication tends to become larger over time, information about how a minimal filesystem should look was also presented to you.
Besides this information, in the next chapter, you will be given an overview of the available components of the Yocto Project, since most of them are outside Poky. You will also be introduced to, and given a brief gist of, each component. After this chapter, a bunch of them will be presented to you and elaborated on.