Recovering Linux from initramfs

| ⌛ 2 minutes read

📋 Tags: Linux Tutorial


You turned on your Linux machine and are greeted by a very scary looking terminal. You’ve booted into busybox and are in initramfs. How do I fix this?

initramfs, Image src: askubuntu question

Very rarely, memory can get corrupted on your Linux machine. When that happens, you boot into the terminal above. The fix is a simple 1 line command using the fsck built-in tool.

Before using fsck, you need to identify which hard disk stores your working data.
The hard disk containing all your data (/, /user, …) is usually found in /dev/...

Use df to list out all the possible partitions and identify your data partition. If you don’t get anything, its ok, just carry on to the next command.

0
1
# Find out what partitions exist
df -h

Run the following command with the identified partition. If you dont know the partition, type fsck /dev and press tab to see the autocomplete options. This will implicitly list out all found partitions on your machine. Run fsck on each partition one by one.

0
1
2
3
# Launch the disk repair
fsck /dev/yourpartition -y
# Once done, exit from initramfs to continue booting normally
exit

You should see a bunch of log messages identifying corrupted memory blocks and fixing them. Once that is done, exit out of intiramfs and you should boot as per normal.