4

Devices can be mounted to a path. For example "/dev/sda1" can be mounted to "/home/user". What I don't understand is how and where the " / " is mounted during boot. Any help explaining?

  • when you installed linux/unix os.You should define which partition as / ,/home and /boot. All the mount point are defined in /etc/fstab.You booted it up.The system will read the /etc/fstab file configuration. When you used automatically installation.You didnt define any partition.But linux os just got one partition /.You can check any mount point on /etc/fstab – supriady Jan 18 '17 at 6:04
6

During the boot of a Unix system, the kernel does a few things that it doesn't do during normal operation. One of these things is to mount a filesystem on the directory /; this is quite different from normal mounting operations since the mounting is not triggered of a mount system call, and the target directory is not an existing directory. Another thing is to execute a program as PID 1, which is different from normal operation since this creates a process without duplicating an existing process.

The way this “magic” mounting of the root directory is very different in different Unix variants. The kernel chooses what device to mount based on configuration parameters that may be specified in a variety of ways: compile-time configuration, runtime configuration in the kernel image, runtime configuration in some predefined memory location, command line parameters, … To find how it works on your machine, you would need to look at the documentation of your Unix variant, and find how your machine is configured.

To give an idea of how it works, here's an overview of how a modern Linux kernel operates. This is not the simplest example because Linux has a lot of history and varied use cases.

  • Linux can start with a “special” filesystem attached to the path /, which consists of files stored in RAM. This special filesystem is called initramfs; it's an instance of the rootfs filesystem type. The initramfs is populated by content either passed by the bootloader through an architecture-dependent protocol, compiled directly into the kernel image that is loaded into memory by the bootloader.
  • Alternatively, Linux can mount a device to / that is part of a restricted (but large) set of volume types that are recognized by the initialization code in the kernel. Such device types include any filesystem on common types of partitions on common types of disks (anything vaguely SCSI-like, including ATA, USB, etc.), as well as RAM disks and NFS mounts.
  • Depending on which path was taken, the initial root filesystem may later be shadowed or replaced by another. Shadowing is what happens with an initramfs, and that's how most desktop and server systems operate (embedded systems, on the other hand, often have a hard-coded root filesystem). Replacement is what happens with an initrd, which is a particular kind of RAM disk. The job of the initramfs or initrd is to load the drivers that provide the “real” root filesystem that will get used in normal operation.
| improve this answer | |
5

This is from the bootup(7) manual on an Ubuntu machine:

A number of different components are involved in the system boot. Immediately after power-up, the system BIOS will do minimal hardware initialization, and hand control over to a boot loader stored on a persistent storage device. This boot loader will then invoke an OS kernel from disk (or the network). In the Linux case, this kernel (optionally) extracts and executes an initial RAM disk image (initrd), such as generated by dracut(8), which looks for the root file system (possibly using systemd(1) for this). After the root file system is found and mounted, the initrd hands over control to the host's system manager (such as systemd(1)) stored on the OS image, which is then responsible for probing all remaining hardware, mounting all necessary file systems and spawning all configured services.

You would have found this by man boot, reading it and not finding the answer, but seeing "See also: bootup(7)" at the bottom of the manual.

Being curious, I then looked at the manual for initrd:

In the first boot-up phase, the kernel starts up and mounts an initial root filesystem from the contents of /dev/initrd (e.g., RAM disk initialized by the boot loader). In the second phase, additional drivers or other modules are loaded from the initial root device's contents. After loading the additional modules, a new root filesystem (i.e., the normal root filesystem) is mounted from a different device.

You mentioned "Unix", so I'll point you to the documentation for the OpenBSD first-stage system bootstrap and second-stage bootstrap too.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.