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?

1
  • You will only see the /boot folder mounted as boot in Finder without loading Ext4 support maketecheasier.com/mount-access-ext4-partition-mac I paid for the Paragon Software in the end - it just works and so so handy.
    – user130616
    Apr 6, 2021 at 8:54

2 Answers 2

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.