Basics
Boot Process
- POST
- Bootloader
- GRUB:
- Stage 1 # Loads stage 1.5
- Stage 1.5 # Provides filesystem support, loads stage 2
- Stage 2 # Contains the bulk of the bootloader, allows users to select kernel and kernel boot options. Loads kernel into RAM
- Solaris (pre-10 1/06)
- mboot
- pboot
- bootblk
- GRUB:
- Kernel Init
- initrd or initramfs
- Provides temp filesystem required to load kernel modules and drivers
- initrd or initramfs
- User Space Init
- SysV
- Serial, starts processes one after the other
- When first booting up, kill scripts will generally not be ran
- init (PID 1) # Ancestor of all other processes
- /etc/inittab
- Defines default run level
- Tells the system what to do when rebooted or run level is changed
- Red Hat:
- /etc/rc.d/
- Startup scripts
- /etc/rc.d/init.d/
- Contains actual service control scripts
- /etc/rc.d/rc.sysinit
- Config to be run before other services. Time zone, hostname, etc
- /etc/rc.d/rc.local
- Config to be run after services are up. Typically system specific such as VPNs
- /etc/rc.d/
- Debian:
- /etc/rc<#>.d/
- /etc/init.d/rcS
- equivalent to rc.sysinit
- upstart
- Can run steps in parallel
- Init reads .conf files in /etc/init
- One of those scripts runs /etc/rc.d/rc script for desired runlevel. This provides the SysV backwards compatibility
- systemd
- Can run steps in parallel
- /usr/lib/systemd/systemd (PID 1) # May also be /sbin/init (symbolic link to systemd)
- Units
- Service # Daemons
- Socket # IPC and network
- Target # Similar to runlevel, groups units together during boot up
- Located in /etc/systemd/system and /usr/lib/systemd/system
- Units in /etc take precedence
- States
- Load
- Did it successfully read the unit’s configuration file?
- Active
- Is it running?
- Sub
- Low-level unit activation state
- Load
- /etc/systemd/system/default.target
- Symbolic link to default target
- SMF # Solaris 10+
- Can run steps in parallel
- Milestones
- Replaces runlevels
- /etc/svc/repository.db
- Config database
- SysV
Shells
Types
https://phoenixnap.com/kb/linux-shells
https://www.freecodecamp.org/news/linux-shells-explained/
Profile Loading
https://youngstone89.medium.com/unix-introduction-bash-startup-files-loading-order-562543ac12e9
https://access.redhat.com/solutions/452073