2

I am searching for MicroSD card for Raspberry Pi that won't get damaged. (See previous post, SanDisk Ultra SD Card with Raspberry Pi 3+ Suddenly Stopped Working (and is Overheated!))

On this product description, it says following,

If you are an experienced Raspberry Pi user, you probably know to perform a soft shutdown before unplugging power or you may end up with an unbootable system. Our MicroSD card images were created with special tweaks to increase performance while offering significantly more protection against data corruption from power issues.

How would user perform soft shutdown if they never SSH'd into the system in the first place.

What I mean is, I SSH into my Raspberry Pi from my Laptop. W

hat if I turned on the Raspberry Pi, but never SSH'd into it. And later on I turn off my Laptop and unplug my Raspberry Pi.

How would I perform a soft shutdown of Raspberry Pi if I never SSH'd into it to begin with, but simply plugged it in?

Ingo
  • 40,606
  • 15
  • 76
  • 189
Marium
  • 155
  • 1
  • 5
  • A number of libraries or simple script can be used to configure a GPIO pin as a soft shutdown pin. Otherwise some kind of remote access is required. A simple workaround is a shutdown socket, a simple server script that triggers shutdown when a magic packet is sent to that socket. – crasic Apr 19 '19 at 01:06
  • SD card corruption on soft shut down is practically non existent. All SD cards will have the potential for corruption on hard shutdown, with the some manfufacturers trying to mitigate that risk through various schemes. Block level corruption due to electrical glitch should be handled by SD card control ic. fs level corruption due to a shutdown during file system write is handled by fs anti corruption features. . At greatest risk is boot sector which is fat32 and thus unjournaled and not robust. If you pull the plug during a kernel update, the sd card can't do much to prevent that. – crasic Apr 19 '19 at 01:07
  • I am confused: Your title does not match the body. You ask what is it, then tell us, and ask how. (and is it about over-heating?) – ctrl-alt-delor Apr 20 '19 at 09:43

2 Answers2

2

As @Millways says, soft shutdown is simply shutting down the operating system before powering off.

Depending on what your Pi is used for, you may be able to automate the shutdown. I have this script which is called from /etc/rc.local

#!/bin/bash
# Control script for Raspberry Pi
# Runs at boot-up, as root

FLAG_FILE=/home/pi/donotshutdown

# Run the application.
my_application

if [ -f $FLAG_FILE ]
then
    # Flag file exists, no shut down
    rm $FLAG_FILE
else
    # Proceed to shut down
    shutdown now
fi

Normally, it runs the application then shuts down. If I want it to remain running when my application has finished, I just create (with ssh) the flag file.

Peter bill
  • 309
  • 1
  • 5
  • 1
    Using `/etc/rc.local` is not a good advice. Please take note that using `/etc/rc.local` has limitations due to [Compatibility with SysV](https://www.freedesktop.org/wiki/Software/systemd/Incompatibilities/). We have seen many problems here on this site using it. Following the recommendation of the developers from **systemd** you should avoid using it. – Ingo Apr 20 '19 at 08:25
1

Sounds like marketing talk!

If you use the shutdown on the Desktop (or sudo poweroff command) there should be no problem.

Your previous problem is likely a hardware failure or power supply issue - nothing to do with how it was shutdown.

It is simple to connect a pushbutton to the GPIO pins to perform a clean poweroff. See https://raspberrypi.stackexchange.com/a/42945/8697

NOTE All SD Card manufacturers claim that SD Cards are not designed to run an OS.

Milliways
  • 54,718
  • 26
  • 92
  • 182