原文連接:http://www.raspberrypi-spy.co.uk/2014/08/how-to-reset-a-forgotten-raspberry-pi-password/
大致過程是這樣的:
1、首先將sd卡從樹莓派取出,
2、在另一台電腦上,修改初始化進程為bin目錄下的sh;
3、然后插入樹莓派啟動起來,啟動后會停留在命令行,在此通過passwd加你的用戶名來設置密碼(即使root也可以在此修改,這里之前是否初始化過root密碼不太確定)
4、樹莓派關機,取出sd卡,插入另一台電腦,恢復啟動文件,修改密碼過程完成
詳細步驟看翻譯吧
翻譯如下:
Step 1 – Grab The SD Card
步驟1-取出sd卡
Power down the Pi and remove the SD card. Insert it into your PC.
將樹莓派關機,移除sd卡,插入到你的電腦
Step 2 – Edit cmdline.txt
步驟2-編輯cmdline.txt
The boot partition should be visible and contain a file named “cmdline.txt”. Edit this file in a text editor and add the following to the end of the existing text :
啟動部分是可見的,並包含一個名為“cmdline.txt”的文件。在編輯器中編輯這個文本,並將下文插入到已有文本的最后
init=/bin/sh
If the original content was :
如果原文是這樣的:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
it should now look like :
那么編輯后應該是這樣的:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh
Make sure it is all one line! Save the text file and eject the SD card from the PC.
確保所有內容在同一行。保存文本內容,從pi出取出sd卡
Step 3 – Reset the Password
步驟3-重設密碼
Insert the card into a Pi that is connected to a monitor and keyboard. Power up the Pi. There may be a delay but you should be presented with a flashing cursor.
將sd卡插入樹莓派(我們在這里需要連上顯示器和鍵盤)。將樹莓派開機,估計在顯示閃動的光標前需要等一會。
At the prompt type the following command :
在標識符后,輸入以下命令:
passwd pi
You will then be prompted for a new password. Enter it carefully and press the [Return] key. It will now ask you to retype the password.
你會被提示輸入一個新的密碼,請仔細輸入后並敲下回車鍵。系統會提示你再次確認輸入密碼
The password has been changed.
這樣密碼就修改完成了
Now type the following commands :
現在輸入以下命令去同步並執行初始化程序
sync exec /sbin/init
The Pi will continue to boot and return you to the normal command line prompt.
樹莓派會繼續啟動
Shutdown the Pi and power it off.
關掉樹莓派並且斷電
sudo halt
Step 4 – Edit cmdline.txt
第四步-編輯cmdline.txt文本
Using the PC edit the “cmdline.txt” file again and remove the “init=/bin/sh” text you added in Step 2.
用電腦再次編輯這個文本:把我們在第二步加入的最后數據刪除
You can now return the SD card to your Pi, reboot and use the new password.
現在你可以插入sd卡到你的樹莓派啦,再次啟動就可以使用新的密碼啦。