Page 1 of 1

Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 10:45 am
by held
Wow, this has been a while I hope everyone is doing OK :D
I finally have some spare time to play around with the MiSTer again, yay!

The MiSTer linux image has a sync script that syncs every 5s which in my uninformed opinion is hazardous to every SD-card. So I started a search and found that embedded devices (where power can be cut off at any time like the MiSTer), use a 470µF capacitor to give the OS enough time to finish writing in case of power failure.

Is this already present on the IO-board, and if not would this be a good idea to introduce?

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 10:53 am
by LamerDeluxe
What does it sync? The capacitor sounds like an interesting idea.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 11:08 am
by Malor
The /media/fat directory is already mounted sync, so the 5-second sync script probably isn't doing much of anything.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 12:56 pm
by held
LamerDeluxe wrote: Thu Nov 24, 2022 10:53 am What does it sync? The capacitor sounds like an interesting idea.
Yeah, I thought so too.
Malor wrote: Thu Nov 24, 2022 11:08 am The /media/fat directory is already mounted sync, so the 5-second sync script probably isn't doing much of anything.
I disabled it on my setup, at least the green light stops flashing so frequently.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 2:38 pm
by Flandango
The constant sync'ing won't hurt the SD card since it's not really writing data to it each time it syncs.
Syncing doesn't only protect against data loss during a power outage, but if you were to reset Mister, any unsaved data is lost.
Now I could be wrong but for cores that allow game saves and what not, it helps make sure the data is written/flushed to the SD card or external drive in case of a reset, power outage or even switching cores.
So unless the the flashing of the green light is annoying, I would leave it enabled.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 4:16 pm
by held
Well the partition is mounted with sync, so it should write to disk asap like @Malor pointed out.
I have seen no ill effects yet since it has been disabled (before my last visit here, so a couple of months) but YMMV.

Good catch on the reset, although I think that is a problem either way. It could still be syncing when the button is pressed.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 6:24 pm
by jca
You can always create a script containing "sync;sync" and run it before whatever you think could cause corruption. This would not be useful in case of power failure/hard reset by pulling the power plug.

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 7:19 pm
by pgimeno
The filesystem is already mounted with the sync flag; isn't that script redundant?

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 7:56 pm
by Flandango
Yes, since the "fat" partition and external drives are mounted with the sync option, the resync script is redundant. May be it was a hold over from earlier versions prior to adding the sync option to mount?

Re: Is the sync script an SD-card hazard?

Posted: Thu Nov 24, 2022 8:20 pm
by jca
I got confused by this post:
"Well the partition is mounted with sync, so it should write to disk asap like @Malor pointed out.
I have seen no ill effects yet since it has been disabled (before my last visit here, so a couple of months) but YMMV."

I did not realize the disabling was referring to the script.

Re: Is the sync script an SD-card hazard?

Posted: Fri Nov 25, 2022 9:40 am
by held
jca wrote: Thu Nov 24, 2022 8:20 pm I got confused by this post:
"Well the partition is mounted with sync, so it should write to disk asap like @Malor pointed out.
I have seen no ill effects yet since it has been disabled (before my last visit here, so a couple of months) but YMMV."

I did not realize the disabling was referring to the script.
Yes I proposed disabling the /etc/resync script if its a wear leveling hazard (or annoyance):

Code: Select all

#!/bin/sh
( while [ 1 ]; do sync; sleep 5; done ) &
triggered by /etc/inittab

Code: Select all

::sysinit:/etc/resync &