Sunday, January 16, 2022

How to reset your password in Raspberry PI when it you forget about the password?

Hardware
-Raspberry Pi 4 Model B

Problems
  • Working on Raspberry Pi recently on my robotics project, I altered /etc/rc.local to setup an auto job and this has caused my system unable to boot properly.
Solutions
  • Remove the SD Card from Raspberry Pi, mount it to your computer
  • Look for cmdline.txt, alter the file based on the value in bold
  • Original
console=tty1 root=PARTUUID=9f7945f8-02 rootfstype=ext4 elevator=deadline 
fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
  • Altered
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline 
fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles 
init=/bin/sh
  • Insert the SD Card back to the Raspberry Pi board again, reboot the system.
  • Run command below to allowed the write access to the SD Card
mount -o remount, rw /
    • I reset my "pi" account password 
    sudo passwd pi
        • Remove the SD Card again from Raspberry Pi, mount it to computer.
        • Revert to the original command in cmdline.txt
        • Insert the SD Card back to the Raspberry Pi board again, reboot the system