1

I have a Raspberry Pi 4 that I haven't used in a little bit, and I've forgotten the password. I know it's running Raspbian Lite, no idea which version. I'd really hate to wipe it, there were many hours of setup that went into it.

I've read some posts about starting by editing the /etc/shadow file, but I can't seem to find it when I plug my micro SD card into my MAC, even when revealing hidden files.

I've also tried adding init=/bin/sh to the end of the cmdline.txt file, but to no avail. When I do that, in fact, I can't even SSH into the Pi, seems like it's not quite booting right.

Any thoughts on this pickle?

toyota Supra
  • 560
  • 2
  • 6
  • 9
Japerspn
  • 19
  • 1
  • 2
  • You will only see the /boot folder mounted as boot in Finder without loading Ext4 support https://www.maketecheasier.com/mount-access-ext4-partition-mac/ I paid for the Paragon Software in the end - it just works and so so handy. –  Apr 06 '21 at 08:54

2 Answers2

2

You need to attach a screen and keyboard and then do the init=/bin/sh. It will sit there waiting for you to enter a command.

joan
  • 71,024
  • 5
  • 73
  • 106
2

You can reset password on the Pi by rebooting to a root shell. (This requires a keyboard & screen).

  1. Append init=/bin/sh at the end of cmdline.txt and reboot.
  2. After booting you will be at the prompt in a root shell.
  3. Your root file system is mounted as readonly now, so remount it as read/write mount -n -o remount,rw /

macOS can not (easily) access ext4 partitions so you can not edit /etc/shadow, although this is possible on any Linux OS - even the Pi.

If you don't want to lose your files I suggest you do a fresh install into a new SD Card.

Milliways
  • 59,890
  • 31
  • 101
  • 209