|Linux| introduce rootfs

This is a note of COSCUP.
In this talk, I learn many knowledge from system scope and find something I should study in advance.
In fact, I am an embedded software engineer and I am not a system engineer yet.
But I believe I will be.
This topic will make up my shortage.

Source: author: Carl Su

Elements of Linux

  • tool chain
    • compile and execute
  • blootloader
    • grub or u-boot for bring up
  • linux kernel
  • rootfs
    covering the above

Overview of rootfs

  • kernel will mount rootfs to (/) with read-only (in order to use init)
  • execute/sbin/init or /bin/sh for initialize system
  • init will remount rootfs and other file systems according to /etc/fstab
  • /sbin/init will be managed by systemd (symbolic link)

Boot flow of ARM

  • ROM code
    • It provider by vendor, and OEM can’t customize.
  • SPL (Secondary Program Loader)
    • Put in SRAM (OEM can customize)
  • TPL (Tertitary Program Loader)
    • e.g. UBOOT
  • Linux kernel: kernel extracts by itself, then pid= 0, 1, 2
  • /sbin/init

檔案系統階層標準 (FHS)

Minimize rootfs

/bin/ :Utilities: sh, ls, cp, mv, etc.
/etc/ :fstab, group, passwd, profile
/sbin/ :init
/lib/ :Runtime libs: glibc, musl, etc.

Methods to build rootfs

FHS Spec: https://refspecs.linuxfoundation.org/fhs.shtml
Linux From Scratch (LFS): http://www.linuxfromscratch.org/lfs/
建立基於 BusyBox 的 rootfs: https://hackmd.io/@c_0KKCwzQE2rsd39mpvNQQ/rknxhDzvB

A Journey to Boot Linux on Raspberry Pi: