On a Raspberry Pi, the boot process is somewhat different from traditional Linux systems due to its unique hardware architecture and boot sequence. However, the role of initramfs (initial RAM filesystem) or initrd (initial RAM disk) remains similar. Here’s how it works specifically for a Raspberry Pi:
- Bootloader Stage: The Raspberry Pi uses a bootloader that is stored on the SD card (or other boot media). The bootloader consists of two parts: the first stage bootloader (located in the ROM of the Raspberry Pi) and the second stage bootloader (located in the
bootpartition of the SD card). The second stage bootloader loads the kernel and theinitramfsorinitrdinto memory. - Kernel Initialization: Once the bootloader has loaded the Linux kernel (usually
kernel.imgorkernel7.imgfor Raspberry Pi), it also loads theinitramfsorinitrdif specified in the boot configuration (e.g., inconfig.txtorcmdline.txt). The kernel initializes the hardware and mounts theinitramfsas the initial root filesystem. -
Running the Init Script: The
initramfscontains essential tools and scripts needed for the boot process. The main script (often located at/initin theinitramfs) is executed. This script typically performs tasks such as:- Detecting and configuring hardware (e.g., loading necessary drivers).
- Setting up the real root filesystem (e.g., from the SD card or USB drive).
- Mounting the real root filesystem to a specific mount point.
- Switching Root: After the real root filesystem is prepared, the
initscript in theinitramfswill execute theswitch_rootcommand to transition from theinitramfsto the actual root filesystem. This involves unmounting theinitramfsand executing theinitprocess from the real root filesystem. - Continuing Boot Process: Once the root filesystem switch is complete, the system continues the boot process by executing the
initprocess of the real root filesystem, which starts the system services and user space processes.
Key Differences for Raspberry Pi:
- No Traditional BIOS/UEFI: The Raspberry Pi does not use a traditional BIOS or UEFI firmware. Instead, it has a simpler boot process that relies on the bootloader stored on the SD card.
- Boot Configuration: The boot configuration is often managed through files like
config.txtandcmdline.txton the boot partition, which specify kernel parameters and the location of theinitramfs. - Hardware-Specific Drivers: The
initramfsmay include specific drivers and configurations tailored for the Raspberry Pi hardware, such as GPU drivers or device tree blobs.
In summary, while the fundamental role of initramfs or initrd in the boot process remains consistent across Linux systems, the specific implementation and boot sequence on a Raspberry Pi are adapted to its unique hardware and bootloader architecture.