2

I flashed Raspbian and I use my Pi headless, connecting via SSH. To power it off I do sudo halt, which disconnects me from the SSH. After a few green led blips I have steady red led on. Does it mean the Pi is still on and I cannot unplug the power?

I am asking this because I have seen a lot of SD card corruption in 2 days, so I was wondering if I have switched off improperly after the sudo halt while the red led was still on.

3

Yes, you may. Oh, have you considered sudo shutdown?

shutdown makes sure to run any shutdown tasks, clean up a bit, then power off gracefully (red LED will still be on on the pi, green LED will blink a few times to indicate shutdown is done. Unplug after that).

halt just kills the system.

Update: Turns out they're technically the same.

  • 1
    halt only kills the system immediately if you use -f, otherwise it and shutdown are much the same thing. In fact they are exactly the same thing; have a quick look at stat $(which halt) and stat $(which shutdown). They just tell init to stop the system. halt -p and shutdown now are identical, as are halt and shutdown -H now. "Power off" is mostly meaningless on the pi because it cannot be powered off anyway -- I think the only difference is it turns off the HDMI & eth/usb bus. The reason there are the two commands is purely historical. – goldilocks Feb 5 '16 at 13:31
  • I.e., Using halt is fine, particularly if you are going to unplug it. – goldilocks Feb 5 '16 at 13:34
  • @goldilocks Noted. – Gene Feb 5 '16 at 14:14
  • One day I will have to get the source and see what it actually does. – Milliways Feb 5 '16 at 22:55
  • I was expecting the green light to go off but at least on my Pi 3, it stays on indefinitely. – Timothy Lee Russell Mar 19 '16 at 6:11
2

If only the red LED is on, everything is good. It says, that your Raspberry PI is connected to a stable power supply. The green LED blinks a few times, when the shutdown process has finished, then it is safe to unplug the power supply. But depending on your raspbian version, it is better if you use the shutdown command.

2

Theoretically shutdown will "Halt, power-off or reboot the machine" There was historically some difference. The man for halt, poweroff, reboot states "These are legacy commands available for compatibility only"

AFAIK all should safely shutdown. In practice on Raspbian there still seems to be some differences. poweroff should power the machine off, but the Pi has no power control. shutdown (without any time parameter) has a delay before it actually shuts down. halt should shut down immediately, but sometimes I find it closes network connections but does not shutdown.

In practice I use poweroff which results in the green LED flashing 10 times then shutting down. Powering off after the flashing stops sems to be safe.

  • shutdown without a time or now will throw up the usage message - unless systemd on the (latest at time of writing) changes this. Traditionally shutdown now without any other options takes a running multi-user system (runlevels 2-5) down to single-user mode so the super-user can make changes (with a time delay the system should block logins from non-root users after the five-minute left deadline has expired). The -h option extends this to "halt" the system, and on non-RPis -P will switch power off. I do recall that this has changed and one of these may now alias the other... – SlySven Feb 5 '16 at 16:05
0

Wait for system shutdown, it usually takes some time - about a minute or so. The red led is a power indicator

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.