|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
https://hackmd.io/p8yqWHBcRmyADm7t0RzhnQ
https://docs.google.com/presentation/d/1v7ScSVk00PVfthV8E-dEeT3o7YcV29Hm2qdDKxHlo-Y/edit?usp=sharing

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

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

Methods to build rootfs

More:
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:
https://www.slideshare.net/chienhungpan/a-journey-to-boot-linux-on-raspberry-pi