Steam Deck: Script to Store Individual Game Cache Files in SD Card

Antonio Rodríguez Negrón
12 min readOct 28, 2022
Symbolic link powa!

The Problem

The Steam Deck is a wonderful handheld gaming device, but it has one particular quirk that is very disappointing if you have a sizeable library and a small amount of local storage. That problem is that the device stores its shader pre-caching updates and compatibility data inside the user data partition on the device’s storage, taking up a significant amount of space which partly negates the benefit of using a micro SD card to store your games. This is particularly troublesome if you own the 64GB model, which is already fairly constrained by the amount of storage taken by the operating system.

The Basic Solution

Given that we know that the main problem is that the device does not store game-specific shader and compatibility updates in the micro SD card where the game has been installed, we need to fool the Steam Deck to look for that data there, even though it expects it to be stored on its own internal data partition. How do we do that? We take advantage of an operating-system feature known as a symbolic link! A symbolic link is a special kind of file that points to another file. It is possible to move the shader and compatibility files to the micro SD card and then create a symbolic link that points to their micro SD card location where the Steam Deck expects to find those files.

A global solution would be as simple as moving the entire contents of the /home/deck/.local/share/Steam/steamapps/compatdata and /home/deck/.local/share/Steam/steamapps/shadercache directories to the micro SD card and then using the symbolic link command to link to them in the micro SD card. I won’t explain how to do that in this article as there are a few guides that explain this already, and this is not the solution that I’ll be explaining now.

Solving the Problem for Each Individual Title

If you have a single micro SD card, it may make sense to move and then link the entire compatibility data and shader cache directories to the micro SD card and get it over with, as explained above. However, there is a problem with that solution: it means that even locally-installed games will look in the micro SD card for these files. What happens if you acquire another micro SD card? And then another? Things start to become tricky to manage at that point. That’s why I offer another solution: moving and linking the data for each game individually. That way the same micro SD card that contains a game will also contain its shader cache and its compatibility data. That makes sense, doesn’t it? This is where a script that I created comes in: run the script and it will ask for the Steam App ID for the game. Input this ID and boom, you’re good to go! The script will detect if you have shader cache or compatibility data for that game in your Steam Deck, move that data over to the micro SD card, and create the links so that Steam will continue to update those files on the micro SD card instead of your deck’s internal storage. If those files don’t exist yet, maybe because the game hasn’t been installed yet or because it hasn’t created them, the script will still do its job so that when those files are created, they will be created on the MicroSD card.

There are quite a few advantages to this approach, including:

  • Frees up space on the internal drive (for example I saved 700MB from moving MK11’s files to the micro SD card with this script)
  • Consolidate most, if not all, of a game’s data in its installation location
  • Extends the life of your internal storage as there are fewer write operations related to shader cache and compatibility data files

Of course, this is not a perfect solution. Here are some of the negatives:

  • Games may load a little slower because micro SD cards are slower than the internal storage, negating some of the advantages of shader pre-caching
  • May reduce the life of your micro SD cards as there will be more write operations to them (I prefer this over reducing the life of the internal drive though)
  • Need to be careful before hot-swapping micro SD cards to avoid data corruption; if the compatibility data and shader cache directories are not in the internal drive and some updates to those were being downloaded, you will interrupt the process if you hot swap the card at that moment
  • I’ve seen that some folks have installed SteamOS on their MicroSD cards and have been running it that way. This script does not cover that kind of use case, but users doing that are probably aware of that limitation anyway.

Make sure to weigh these considerations before proceeding. You may choose not to make use of the script and that is perfectly fine. However, if the thought of saving space and wear on your Steam Deck’s internal storage is something that you are interested in, please feel free to use this script.

Disclaimer:

This is the moment that I need to specify that I am not responsible for any damage that you may do to your Steam Deck from the use of this script. While I’ve been running it already and have had no issues with it, your mileage may vary. Proceed at your own risk!

Where to find the script:

I have set up a Github repository for the script. This means that you can download it from Github, fork it, and make custom changes if you wish to do so. More advanced users can use Git on the Steam Deck to download it directly from the repository. I was very pleasantly surprised when I found out that Valve had already included Git in the Steam Deck itself, so thanks for that Valve! Anyway, here’s the repository with the script:

Right now it only contains a Readme Markdown file and the moveCacheLocation.sh script but I may upload other scripts in the future so make sure that you are referring to the moveCacheLocation.sh script before running it.

How to Use the Script

Please feel free to use this guide if you feel comfortable with following written instructions. I have also uploaded a video on YouTube and on Rumble explaining how the script works and how to run it. Please follow the YouTube link below if you’d rather watch the explanation. Either way works fine; do what makes more sense to you! I do recommend to coming back to this article later on as I explain a few things in more detail here.

There are a few things to verify before we run the script:

  • The title that will have its data moved to MicroSD card must have been initially installed to MicroSD card. If you installed the title to internal storage first and then moved it to MicroSD card by using Steam’s “Move install folder…” option, the script (as it is today) will not work properly. So the best use practice is to install the game to MicroSD card directly and THEN run the script (or run it before installing the game to create the environment so all compatibility and shader pre-cache data is created on the MicroSD card to begin with; just make sure you actually choose to install it to MicroSD card if you do that when you actually install it!)
  • The title that will have its data moved to MicroSD card must actually be present in the current MicroSD card. If you run the script for a game that’s installed on a different MicroSD card, you now have the data on a MicroSD card that’s not present in the same card as the game itself and it will not do you any good! It may also cause other problems down the line as SteamOS will expect some directories that won’t be present when you run the game from its actual MicroSD card.
  • Download the script to your Steam Deck from the Github repository mentioned above.

Don’t make the mistake of typing the script out yourself. Download it to your Steam Deck or copy and paste it, please. That’s an area where the SSH connection can help; you browse to the script’s location through a browser on a smartphone or PC, copy the script, paste it into a new text file, and then upload that to the Deck. You can do that from the Deck itself as well by downloading or copy-pasting the script from a browser in Desktop mode.

You don’t need to set SSH up, but it will be very helpful if you do. I don’t have an SSH guide ready, but you should be able to find one easily if you look around. The big advantage of setting SSH up is that it will allow you to connect to your Steam Deck from an external computer and upload and run the script quite easily within the Steam Deck itself. It will also help you to browse the Deck’s file system from your PC, which can be useful. You may just download the script and run it directly from the Deck itself as well.

For the script to work, you will have to save it as a file with a sh extension and give it the proper permissions to execute. I named the file moveCacheLocation.sh. My recommendation is to save the script in the deck user’s home directory, then open up a terminal (I use Konsole, which the Deck already includes). You should be at /home/deck whenever you open Konsole. You can find this out by using the pwd command. That command returns the current path. Create your script by copy-pasting the contents of the script into a blank file (or download it) and name the file moveCacheLocation.sh. Finally, set the executable permissions bit:

chmod 700 moveCacheLocation.sh

Linux users will notice that, for the sake of convenience, I am actually setting read, write, and executable permissions in the file instead of just executable, and only for the current user. An alternate way to do it is to type:

chmod +x moveCacheLocation.sh

That isn’t as restrictive as chmod 700, but that shouldn’t be a big problem on the Steam Deck. Please, only run the script from the terminal; don’t try to run it from the file explorer (Dolphin). It may work, but I haven’t tested it that way. To call the script so that it executes you can’t just type the script’s name into the terminal. You need to tell the operating system that you want this file to be executed. To do that, you have two ways to type the command:

bash moveCacheLocation.sh

or

./moveCacheLocation.sh

The second method may look unusual if you’re a Windows user, but it’s pretty common in the Linux world. Anyway, either method will execute the script. Once the script is running, just follow the prompts. Oh, and make sure to have the App ID for the game that you want to move its compatibility and pre-cached shader cache data to the MicroSD card.

Obtaining a Game’s App ID

To obtain a game’s Steam App ID, you can either obtain it from the Updates pane within Steam, or you can go to a website such as the Steam DB (steamdb.info) and look for the App ID:

An App ID is all numbers, no symbols or letters. The script will only proceed if the App ID entered only contains numbers. There is no back end for the script to communicate with Steam to tell if the App ID entered was valid, so make sure that you have the right one. If you enter an App ID that’s all numbers, the script will run with that App ID and do its job, whether there’s any data for that App ID or not on your Steam Deck (if there’s no data, it will just create the directories and create the link as it assumes you want them to be created for when you actually install that game).

Advanced Uses

This script has been created for and tested on a Steam Deck. It may work on other SteamOS devices (in fact, I am 90% sure it should work as it is on other SteamOS devices with a single internal MicroSD card port). However, there may be other SteamOS devices released in the future that may do things differently. That’s ok; most of it should still work. Just check that the settings for the path variables apply to your device. Path variables?

If you open up the script to check its code, you will notice certain paths are defined as variables near the top of the script. The first one is the path name for the location of the MicroSD card:

sCardPath="/run/media/mmcblk0p1"

That’s where the MicroSD card is mounted on a Steam Deck. If you have a different device, the mount location for the MicroSD card may be different. If that’s the case, please modify this variable so it has the mount location for the MicroSD card in your device. The path goes inside the quotes; please don’t remove them. Future Steam Deck revisions may mount the MicroSD card in a different location, so it may also need to be modified in that case.

There are four more path variables defined in the script:

sLocalCompatDataRoot="/home/deck/.local/share/Steam/steamapps/compatdata"
sLocalShaderCacheRoot="/home/deck/.local/share/Steam/steamapps/shadercache"
sCardCompatDataRoot="$sCardPath/steamapps/compatdata"
sCardShaderCacheRoot="$sCardPath/steamapps/shadercache"

sLocalCompatDataRoot is the variable name for the directory with all of the compatibility data directories. If this is different on your device, you need to change it here. The most likely difference would be the name of the user (/home/deck). The default user name for the Steam Deck is deck. It may be different for your device and in that case, it needs to be adjusted.

The same thing applies to sLocalShaderCacheRoot. This is the name of the directory with all of the pre-cached shader data directories. Rename it if you need to do so for your device.

The variable named sCardCompatDataRoot is the parent location of the compatibility data directories on the MicroSD card. Please modify this variable if the paths are different for your device. The same applies to sCardShaderCacheRoot, except that this is for the pre-cached shaders.

I don't really anticipate that any other variables would need to be modified on a different device though, as I only have access to a Steam Deck and not any other SteamOS device. This is for a SteamOS device that’s running SteamOS from internal memory and not for one that’s running from the MicroSD card.

What if the Data’s already been moved?

Good question! The script has been written in such a way that it can detect if there is already a symbolic link for the data and will ask if you want to move it back to internal storage if that’s the case. Handy!

There is, however, a scenario that the script doesn’t cover. That scenario is if there are directories in both the internal storage and the MicroSD card for the same data. I have made a conscious choice to not handle that specific scenario right now. I do have it set as the top feature for a 2.0 release. How may you get duplicate directories in both internal storage and the MicroSD card for compatibility data? If you have installed the game to internal storage but later use the “Move install location” feature from Steam to move the game to MicroSD card, SteamOS will actually create a compatibility data directory for the game on the MicroSD card. It’s not a symbolic link. I haven’t spent enough time exploring how that works: is it a copy and there is data in both locations? How does Steam know which of those directories to use? Maybe there’s a specific file there to tell Steam or it looks for the most recent files? I don’t know right now and so I have decided to not handle that situation. The best course of action would be not to run the script for a game if you moved the install folder through the Move install location feature instead of installing it directly on the MicroSD card.

A Small Note:

I’m not the kind of person that begs for followers or that tries to get the largest amount of clout possible. I just write about what I like, whether it gets a lot of traction or not. However, if you have the means and enjoyed my content, please consider a small token of appreciation.

--

--

Antonio Rodríguez Negrón

Father of two, full of boundless curiosity. Tech Product Manager, hobby writer, amateur photographer, weekend tinkerer. https://ko-fi.com/arodznegron