Steam Deck: Improved Data Transfer Script
Inspect and Adapt!
It wasn’t that long ago that I posted instructions for a script that moves compatibility and shader pre-cache data from the Steam Deck’s internal memory storage to the MicroSD card for a specific game. This really helps out to save space on the Deck’s internal storage. It also extends its life as there will be fewer write operations to it. After sharing the script on Reddit, there was an immediate request to offer a version of it that didn’t require the AppID of the game to be moved. Ideally, it would look into the MicroSD card currently placed in the Steam Deck, and offer a choice of which game, of those in the current MicroSD card, to have its compatibility and shader pre-cache data moved to MicroSD card. This new script is that request, brought to code! It features the following improvements:
Friendlier UI
As mentioned above, this script will read the current MicroSD in the Steam Deck’s MicroSD slot, and return the games installed in it. That way, there are no errors because of the user typing the wrong AppID.
After running the script, the user will be presented with the list of games installed on the current MicroSD card, and a number is assigned to each of those games. Look at the topmost entry in the sample screenshot: “1) 1121560-Atelier_Ryza:_Ever_Darkness_&_the_Secret_Hideout.”
That kind of interaction avoids errors with the AppID, and also makes sure that the script is only run on games that are actually present on the current MicroSD card. This is a nice improvement over the first script that I created.
Conflict Resolution
Another useful feature of this script is that it’s able to handle a specific use case that the older script ignores: it can identify if the compatibility and shader pre-cache data directories are present in both the internal storage drive and the MicroSD card. If that happens, the script will let the user know and request confirmation to delete the directories located in internal storage and create a symbolic link to the directories located in the MicroSD card. The main goal is to save space on internal storage and to minimize write operations to it (to extend the life of the internal SSD) so having the data on the MicroSD card is prioritized. Now, is this scenario likely to happen very often? I don’t think so, but I’d rather treat it as an identified and handled edge case over ignoring it.
How to Work It!
Now that I’ve written a bit about the script and its features, let’s get into the nitty-gritty! First things first, let’s obtain the 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!
Also, you may want to follow my videos instead of this article if you prefer it that way or simply want to see the script working before committing:
YouTube Link: https://youtu.be/eN2jSfvatJo
Rumble Link: https://rumble.com/v1wbfdw-an-improved-script-to-save-storage-space-on-steam-deck.html
Downloading the Script
Like my first script, you can locate the transferCacheToSDCard.sh script from my github. You can download the raw text version from there, but I want to explain how to use git to download it to your Steam Deck this time. Git is included in the Steam Deck, and it would be a shame to ignore this great tool!
Run a Terminal on your Steam Deck
You can boot into Desktop Mode by opening the Power Menu and selecting the Desktop Mode option and from there, you can open Konsole. That’s the easiest way to get a terminal running in your Steam Deck, and it will use the bash shell, which is what the script expects.
You can also connect to your Steam Deck via SSH. That’s my preferred option, but this is not an article about SSH so you can safely ignore this if you haven’t set SSH up on your device.
Clone my GitHub Repository
Once you have a terminal up and running, via Konsole on your Steam Deck or via SSH session, I suggest creating a new directory for anything you download via git on your home directory. For this example I will create a directory called scriptTests, but you can name it whatever you want:
mkdir scriptTests
That should have created your directory. Now let’s change into that directory with the change directory command:
cd scriptTests
Remember that you can name it whatever you want. Maybe something like awesomeScripts or the like! Anyway, once inside the new directory, we want to use git to clone the contents of the repository with the script into your Steam Deck. You will now type the following:
git clone https://github.com/silverthornne/steamdeckbash
Git will create a new directory called steamdeckbash inside your current directory, and it will download the contents of the repository to that directory. You can see for yourself by changing to that new directory:
cd steamdeckbash
Let’s list the contents to make sure that we have everything that we need in there:
ls -lrt
The “ls” command is the standard command to list contents in a directory. I used the l, r, and t parameters to have a nice detailed list ordered by date. If you don’t use parameters, it will just type them all in an unordered sequence. There won’t be many files there, so that will probably not matter, but I prefer the detailed view to see permissions and file sizes. Anyway, you should see something similar to this:
(deck@deckprime steamdeckbash)$ ls -lrt
total 64
-rw-r--r-- 1 deck deck 24655 Nov 5 20:50 moveCacheLocation.sh
-rw-r--r-- 1 deck deck 3794 Nov 11 15:07 README.md
-rw-r--r-- 1 deck deck 30952 Nov 18 11:55 transferCacheToSDCard.sh
(deck@deckprime steamdeckbash)$
Set Executable Permissions
Notice that funny sequence of letters and dashes with “-rw-r — r — “
We call those permissions. The scripts, even though they are in .sh format, can’t be executed right now because they lack the proper permissions to be executable. We’re going to fix that:
chmod +x transferCacheToSDCard.sh
The chmod command changes permissions on files. The +x parameters means that you want to add the executable permission. Once you do that, perform another ls -lrt and you should get something like this:
(deck@deckprime steamdeckbash)$ ls -lrt
total 64
-rw-r--r-- 1 deck deck 24655 Nov 5 20:50 moveCacheLocation.sh
-rw-r--r-- 1 deck deck 3794 Nov 11 15:07 README.md
-rwxr-xr-x 1 deck deck 30952 Nov 18 11:55 transferCacheToSDCard.sh
(deck@deckprime steamdeckbash)$
Notice that the transferCacheToSDCard.sh file now has the letter “x” added three times on its listing. That means that it can now be executed. There’s a whole world out there about Linux permissions, and this article isn’t really about it, so I won’t go into any more detail about that. Just keep in mind that you need to add executable permissions to scripts so you can actually use them as an executable file (run them).
Run the Script
There are two ways to run the script:
./transferCacheToSDCard.sh
The first method (above) is to type a period and a slash in front of the name of the script. That tells the terminal to treat the script as an executable. A special character at the top of the script, called a shebang, points the operating system to the script interpreter to use. That’s why the script starts like this: #!/bin/bash
That’s the shebang telling the operating system to use the bash shell to run the script. The second method to run the script is to explicitly use the bash command:
bash transferCacheToSDCard.sh
No guessing there. You’re explicitly requesting to run the script in bash. Either way of running the script is fine. I’ve run into the first method a lot more than the second one though! Hardly any other Linux users I know use the second method.
Anyway, once the script runs, you will be presented with a disclaimer:
You need to accept the disclaimer to proceed. The way to do that is to type “1” (without the quotes) and press the “Enter” key.
Once you do that, the script will display a list of every game you have installed in your MicroSD card. Depending on how many games you have in there, you may need to scroll in order to see them all. There are two important things to note:
There will be a number on the left of each game preceded by a closing parenthesis character, such as “1)” Then you will see a number, which is the game’s AppID, a dash, and the game’s title. The title won’t have spaces in it, instead opting to use underscores as spaces. So a list of your games may look something like this:
1) 1121560-Atelier_Ryza:_Ever_Darkness_&_The_Secret_Hideout
2) 1132980-There_Is_No_Light
3) 1293830-Forza_Horizon_4
And so on. To choose a game from that list, you need to type the number in front of it. For example, if I wanted to proceed with Forza Horizon 4, I would type “3” into the prompt (without the quotes), and press the “Enter” key.
The script will ask you to confirm by telling you what to type for “Yes,” and which option for “No.” It works exactly the same as the previous script in that sense, moving the compatibility data and shader pre-cache data to the MicroSD card to save on storage space or moving them back to internal storage if you’ve had a negative experience, as some games may suffer a performance hit if the data is not present on internal storage. You will have to experiment to determine if it’s a good idea to have a particular game’s compatibility and shader pre-cache data on the MicroSD card or not. At least the script lets you move the data back and forth by running it again for that particular game.
Conflict Resolution Feature
This is a big difference from my first script, the moveCacheLocation script. That script could only be run on games that had been initially installed on the MicroSD card. When you use Steam’s “move install location” feature, it sometimes seems to leave a copy of the compatibility and shader pre-cache data on internal storage while creating a copy on the MicroSD card. So the older script didn’t really support games that had been moved to MicroSD card through that option. That has been fixed with this script.
When you run the transferCacheToSDCard.sh script, it will detect if there is compatibility and shader pre-cache data on both internal storage and the MicroSD card, alerting the user about the conflict. When this happens, if the user decides to proceed, the script will delete the compatibility and shader pre-cache directories located on internal storage, and create symbolic links to these directories on the MicroSD card. The reason for this behaviour is that the aim of the script is to save storage and write functions on the internal storage, so it prioritizes the data on the MicroSD card.
If you would rather keep the data on internal storage, then choose to not proceed if a conflict is identified by the script.
Advanced Uses
This is just a repeat of the information in the article about the moveCacheLocation.sh script, as both scripts support customizing the paths if you need to for some reason. Of course, I’m sharing this information because I am following the assumption that if you need to do this, you know what you’re doing.
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.
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.