SD card corruption - tmpfs and swap approach
-
I just had my 2nd SD corruption on retropie - due to hard reboots that can happen when dealing with ROMs of uncertain origin...
The cards where both high quality and non-chinese.
I have a pair of Raspberries doing other chores around here, and they run smoothly since forever despite occasional crashes, thanks to a tuning of the tmpfs and the swap file systems , from an old recipe I found here http://ideaheap.com/2013/07/stopping-sd-card-corruption-on-a-raspberry-pi/So I was wondering if something like this could be applied to the Retropie, or instead if the emulators require that I leave it alone ...
what do you think?
-
@alexxx The improvements suggested in that post (which is quite old, btw) are already implemented in Raspbian, the OS used by the RetroPie image:
/tmp
is mounted in memory- the
/
partition is mounted withnoatime
/var/run
is mounted in memory (already acknowledged in the article)/dev/shm
is also mounted in memory - this is where the logs from emulators that are running or the temp configuration files are stored.- swap is not used unless installing from source for a few memory intensive compilation with packages like EmulationStation. In this case a temporary swap file is created during the compilation, and deleted afterwards.
-
@mitu thank you for the answer...
I know the post is old, but it served me well along the years.
I'm happy to know that Raspbian uses this tricks already - although it still leaves me with the problem of my cards' corruption - probably it's just that I leave it switched on 24/7 - you never know when the desire to play Pastfinder will come to you :-) -
I have my root FS on a hard drive. I still get corruptions and problems even when everything's unmounted cleanly.
-
@mitu said in SD card corruption - tmpfs and swap approach:
/tmp
is mounted in memory
This is not default on the RetroPie/Raspbian image afair. /tmp is on the sdcard.
- swap is not used unless installing from source for a few memory intensive compilation with packages like EmulationStation. In this case a temporary swap file is created during the compilation, and deleted afterwards.
Swap is created and used as needed. RetroPie can add additional swap for some package building, but the system does come with some swap enabled as default.
-
@buzz said in SD card corruption - tmpfs and swap approach:
@mitu said in SD card corruption - tmpfs and swap approach:
/tmp
is mounted in memory
This is not default on the RetroPie/Raspbian image afair. /tmp is on the sdcard.
You're right, this is the default in Debian, but it seems not in Raspbian.
-
@mitu You're right
files created in /tmp get vanished after reboot but it's not mountend in memory. It's just emptied after a reboot. This seems to make no difference (someone might think) but if you do heavy writing to/tmp
this will cost SD-card lifecycles ;)
You can check withdf /tmp
It will output mountpoint/
My output of
df
ispi@retropie:~ $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 3714944 3172340 356232 90% / devtmpfs 370708 0 370708 0% /dev tmpfs 375316 0 375316 0% /dev/shm tmpfs 375316 5252 370064 2% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 375316 0 375316 0% /sys/fs/cgroup /dev/mmcblk0p1 58234 21536 36698 37% /boot /dev/sda1 31158272 23856128 7302144 77% /media/usb0
-
For information, I formatted my root partition with F2FS more than a year ago, and never had a corruption since.
The main drawback is that it's more difficult to resize ATM than ext4 or xfs.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.