How to shutdown the Raspberry Pi?


14 posts
by atzensepp » Wed Oct 03, 2012 8:17 pm
I want to use my Pi as internet radio with mpd. It should work as a stand alone device. Start up is no problem since mpd is strting automatically. But when I want to turn it off Iam currently pulling the power plug. Since it is a linux device I am afraid that by this rough procedure one time the file system could get corrupted. What would be your advice to do a decent shutdown or is the power off method not so critical for the pi?
Posts: 11
Joined: Sun Sep 23, 2012 8:00 pm
by rymate1234 » Wed Oct 03, 2012 8:25 pm
Just run sudo halt from a console to shut your pi down. This initiates the linux shutdown routine.
Posts: 22
Joined: Wed Oct 03, 2012 8:22 pm
by alexeames » Wed Oct 03, 2012 8:26 pm
Best thing to do is enable ssh (it should be enabled if you haven't disabled it) then ssh into it from another computer (or even your smartphone) and type

Code: Select all
sudo halt


Further info here...

http://raspi.tv/2012/how-to-safely-shutdown-or-reboot-your-raspberry-pi
Alex Eames RasPi.TV HDMIPi.com RasP.iO
User avatar
Posts: 2054
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
by ski522 » Wed Oct 03, 2012 11:46 pm
Leave it running, why do you need to shut it down? The power the device uses is minimal.
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm
by RockMachine » Thu Oct 04, 2012 5:06 pm
Sudo poweroff
Posts: 61
Joined: Sat Aug 18, 2012 6:30 pm
Location: Italy
by mckorr » Fri Oct 05, 2012 5:05 pm
ski522 wrote:Leave it running, why do you need to shut it down? The power the device uses is minimal.


In order to move it to a different location, or to swap out the SD card, or.... Lots of reasons you might have to shut it down.
Posts: 12
Joined: Fri Oct 05, 2012 5:01 pm
by atzensepp » Tue Oct 09, 2012 8:14 pm
rymate1234 wrote:Just run sudo halt from a console to shut your pi down. This initiates the linux shutdown routine.

Sure this is the correct way if one has a terminal connection.
But I am interested in a way to safely power off the Pi with a simple button press without the need for logging in just for the purpose of powering down.
Following ideas I had so far:
  • write a demon that is permanently checking one of the GPIO pins and shutting down the Pi when a special button is pressed
  • write a PHP script to power it down via web with an Iphone as controller ( :? )
  • build a little UPS device that detects a power off, supplies the Pi for some seconds until it powers off after sending a shutdown-signal via GPIO to the Pi. (a demon needed too)

I was hoping this problem has been solved already. More elegant suggestions are welcome.
Posts: 11
Joined: Sun Sep 23, 2012 8:00 pm
by toxibunny » Tue Oct 09, 2012 8:26 pm
I use either sudo shutdown, then pull the plug, or sudo shutdown -r to reset.

What's all this 'sudo halt' and 'sudo poweroff' stuff?
note: I may or may not know what I'm talking about...
Posts: 1050
Joined: Thu Aug 18, 2011 9:21 pm
by toxibunny » Tue Oct 09, 2012 8:27 pm
yeah, I also mostly just leave it running, too... which I feel a bit dodgy about, to be honest.
note: I may or may not know what I'm talking about...
Posts: 1050
Joined: Thu Aug 18, 2011 9:21 pm
by mahjongg » Tue Oct 09, 2012 8:29 pm
These are shortcuts for the more difficult to remember command
sudu shutdown -h now

why shouldn't you make something easy that you have to do so often.
User avatar
Forum Moderator
Forum Moderator
Posts: 4928
Joined: Sun Mar 11, 2012 12:19 am
by mak3r » Tue Oct 09, 2012 9:09 pm
atzensepp wrote:[*] build a little UPS device that detects a power off, supplies the Pi for some seconds until it powers off after sending a shutdown-signal via GPIO to the Pi. (a demon needed too)[/list]
I was hoping this problem has been solved already. More elegant suggestions are welcome.


You probably don't need an entire ups. Why not just a switch that signals one of the inputs.
Posts: 1
Joined: Tue Oct 09, 2012 9:05 pm
by atzensepp » Wed Oct 10, 2012 9:02 pm
mak3r wrote:
atzensepp wrote:[*] build a little UPS device that detects a power off, supplies the Pi for some seconds until it powers off after sending a shutdown-signal via GPIO to the Pi. (a demon needed too)[/list]
I was hoping this problem has been solved already. More elegant suggestions are welcome.


You probably don't need an entire ups. Why not just a switch that signals one of the inputs.


Yes an ups would be overkill. Probably something like that is sufficient:
http://picnote.blogspot.de/2008/10/batt ... oller.html
(The battery could be used for a RTC (e.g. DS1337) too.)

B.t.w. I found a thread in this forum that deals with that problem: "Safe hard power-off"
viewtopic.php?f=29&t=17140
Posts: 11
Joined: Sun Sep 23, 2012 8:00 pm
by atzensepp » Thu Oct 11, 2012 9:06 pm
What about using a large (Gold Cap) capacitor as back-up power supply to enable a decent shutdown?
The Pi is consuming 2 W at 5 V. For a 30s Shutdown cycle a charge of 12 As is needed which could be provided by a capacitor with 2.4 F capacity.
Do you think that would work?
Posts: 11
Joined: Sun Sep 23, 2012 8:00 pm
by FruityPenguin » Sun Nov 11, 2012 4:01 pm
I was also thinking about using a Gold Cap for a mini-UPS, as I see several advantages:
  • Doesn't require a complex charging circuit
  • It can easily supply more than enough power for a quick shutdown
  • Has a longer shelf life (up to 10 years) than rechargeable batteries
  • Small
Detecting that mains power has failed and triggering a GPIO pin to initiate the shutdown should also be easy to do.

Unfortunately my skills in electronics are too basic to actually turn this idea into a working circuit. :oops:
Posts: 5
Joined: Thu Jul 05, 2012 7:44 pm
Location: Berlin, Germany