LostPassword

Losing one's password makes life difficult. With a RasPi, recovery without losing the OS content isn't too hard. If, that is, you have physical access to the system.

  1. Remove the SD card
  2. Mount the SD card on another computer (that you DO have access to)
  3. Edit the cmdline.txt file in the boot partition, changing the line that resembles
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

to

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/sh

Note that the added text init=/bin/sh must be on the same line as the original command

  1. Attach, at minimum, a keyboard to the RasPi. Attach a display if possible (it will make this easier)
  2. Put the SD card back in the RasPi and power it up
  3. Wait for the RasPi to boot. At the end of the boot process, it will open a shell and allow input. With a display, you will see this. Without, you get to wait a good long while, then type blindly!
  4. Type passwd pi and enter
  5. Type the new password plus enter twice
  6. Type sync enter
  7. type exec /sbin/init enter
  8. Wait at least 30 seconds, then power down the RasPi
  9. Remove the SD card, edit on another computer, and restore the line in cmdline.txt to its original state
  10. Put the SD card back in the RasPi, turn on, and enjoy the new password!