How is the filesystem bootstrapped, given that we start on a different partition?
Typically, one has /boot or /boot/efi on a separate partition, using some simple filesystem like FAT32 that the bootloader can handle. At startup, Linux needs to be able to set up the entire / filesystem, across multiple partitions.
Of course, booting can use a temporary in-memory filesystem (the "initramfs") and doesn't need to care about the fact that the partition it's running from is not where the eventual filesystem root will be. But the rules for mounting partitions are in /etc/fstab, which generally will be on a different partition.
During the boot sequence, how does Linux find /etc/fstab in order to be able to set up the filesystem?
1 answer
The root partition is noted explicitly in the configuration of the boot loader.
For example, grub on an Ubuntu machine (/boot/grub/grub.cfg):
[...]
linux /vmlinuz-6.5.0-44-generic root=/dev/mapper/system-root ro cgroup_enable=memory swapaccount=1 systemd.unified_cgroup_hierarchy=false
[...]
The boot loader now knows how to find the kernel to boot on the boot partition, and which partition (or logical volume in this case) holds the root partition. The kernel contains all modules needed to mount the other partitions, so it mounts the root partition temporarily (and read-only ro in this example). From there the system can read /etc/fstab and use this information to set up the directory tree.

0 comment threads