When Your Linux System Hits Emergency Mode: initramfs & fsck
Source: Dev.to
What is initramfs?
When you first see that word, it sounds alien, right?
initramfs stands for initial RAM filesystem. It is a small temporary filesystem that is loaded into RAM by the bootloader before your main OS filesystem is mounted. Think of it as a toolkit containing the things needed to mount your main filesystem.
What is fsck?
fsck stands for file system integrity check. It is a tool you use when something goes wrong with your file system. Common reasons to run fsck include:
- Improper shutdowns
- Power cuts
- Disk errors
- Corrupted filesystems
When fsck detects issues, it will attempt to repair them automatically or prompt you for confirmation.
Example of initramfs and fsck
The initramfs shell looks like this:
(initramfs) _
In this shell you can run commands such as:
fsck /dev/sda1 # check and repair root partition
mount /dev/sda1 /root # try mounting manually
A simple 6‑step example of how initramfs and fsck interact:
- System boots, kernel loads.
- Kernel loads initramfs into RAM.
- initramfs tries to mount
/, fails. - You are dropped into the initramfs shell.
- Run
fsckto fix the filesystem. - Reboot. If successful, the system boots normally.
Wrapping up
You now have a basic idea of what initramfs and fsck are and how they fit together during the boot process.