RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    SD card corruption - tmpfs and swap approach

    Scheduled Pinned Locked Moved Help and Support
    sd cardswapcrash
    8 Posts 6 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alexxx
      last edited by

      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?

      mituM 1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator @alexxx
        last edited by mitu

        @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 with noatime
        • /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.
        A BuZzB 2 Replies Last reply Reply Quote 0
        • A
          alexxx @mitu
          last edited by

          @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 :-)

          1 Reply Last reply Reply Quote 0
          • Z
            zerojay
            last edited by

            I have my root FS on a hard drive. I still get corruptions and problems even when everything's unmounted cleanly.

            1 Reply Last reply Reply Quote 0
            • BuZzB
              BuZz administrators @mitu
              last edited by BuZz

              @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.

              To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

              mituM 1 Reply Last reply Reply Quote 1
              • mituM
                mitu Global Moderator @BuZz
                last edited by

                @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.

                cyperghostC 1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost @mitu
                  last edited by cyperghost

                  @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 with df /tmp
                  It will output mountpoint /

                  My output of df is

                  pi@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
                  
                  1 Reply Last reply Reply Quote 0
                  • SanoS
                    Sano
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post

                    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.