If you’ve been tinkering with a Raspberry Pi for a while, chances are you’ve hit this annoying wall: your Pi just won’t boot anymore. No screen. No OS. No mercy. Most of the time? It’s the SD card playing dead.
Don’t panic. It’s often not fatal. In many cases, your SD card just has a corrupted file system — and that, my friend, can be fixed.
Why does this happen?
Even with modern OS images and improved power management, SD cards are still fragile creatures. These are the most common causes of corruption:
- Improper shutdown (pulling the plug, power loss, etc.) I would say this is the most frequent one.
- Unstable power supply or voltage drops
- Writing to the card during crashy code experiments
Yes, you should back up everything. No, nobody (not even me) actually does it while prototyping. Let’s move on.
The hero: e2fsck
Linux has a built-in file system checking tool that can bring your ext-based partitions back from the grave. Here’s how to use it step by step.
Step 1: Plug the SD card into a Linux machine
This could be a physical Linux PC or a virtual machine. Use a USB SD reader if needed. Just make sure you have access to a terminal with root privileges.
Step 2: Identify the correct device (DO NOT GUESS!)
First, list your devices before inserting the SD card:
lsblk
Now insert the SD card and run it again:
lsblk
Look for the new entry — typically something like /dev/sdb
. If your card has multiple partitions, the root filesystem is usually /dev/sdb2
.
You can also use:
sudo fdisk -l
⚠️ Make absolutely sure you get the right partition. Running e2fsck
on the wrong device can do nasty things on unrelated data.
Step 3: Run e2fsck
like a boss
Now that you’ve identified the correct ext4 partition (not the boot partition, which is usually FAT32), run:
sudo e2fsck -f /dev/sdb2 -y
-f
forces a check, even if the system thinks it’s clean.-y
answers “yes” to all prompts, so you don’t have to babysit it.
Swap /dev/sdb2
with your actual device name.
Step 4: Unmount and pray 🙏
If you saw messages like “Inode corrected” or “Block count fixed”, chances are your SD card is now back in shape.
Before removing it:
sudo umount /dev/sdb2
Pop it back into your Raspberry Pi and boot it up. With a bit of luck… success!
Still broken?
- Try checking other partitions like
/dev/sdb1
- If you have a backup image, re-flash it using
dd
or Balena Etcher (yes, at some point was not reliable but now it is) - If corruption happens often, ditch that SD card forever and destroy it — it might be faulty, or fake (btw, at some point I need to write something about fake SD cards).
Did this save your project? Have a better recovery method? Drop it in the comments and help others survive the next Pi meltdown.