2

So it's been a while since I've played with it, and I forgot my Raspberry Pi's login info (both username and password), and it's running. I've seen some instructions for resetting the password, but they require the SD card to be put into another machine.

Is there a way to shut it down without being logging into it, so I can get the SD card out without possibly corrupting the file system (by yanking the power cord)?

Thanks

  • As der_do says, if the system is idle the risk of corruption when pulling the plug/cutting the power is really low. You can run fsck on the second partition when you put the SD card into another box to check. – goldilocks Mar 9 '15 at 17:40
  • Which distro is it running? – Wilf Mar 9 '15 at 17:52
3

I think it is safe to just pull the power plug.

If your pi is not busy (writing to SD-Card), you should not get any data corruption.

If you have a display and keyboard attached, you can try the 'Magic SysReq' keys: http://www.linuxhowtos.org/Tips%20and%20Tricks/sysrq.htm

The proper combination would be:

  • Flush disks (Alt+SysRQ+s)
  • Mount disks readonly (Alt+SysRQ+u)
  • Reboot (Alt+SysRQ+b)
  • Pull the power plug.

I don't know whether this is enabled in the Pi kernel. If you don't see any logs on the console when you do the first step, then it's not :(

Have fun.

2

If you are realy concerned about this you can attach a button to a GPIO pin and have some code that starts with the system monitor the pin and halt the pi when the button is pressed.

  • The question is with regard to a system that can't be logged into because the passwords were lost, so a solution that involves modifying the system won't work. – goldilocks Mar 9 '15 at 17:38
  • You can try pull the plug and reset the password my modifying the shadow file on another Linux computer. I once pulled this trick by resetting a lost password of a Loongson server by modifying the shadow file and inject the hash from a x86 Ubuntu computer. Server is school property, but the administrator of the server gave me the task to regain access to the server no matter what it takes. – Maxthon Chan Mar 9 '15 at 19:00
  • You can also completely remove the hash and leave the account passwordless: unix.stackexchange.com/questions/35929/… – goldilocks Mar 10 '15 at 12:41
0

I suppose a safer way would be to hold the Pi in a reset state as you pull the power.

More recent Pi models have two points you can bridge with a wire to reset the Pi. If you hold it in reset it will be safer to pull the power.

See https://www.google.co.uk/search?q=raspberry+pi+reset+pins&biw=1077&bih=592&tbm=isch&tbo=u&source=univ&sa=X&ei=eGL9VJC5FeWy7Qan1IC4Dw&ved=0CCAQsAQ

Frankly unless you can see SD card activity (flashing LED) I'd just pull the plug. Frankly, frankly even if I saw SD card activity I'd just pull the plug (I keep nothing important on the SD card).

0

If the your raspberry pi is connected to a display, and you are at the terminal login prompt, pressing CTRL+ALT+DELETE should start the reboot sequence. You can watch the screen for the moment of reboot(screen blanking), and remove power. This should be the safest method.

0

Add a user called shutdown that runs only the shutdown program in the "/etc/passwd" file. In the field for the shell add "/usr/bin/shutdown". You would probably have to add shutdown to legal shells file too.

Old unix's of the '80s had a user call "sync" that ran "/usr/bin/sync". The command line login would return after the sync to a login prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.