Is the sync script an SD-card hazard?

For topics which do not fit in other specific forums.
held
Posts: 185
Joined: Sun Sep 26, 2021 2:18 pm
Has thanked: 24 times
Been thanked: 29 times

Is the sync script an SD-card hazard?

Unread post 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?
User avatar
LamerDeluxe
Posts: 860
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 543 times
Been thanked: 190 times

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

Unread post by LamerDeluxe »

What does it sync? The capacitor sounds like an interesting idea.
Malor
Posts: 571
Joined: Wed Feb 09, 2022 11:50 pm
Has thanked: 32 times
Been thanked: 124 times

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

Unread post by Malor »

The /media/fat directory is already mounted sync, so the 5-second sync script probably isn't doing much of anything.
held
Posts: 185
Joined: Sun Sep 26, 2021 2:18 pm
Has thanked: 24 times
Been thanked: 29 times

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

Unread post 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.
Flandango
Core Developer
Posts: 245
Joined: Wed May 26, 2021 9:35 pm
Has thanked: 25 times
Been thanked: 210 times

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

Unread post 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.
held
Posts: 185
Joined: Sun Sep 26, 2021 2:18 pm
Has thanked: 24 times
Been thanked: 29 times

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

Unread post 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.
jca
Posts: 1275
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 93 times
Been thanked: 255 times

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

Unread post 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.
User avatar
pgimeno
Posts: 582
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 212 times
Been thanked: 180 times

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

Unread post by pgimeno »

The filesystem is already mounted with the sync flag; isn't that script redundant?
Flandango
Core Developer
Posts: 245
Joined: Wed May 26, 2021 9:35 pm
Has thanked: 25 times
Been thanked: 210 times

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

Unread post 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?
jca
Posts: 1275
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 93 times
Been thanked: 255 times

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

Unread post 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.
held
Posts: 185
Joined: Sun Sep 26, 2021 2:18 pm
Has thanked: 24 times
Been thanked: 29 times

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

Unread post 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 &
Post Reply