2.9 (En)
2.9 (En)
1. Write the operating system source code (or obtain previously written
source code).
2. Configure the operating system for the system on which it will run.
3. Compile the operating system.
4. Install the operating system.
5. Boot the computer and its new operating system.
The major differences among these approaches are the size and generality
of the generated system and the ease of modifying it as the hardware configu-
ration changes. For embedded systems, it is not uncommon to adopt the first
approach and create an operating system for a specific, static hardware config-
uration. However, most modern operating systems that support desktop and
laptop computers as well as mobile devices have adopted the second approach.
That is, the operating system is still generated for a specific hardware config-
uration, but the use of techniques such as loadable kernel modules provides
modular support for dynamic changes to the system.
We now illusrate how to build a Linux system from scratch, where it is
typically necessary to perform the following steps:
When the system reboots, it will begin running this new operating system.
Alternatively, it is possible to modify an existing system by installing a
Linux virtual machine. This will allow the host operating system (such as
Windows or macOS) to run Linux. (We introduced virtualization in Section 1.7
and cover the topic more fully in Chapter 18.)
There are a few options for installing Linux as a virtual machine. One
alternative is to build a virtual machine from scratch. This option is similar
to building a Linux system from scratch; however, the operating system does
not need to be compiled. Another approach is to use a Linux virtual machine
appliance, which is an operating system that has already been built and con-
figured. This option simply requires downloading the appliance and installing
it using virtualization software such as VirtualBox or VMware. For example,
to build the operating system used in the virtual machine provided with this
text, the authors did the following:
To save space as well as decrease boot time, the Linux kernel image is a
compressed file that is extracted after it is loaded into memory. During the boot
process, the boot loader typically creates a temporary RAM file system, known
as initramfs. This file system contains necessary drivers and kernel modules
that must be installed to support the real root file system (which is not in main
memory). Once the kernel has started and the necessary drivers are installed,
the kernel switches the root file system from the temporary RAM location to
the appropriate root file system location. Finally, Linux creates the systemd
process, the initial process in the system, and then starts other services (for
example, a web server and/or database). Ultimately, the system will present
the user with a login prompt. In Section 11.5.2, we describe the boot process
for Windows.
It is worthwhile to note that the booting mechanism is not independent
from the boot loader. Therefore, there are specific versions of the GRUB boot
loader for BIOS and UEFI, and the firmware must know as well which specific
bootloader is to be used.
The boot process for mobile systems is slightly different from that for
traditional PCs. For example, although its kernel is Linux-based, Android does
not use GRUB and instead leaves it up to vendors to provide boot loaders.
The most common Android boot loader is LK (for “little kernel”). Android
systems use the same compressed kernel image as Linux, as well as an initial
RAM file system. However, whereas Linux discards the initramfs once all
necessary drivers have been loaded, Android maintains initramfs as the root
file system for the device. Once the kernel has been loaded and the root file
system mounted, Android starts the init process and creates a number of
services before displaying the home screen.
Finally, boot loaders for most operating systems—including Windows,
Linux, and macOS, as well as both iOS and Android —provide booting into
recovery mode or single-user mode for diagnosing hardware issues, fixing
corrupt file systems, and even reinstalling the operating system. In addition to
hardware failures, computer systems can suffer from software errors and poor
operating-system performance, which we consider in the following section.