You can attempt to repair problems on the Pi by rebooting to a root shell. Here's how to do that:
-
Remove the SD card from the misbehaving RPi, and mount it on another computer (N.B. the
/boot
partition is FAT-formatted, and it can be mounted, read and written by virtually any computer on earth.). The file you must edit is:/boot/cmdline.txt
). -
Append
init=/bin/sh
at the end ofcmdline.txt
. Re-insert the modified SD card, and boot the system (plug in USB power cord). -
After booting you will be at the prompt in a root shell.
-
Your root file system is mounted as read-only at this point, and so will need to re-
mount
it as read-write:mount -n -o remount,rw /
-
You can now edit files anywhere on the SD card/root file system, incl.
/
- the rootext4
partition. -
Running
raspi-config
may be a good place to start; it will allow you to change your password, network settings, enable/disable SSH, change keyboard layout, etc.
- Changed keyboard layout & now can't enter password; Full credit to the effervescent @Milliways :)