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
-
Stick the SD card in a windows machine and open up
cmdline.txtin an editor. -
ADD the following to the end of
cmdline.txt:
init=/bin/sh -
Look for
root=PARTUUID=in the command, replace it with
root=/dev/mmcblk0p2 -
Save
cmdline.txtand stick it back in a PI -
Boot the PI.
-
When the text stops scrolling by press Enter a few times to get to a
#prompt -
Mount the proc filesystem:
mount -t proc /procEnter -
Remount the root file system as readwrite (it is mounted readonly now):
mount -o remount,rw -t ext4 /dev/mmcblk0p2 /Enter -
Reset the pi user’s password (or any other user, just replace
piwith the user you want to reset):
passwd piEnter -
Follow the prompts to reset the password. You should see
password updated successfully -
Sync the filesystem to disk:
syncEnter -
Exit the shell
exitEnter -
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)
-
Stick the SD card back in a PC and edit
cmdline.txtagain. -
REMOVE
init=/bin/shfrom the end of the command -
You can change the
root=option back to what it was, but you don’t need to. -
Save, stick the SD back in a PI and give logging in a go.