Posted on

Pi Brick – oh no!

So have you bricked your Pi? By that I mean have you somehow hosed the start-up enough that the Pi never makes it to the log-in prompt or loads ssh so you can get connected remotely? There is a way to boot your Pi that bypasses the init.d startup scripts.

The cmdline.txt file (located in your boot folder) contains a number of parameters used during the boot sequence. You can see the boot folder and this file when you plug your SD card into your desktop computer and browse the files.

Using a plain text editor, add the following parameter to the end of the text like so:

init=/bin/sh

This tells the linux kernel that instead of running /sbin/init as usual it should load a shell (/bin/sh).

Save your file, eject the SD card, plug it into the Pi and power up. You will see a shell prompt. No everyday services are running – none of the init.d scripts will have run. You will have root permissions (UID 0), which means you can change passwords, undo the modifications you made, and get back to a working state.

I used this trick when I tried to set up a python script to run as a daemon (service) and forgot to load the script in the background, and the startup stalled right after that script started up.