Resetting password on Raspberry PI (newer images)

The newer images for raspberry pi use PARTUUIDs in the root filesystem options so most of the online “How to reset the password on your pi” tutorials are missing a couple of steps to make it work. I helped @Gary with this today and thought I’d type it up here for posterity

  1. Stick the SD card in a windows machine and open up cmdline.txt in an editor.

  2. ADD the following to the end of cmdline.txt:
    init=/bin/sh

  3. Look for root=PARTUUID= in the command, replace it with
    root=/dev/mmcblk0p2

  4. Save cmdline.txt and stick it back in a PI

  5. Boot the PI.

  6. When the text stops scrolling by press Enter a few times to get to a # prompt

  7. Mount the proc filesystem:
    mount -t proc /proc Enter

  8. Remount the root file system as readwrite (it is mounted readonly now):
    mount -o remount,rw -t ext4 /dev/mmcblk0p2 / Enter

  9. Reset the pi user’s password (or any other user, just replace pi with the user you want to reset):
    passwd pi Enter

  10. Follow the prompts to reset the password. You should see password updated successfully

  11. Sync the filesystem to disk:
    sync Enter

  12. Exit the shell
    exit Enter

  13. Once all the scrolling stops, power off the pi and remove the SD card (Note, you’ll see something about a kernel panic, ignore that)

  14. Stick the SD card back in a PC and edit cmdline.txt again.

  15. REMOVE init=/bin/sh from the end of the command

  16. You can change the root= option back to what it was, but you don’t need to.

  17. Save, stick the SD back in a PI and give logging in a go.