This Answer is out of date (Raspbian now uses PARTUUID to identify root partition) and uses
/bin/bash rather than the POSIX compliant
It may work to repair the partition, but changing
cmdline.txt to contain
root=/dev/mmcblk0p2 (without a matching change to
etc/fstab) may cause subsequent boot problems.
One way to get in to a safe mode of sorts can be accomplished by booting directly in to bash.
- Unplug and take the card out
- Mount it on a computer
- Open the drive, edit the cmdline.txt file and add " init=/bin/bash" at the end of the existing command.
Note: the space before init is required.
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2
rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash
Unmount the card, put it back in your pi, and boot up.
For me, the availability of a command line was not apparent until I pressed
Enter on the keyboard.
You will likely find that the card is not writable.
You can remount it as readable/writable by doing (adjust the device name if necessary):
mount -o remount,rw /dev/mmcblk0p2 /
- Track down that boo boo,
exit the bash session, and unplug the pi
- Remount the card on your computer and remove " init=/bin/bash" from cmdline.txt and hopefully voila! Lather, rinse, and repeat if necessary.