Skip to content

Instantly share code, notes, and snippets.

@KageKirin
Last active July 2, 2022 06:49
Show Gist options
  • Save KageKirin/973efa3b269742e38238757043d4eb77 to your computer and use it in GitHub Desktop.
Save KageKirin/973efa3b269742e38238757043d4eb77 to your computer and use it in GitHub Desktop.
Bricked Raspberry PI 4b -- First Aid guide

Bricked Raspberry PI 4b -- First Aid guide

This is intended as a personal memo, but also public service. It contains info I gathered from multiple sites while resurrecting my own Raspi.

A part of the salvation process happens on the Raspi directly, so you need a screen and keyboard attached to it.

Bad /etc/fstab

If you edited /etc/fstab and your Raspi won't go beyond the boot sequence while running hot.

  1. Cut the power. Also let the machine cool down before you touch it.
  2. Mount the Raspi's boot SD card in a Mac/PC. (Do NOT format it!) It should be mounted as boot (/Volumes/boot on my Mac)
  3. Edit boot/commandline.txt as described in detail below. Save (unmount boot) and put the SDcard back in the cooled down Raspi.
  4. Switch on the Raspi. Wait for it to boot up to a shell
  5. Try editing /etc/fstab with sudo nano /etc/fstab. If it doesn't show any warning that the file is READ ONLY, great! Read the part about editing /etc/fstab below. Else, continue reading below.
  6. Remount / as read-write. See the section below for details.
  7. Edit /etc/fstab (see above). If should be writable now. If not, I'm sorry, but I can't help you. Maybe try remounting again?
  8. Reboot
  9. Shut the Raspi down using sudo shutdown -h now.
  10. Put the Raspi's SDcard back in your Mac/PC and edit cmdline.txt again to undo your previous changes.
  11. Put the Raspi's SDcard back into the Raspi and switch on. Fingers crossed that the boot sequences finishes without issues.

Good luck!

Editing cmdline.txt

When you first open cmdline.txt, it should read something like this single line below:

console=serial0,115200 console=tty1 root=PARTUUID=467086ff-02 rootfstype=ext4 fsck.repair=yes rootwait

You need to add init=/bin/sh at the end of this line like below.

console=serial0,115200 console=tty1 root=PARTUUID=467086ff-02 rootfstype=ext4 fsck.repair=yes rootwait init=/bin/sh

Similarly, when undoing the changes, you need to just remove the init=/bin/sh part.

Mounting / as read-write

This one can be tricky, as there are several possible commands. Don't despair if one of the given commands doesn't work, and just try the next one until it works. Also try adding sudo in front of it.

mount -o remount,rw /
mount -o remount,rw / –target /

If you get an error like Can't find PARTUUID=eb55478c-02:

sudo mount -o remount,rw /dev/mmcblk0p2 /

Also, I've found the above one to always work for me.

Editing /etc/fstab

When opening /etc/fstab you should see a number of entries like below.

proc            /proc           proc    defaults          0       0
PARTUUID=467086ff-01  /boot           vfat    defaults,flush    0       2
PARTUUID=467086ff-02  /               ext4    defaults,noatime  0       1
UUID=10f1b8d9-6166-4dee-9f6f-bf71aa56379a /mnt/timemachine  ext4  sync,noexec,nodev,noatime,nodiratime,0 0
UUID=409c8a4c-0629-4fde-b049-82eff80fe308 /mnt/dataserver   ext4  sync,noexec,nodev,noatime,nodiratime,0,0
#
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

In my case, it's the last 2 entries causing the boot issue, so we just comment them out for now with #.

proc            /proc           proc    defaults          0       0
PARTUUID=467086ff-01  /boot           vfat    defaults,flush    0       2
PARTUUID=467086ff-02  /               ext4    defaults,noatime  0       1
#UUID=10f1b8d9-6166-4dee-9f6f-bf71aa56379a /mnt/timemachine  ext4  sync,noexec,nodev,noatime,nodiratime,0 0
#UUID=409c8a4c-0629-4fde-b049-82eff80fe308 /mnt/dataserver   ext4  sync,noexec,nodev,noatime,nodiratime,0,0

It will be easier to edit this file using a remote shell later after getting the Raspi back to booting.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment