Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Usually with a desktop computer, if I run sudo shutdown -P now, the computer switches off completely and I can switch it back on again with a button. (Likewise, if the computer crashes, I can force a restart by holding down the power button for 5 seconds or so.)

The Raspberry Pi doesn't have a power button. In fact, if I run sudo shutdown -P now, the power led still seems to be on, and in order to start it up again, I seem to need to unplug it and plug it back in again. This seems somewhat analogous to "It is now safe to switch off your computer" in old versions of Windows.

At what point is it safe to pull the plug on the Raspberry Pi? Am I doing something wrong?

share|improve this question
2  
The red led just indicates that the oi is receiving power. The one you want to pay attention to is the green one. If it is flashing that means the oi is accessing the microSD card. When you shut down watch it. It should flash 4-10 times. Once this occurs it is safe to unplug. – TheXed Feb 21 at 19:26
1  
Provided your SD card is formatted in ext4 (or other journalling FS) it is frankly more or less safe to turn it off whenever the pi is just sitting around idle. At least more safe than it was to just turn off a Windows95 computer. (Not that I recommend it for any safety critical applications... but a pi isn't exactly ideal then, anyway.) – leftaroundabout Feb 21 at 19:54
3  
@leftaroundabout, journaling doesn't do much when the underlying medium can't handle a power failure cleanly. I frequently need to re-format my SD cards after a power failure. – Mark Feb 21 at 20:11
    
@Mark: possible. I have a pi that I've often unpowered unsafely without complications, but in fact this one only uses the card only for the boot loader and has everything else on a USB hard drive. – leftaroundabout Feb 21 at 20:16
    
@Mark It also doesn't mean much when in the middle of a data write. You'll still lose your data. It just guaranteed filesystem consistency,. – Bob Feb 22 at 4:02

You are not doing anything wrong.

The activity LED should flash 3 or 4 times just before power off. It is then safe to remove the power.

I typically shut-down, go away for a few minutes, and then yank the power cord out.

share|improve this answer

You do not need to remove power to restart Pi. There are a pair of pads near the SD Card (I think labelled reset possibly run - I can't see on my Pi because they all have switch soldered on the board.) Momentarily short to restart.

I recommend sudo poweroff to shut down the Pi. There is nothing wrong with what you are doing, but poweroff causes the green LED to blink 10 times at 1 second intervals when it is safe to poweroff.

I have a Python script which shuts the Pi down with a pushbutton.

#!/usr/bin/env python2.7
#-------------------------------------------------------------------------------
# Name:         Shutdown Daemon
#
# Purpose:      This program gets activated at the end of the boot process by
#               cron. (@ reboot sudo python /home/pi/shutdown_daemon.py)
#               It monitors a button press. If the user presses the button, we
#               Halt the Pi, by executing the poweroff command.
#
#               The power to the Pi will then be cut when the Pi has reached the
#               poweroff state (Halt).
#               To activate a gpio pin with the poweroff state, the
#               /boot/config.txt file needs to have :
#               dtoverlay=gpio-poweroff,gpiopin=27
#
# Author:      Paul Versteeg
#
# Created:     15-06-2015, revised on 18-12-2015
# Copyright:   (c) Paul 2015
# https://www.raspberrypi.org/forums/viewtopic.php?p=864409#p864409
#-------------------------------------------------------------------------------

import RPi.GPIO as GPIO
import subprocess
import time

GPIO.setmode(GPIO.BCM) # use GPIO numbering
GPIO.setwarnings(False)

# I use the following two GPIO pins because they are next to each other,
# and I can use a two pin header to connect the switch logic to the Pi.
# INT = 17    # GPIO-17 button interrupt to shutdown procedure
# KILL = 27   # GPIO-27 /KILL : this pin is programmed in /boot/config.txt and cannot be used by any other program
INT = 21    # GPIO button interrupt to shutdown procedure

# use a weak pull_up to create a high
GPIO.setup(INT, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def main():

    while True:
        # set an interrupt on a falling edge and wait for it to happen
        GPIO.wait_for_edge(INT, GPIO.FALLING)
#       print "button pressed"
        time.sleep(1)   # Wait 1 second to check for spurious input
        if( GPIO.input(INT) == 0 ) :
            subprocess.call(['poweroff'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if __name__ == '__main__':
    main()
share|improve this answer
    
Can you add that python code for reference, and what if I give the power source will it automatically start pi or else? – Gaurav Dave Feb 25 at 12:59

As previous answers have stated, the red led means the pi is receiving power where as the green led is activity (I believe disk activity)

you can either pull the plug when the green led has stopped blinking after a shutdown command or you can short the run/reset pads that are on the board

This website has a great instructions on how to add a hard reset switch if your willing to solder a few pins.

If you do use the hard reset be sure to only use it after a halt or system shutdown or as a last resort as it immediately restarts the processor, if you are writing to your SD card then you can potentially corrupt it just as pulling the power while it running

share|improve this answer

No one seems to have answered this question: "At what point is it safe to pull the plug on the Raspberry Pi?"

To properly shutdown, you run

sudo shutdown

When you do this, you'll see the "ACT" light (the green one) blink solidly 10 times (0.5 second intervals). Once it stops blinking, the green light will turn off. At this point, it is safe to remove the power or pull the plug.

The red light will remain on as long as there is power applied to the Pi.

After shutdown, you must remove the power and then apply the power again to power up the Pi.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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