On a PC, you'd edit the kernel command line and (e.g.,) append one of:
systemd.unit=emergency.target
to get just a shell (requires systemd);
systemd.unit=rescue.target
to get some more stuff started, then a shell (requires systemd);
single
to boot to single-user mode, on SysV init systems. Not entirely sure this will avoid rc.local
on Wheezy, though; or
init=/bin/bash
, which would avoid starting init at all, instead giving you a shell (where you could then remount the root filesystem read-write, and edit the broken file). I'm not entirely sure on a Pi, though, that this will give you a working keyboard. And it requires some knowledge as you'll be running without an init setting up the system for you; you can generally use exec /sbin/init
to continue booting. (Works with any init system, because you completely bypass it).
I don't think there is a way to do that on a Raspberry Pi unless you're using NOOBS. In which case holding down shift should get you a recovery interface which will let you edit cmdline.txt
—and this change the kernel command line. (Or, probably, just edit the broken file—I'd suggest doing that if possible)
The other alternative is to take your SD card out of the Pi, and use an SD card reader to mount either the boot partition (which I believe is FAT32, so you should be able to do this on Windows) or the root partition (which is likely ext4, so you'd need to be running Linux). Then you can either change the kernel command line in cmdline.txt
or directly fix your rc.local
. If you edit cmdline.txt
on Windows, make sure to use an editor that understands Unix-style line endings and won't make a mess of them.
Personally, my approach would be to mount the Pi's root filesystem on a Linux box and edit the broken rc.local
.
Once you've got your Pi booted again, remember to remove the any rescue options from cmdline.txt
, of course.
exec /sbin/init
(to continue booting) or remount root r/o, sync, and hit reset (to reboot). But yeah, I'll edit to mention single (for Wheezy) and systemd emergency mode. – derobert Jan 29 '17 at 00:23