Take Advantage Of 2GB and 4GB RAM for a Virtual Disk to extract Roms to
-
I was reading up on how ROMS can and mostly are stored as a .zip or .7z and when you run them it will extract them to the zipped roms current path to execute them, I also know that this would often be kept on a Micro SD Card, the problem I see is SD cards wear out quickly with constant writing to them, so I was hoping that the main dev team of RetroPie would consider making an option available for a Virtual Disk Temp path(s) to reduce writes to the SD card by making the virtual disk the default extraction point for compressed roms. This would have a added benefit of loading roms faster as a virtual disk is MUCH faster than SD Read speeds. I was hearing how the 2GB and 4GB are overkill for most of the Emulation, this would add a feature to make use of such memory.
Sorry and disregard this if it is already possible within the RetroPie Settings , the Pi 4 4GB is my first Pi I have seen/used and I am keen to setup RetroPie for the first time in the near future. If I spot anymore improvements once I begin testing/building, I'll share them here.
-
RetroArch extracts the roms to its cache directory (
/tmp/retroarch
by default). You can mount/tmp/retroarch
to ram by adding this line to your/etc/fstab
.tmpfs /tmp/retroarch tmpfs nosuid 0 0
Editing the
fstab
requires administrative permissions. One way to edit it is the commandsudo nano /etc/fstab
in the RetroPie console.edit: The mount will take effect at the next boot or immediately by the command
sudo mount -a
.edit 2: You should make a backup of your
fstab
before editing it, lest you make your system unbootable by mistake:sudo cp /etc/fstab /etc/fstab.backup
-
@LiveFreeDead that's something to have in mind. Besides what @Clyde said, there are a few instances where temporary archives are unpacked in
/tmp/retropie-archive
when a source installation is performed.
Maybe the whole/tmp
can be RAM-backed - when enough memory is present. -
@mitu Yes, I also thought about that, but I didn't know how much of
/tmp
is used by RetroPie, so I played safe. At the moment, the/tmp
of my Retropie only holds 44K after running a mame 2003 plus game and an SNES game for a short time for testing, so I think it should be okay.@LiveFreeDead Just change
/tmp/retroarch
to just/tmp
to mount it into ram completely. You can check its total size with the commandsudo du -sh /tmp
, and your system's free memory withfree -h
.(The
sudo
beforedu
is needed because/tmp
holds at least one directory owned byroot
.) -
@Clyde I tried
/tmp/retroarch
and it did not improve the loading times and I get this message after loading a game:rm: cannot remove /tmp/retroarch : Operation not permitted
. I changed it to just/tmp
and the message is gone but it still doesn't improve load times.I'm using raspbian lite buster and retropie's pi4 repo. I guess this saves sd writes so that's a plus.
-
@Darksavior Ah, so RA creates the directory on runtime and deletes it afterwards. Then it would be better to put the whole
/tmp
into ram.That said, did the message prevent anything from happening? If not, one might just ignore it.
edit: As for the speed, @LiveFreeDead seemed more interested in preserving the flash memory of the sd card than to speed up the loading times.
-
@Clyde The only issue I could foresee is a lack of space for DVD sized roms or dual PSX roms, these will still need to use a swapdisk or disk tmp folder on the SD card, that would be the only reason I could see it failing, if anyone can come up with a check that can revert to default tmp the feature would near be possible already :D thanks for running tests tho, good to know it doesn't increase speeds, I really thought it would have on n64 or dreamcast sized roms.
-
@LiveFreeDead Alternatively, you could change RA's cache path to
/dev/shm
(shm = shared memory), the pre-installed ramdisk of Retropie. See https://github.com/RetroPie/RetroPie-Setup/wiki/RetroArch for the optioncache_directory
.That way, you could use the ramdisk only for some systems, but not others.
-
@Clyde No problems loading games with that error message. I changed it to
/tmp/
now, though.
@LiveFreeDead Well, you can disable runcommand's launch menu to shave off a few seconds :D -
@Darksavior One other potential problem with
/tmp/retroarch
came to my mind. If it doesn't exist on boot time because RA deleted it, the auto-mount viafstab
will fail. After one successful mount however, it will be protected from deletion by the mount.Thus, the safe sequence would be:
- Create the directory via
mkdir -p /tmp/retroarch
- Edit the
fstab
like described above. - Reboot.
Then, the directory will be there on boot time, the mount to ram will happen, and prevent deletion until shutdown. Rinse and repeat. :)
This isn't necessary if the whole
/tmp
is mounted to ram, of course. - Create the directory via
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.