amcdonley
Posts: 175
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Second SD card went read-only - Is shutdown -h now safe?

Fri Nov 24, 2017 10:08 pm

Recently my robot suffered its second "read-only" SD card failure. At the moment, if my robot detects that it only has a few minutes of life left, it executes an

Code: Select all

os.system( "sudo shutdown -h now")


Is shutdown -h now safe to issue?

The robot launches several Python processes to manage sensor readings, interrupts for the wheel encoders, and motor speed control. (None that will be writing to the disk at the time, but something in the OS is blinking the green light periodically)

User avatar
The Traveler
Posts: 360
Joined: Sat Oct 21, 2017 3:48 pm

Re: Second SD card went read-only - Is shutdown -h now safe?

Fri Nov 24, 2017 10:28 pm

Difficult to say if it's entirely safe, not knowing the status of all your processes, file system r/w state, etc. Under normal circumstances a shutdown -h is safe. I'd say you don't much to lose either way ...

Cheers.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: Second SD card went read-only - Is shutdown -h now safe?

Sat Nov 25, 2017 6:55 am

shutdown -h now is safe.
but I have my shutdown script that terminates all process that I run (killall,pkill -KILL <name>) and then execute 'sync' then the last command is the shutdown (sudo poweroff). if you do not write data to SD card often you should set the OS to read only, disable dphys swap, disable or move the /var/log to a tmpfs partition (RAM), and also the default filesystem of raspbian is EXT4 which may reduce the lifespan of sd cards so I used the F2FS (flash friendly filesystem as the root filesystem) to atleast extend the lifespan of the microsd.
FLOSS enthusiast, Debian user (linux-libre)

pcmanbob
Posts: 6652
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Second SD card went read-only - Is shutdown -h now safe?

Sat Nov 25, 2017 10:33 am

Yes you are safe using "shutdown -h now" it issues commands to all your running processes to shut them down gracefully, Its all I ever use not just on my pi's but on my linux based pc's as well, and it has never caused any data loss or SD cards to fail.

SD cards going read only normally indicates a problem with the card that has been detected by its own hardware, no one is really sure why this happens to some people but not others on their pi's, personally I have never suffered this problem and I only ever use Kingston class 4 SD cards, which some people say are not the best, but they seem to work fine for me.

one thing I am always careful of is to make sure I use good quality stable power supplies, as I think this might be the problem in may cases of corrupt and failed SD cards.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Troubleshooting”