DEV Community

Cover image for When Your Linux System Hits Emergency Mode: initramfs & fsck
Rijul Rajesh
Rijul Rajesh

Posted on

When Your Linux System Hits Emergency Mode: initramfs & fsck

Recently, I had a situation where my disk usage went to 100%. I wasn't able to do much; it was almost like the system was going into emergency mode.

When I rebooted, a screen came up called initramfs.

Some commands I entered fixed the issue, and I was able to clean up the disk later. Things were back to normal.

In this article, I just wanted to explain what initramfs is.


What is initramfs?

When you first see that word, it sounds too alien, right?

Let's expand it: initramfs stands for initial RAM filesystem.

This is a small temporary filesystem that is loaded into your RAM by the bootloader before your main OS filesystem is mounted.

You can consider it as a toolkit with the things needed to mount your main filesystem.


What is fsck?

fsck stands for file system integrity check. This is a tool that you often use when something goes wrong with your file system.

Some common reasons to use fsck are:

  • Improper shutdowns
  • Power cuts
  • Disk errors
  • Corrupted filesystems

When fsck detects issues:

  • It will attempt to repair them automatically or prompt you.

Example of initramfs and fsck

The initramfs shell looks like this:

(initramfs) _
Enter fullscreen mode Exit fullscreen mode

In this shell, you can run commands like:

fsck /dev/sda1   # check and repair root partition
mount /dev/sda1 /root   # try mounting manually
Enter fullscreen mode Exit fullscreen mode

Here is a simple 6-step example of how initramfs and fsck come into the picture:

  1. System boots, Kernel loads
  2. Kernel loads initramfs into RAM
  3. initramfs tries to mount /, fails
  4. You are dropped into the initramfs shell
  5. Run fsck to fix the filesystem
  6. Reboot. If successful, it will be a normal boot.

Wrapping up

Hope you got a basic idea of initramfs and fsck and how they come into the big picture.

I have a recommendation for you: if you’ve ever struggled with repetitive tasks, obscure commands, or debugging headaches, this platform is here to make your life easier. It’s free, open-source, and built with developers in mind.

👉 Explore the tools: FreeDevTools
👉 Star the repo: freedevtools

Top comments (0)