Skip to content

Instantly share code, notes, and snippets.

@logan2611
Last active May 20, 2024 05:25
Show Gist options
  • Save logan2611/837a1897fbfaea7b8dd2def6594b7806 to your computer and use it in GitHub Desktop.
Save logan2611/837a1897fbfaea7b8dd2def6594b7806 to your computer and use it in GitHub Desktop.
Deck for Enthusiasts Guide

Deck for Enthusiasts

This is a guide that I put together which is primarily aimed at Steam Deck enthusiasts and developers. I will be updating this over time as I think of more things to put in here.

Table of Contents

SteamOS Tweaks

Btrfs

Btrfs has a few advantages over ext4 on the Deck. The most notable and relevant features being:

  • Native, transparent file compression
    • Typically saves 15-25% of disk space and grants a similar read/write increase when I/O bottlenecked (typical on microSD cards and the 64GB Deck's internal storage).
    • This option also increases the life expectancy of your storage as it writes less data to the disk.
  • The "ssd_spread" option
    • This option can potentially increase performance on MicroSD cards and the 64GB model's internal storage.
  • Deduplication
    • This can massively reduce disk space by having duplicate files only be stored on disk once. This provides massive benefits with the Wine prefixes that Steam/Proton generates. (Up to 400MB saved per Windows game!)

I have had great success with https://gitlab.com/popsulfr/steamos-btrfs, it installs very easily, persists through updates, can convert your home partition in place to Btrfs, and also supports mounting your microSD card with Btrfs and F2FS. I highly recommend reading the README as it contains useful information.

You can change the default compression level in order to increase or decrease the amount of space you save at the cost of CPU usage (aka power consumption).

zram

The Deck comes with an abysmal 1GB of on disk swap space, which can quickly get used up. This swap space can cause unnecessary writes to the disk, decreasing performance and potentially degrading your eMMC/SSD. Replacing this small swap space can not only sometimes increase performance, but can also increase the longevity of your eMMC/SSD and give you an extra GB of disk space to work with. This may also permit more RAM heavy games/applications to open and function well as they effectively have more memory to work with.

The Linux kernel comes with something called "zram", a kernel module that creates compressed RAM disks which can be used to create swap space in RAM. The Deck comes with a service that can easily create and configure zram to be used as swap space called "systemd-swap".

This solution isn't perfect though, if RAM has a lot of incompressible data this solution will be effectively as good as having no swap at all, however generally this is not the case. Additionally there is some CPU overhead as well, however I have found this to be inconsequential compared to the I/O overhead introduced by swapping to disk. Lastly, zram uses the CPU in order to compress the data, which can potentially lead to increased power usage (However, I have found this difference to be minimal. Writing to the internal storage also takes power.).

The procedure I used is as follows (Requires a password on the "deck" account):

  1. Disable SteamOS's swap file creation and mounting service.
    sudo systemctl mask home-swapfile.swap swapfile.service
    
  2. Open /etc/systemd/swap.conf in a text editor (requires root). Disable zswap and enable zram. You can optionally also adjust the total size of the zram devices created and the compression algorithm used. I do not recommend going over 1/2 of the RAM and to use the default compression algorithm, zstd. The beginning of the file should look approximately like this, changing options as you see fit (comments omitted):
    zswap_enabled=0
    #zswap_compressor=zstd
    #zswap_max_pool_percent=25
    #zswap_zpool=z3fold
    zram_enabled=1
    zram_size=$(( RAM_SIZE / 2 ))
    #zram_count=${NCPU}
    #zram_streams=${NCPU}
    #zram_alg=zstd
    
  3. Save that file and enable the systemd-swap service so that it starts on the next boot.
    sudo systemctl enable systemd-swap
    
  4. (Optional) Adjust the "swappiness" value. SteamOS comes with a swappiness value of 100, which tells the kernel to swap as often as possible, however this might not always be desirable as it can cause unnecessary CPU overhead while idling. However if your RAM usage increases to nearly full it could slightly reduce performance as it has to swap things that would've likely gotten swapped earlier. If you want to change it, open /etc/sysctl.d/swappiness.conf as root and adjust the value to your liking (0 being swap as little as possible, 100 being as aggressive as possible).
  5. Reboot.
  6. Check to make sure that systemd-swap is working by checking the service's output for any errors using systemctl status systemd-swap. Additionally, check to see if the new swap space showed up by running free -mh and looking at the "Swap" row. If there is 1GiB (1024 MiB) more swap space than you expected, step 1 likely didn't work.
  7. If all is good, delete the old swap file.
    • If you are using SteamOS-Btrfs, use the following commands:
       sudo rm /home/@swapfile/swapfile && sudo touch /home/@swapfile/swapfile
      
    • If you are on a normal SteamOS install, use these commands:
       sudo rm /home/swapfile && sudo touch /home/swapfile
      

Automatic mounting of external drives

SteamOS does not support automatically mounting any drives other than the MicroSD out of the box. This can be quite annoying as you currently have to go into desktop mode and then manually mount and and them as a drive to Steam. However, the mechanism SteamOS uses to automatically mount drives can easily be extended to include any drive you want.

  1. Create and open /etc/udev/rules.d/99-external-mount.rules in a text editor (requires root). Add the following contents:
    KERNEL=="sd[a-z][0-9]", ACTION=="add", RUN+="/bin/systemctl start sdcard-mount@%k.service"
    KERNEL=="sd[a-z][0-9]", ACTION=="remove", RUN+="/bin/systemctl stop sdcard-mount@%k.service"
    
    (Some drives may need different rules)
  2. Save and then run these commands:
    sudo udevadm control --reload-rules
    sudo udevadm trigger
    

Now drives should automatically pop up in Settings -> Storage when they are inserted (can sometimes take a few seconds).

Other

Extra Deck Hardware Info

  • SoC: AMD Van Gogh/Aerith
    • TDP: 1-30W1
    • CPU:
      • 4C/8T (1 CCX) @ 2.8GHz Base/3.5GHz Boost
      • 7nm Lithography
      • L1 Cache: 256KB
      • L2 Cache: 2MB
      • L3 Cache: 4MB
    • GPU:
  • Wireless: Azurewave AW-CM421NF (RTL8822CE)
  • Storage:
    • 64GB: Foresee FE2H0M064G-B5X10
    • 256GB: Phison PS5013-E13-354
    • 512GB: Kingston OM3PDP3512B-A014
  • Audio
    • Audio Coprocessor: AMD ACP 5.x
    • DACs:

1As reported by the kernel

4Some models ship with a different SSD model, but I do not know which model these have yet



TODO: Dual booting with rEFInd

TODO: Getting other Linux distros to work on the Deck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment