‘Salvage’ from reddit
Original post:

For those of us with the 64 gig model, having a small home partition can be an issue from time to time. While you can symlink compatdata and shadercache to the sdcard, flatpaks are more difficult and you may have other files taking up space too.

Disclaimer

I am not responsible for you borking your deck or losing any data. This is not for everyone, and if you can get away with symlinking I highly recommend doing that instead. You will not be able to swap out the sdcard without data loss after this process.

Prerequisites

  1. You must have a btrfs formatted home partition. You can find how to do this [here](https://gitlab.com/popsulfr/steam os-btrfs)
  2. You must back up any existing data on your sdcard to an external device or an off site location such as cloud storage. This can take a long time depending on how much data you have.
  3. (optional) Back up your /home partition to an external device or off site location such as cloud storage.
  4. You must have a sudo password.

Using your sdcard as Adoptable Storage

There may be a way to do this more directly without data loss, but I will go with my current solution based on my somewhat limited knowledge of the btrfs filesystem.

How to

  1. Make sure your home partition is btrfs and that all the data you care about is backed up.
  2. Open konsole and enter a su shell: sudo -s
  3. Unmount your sdcard using mount /run/media/mmcblk0p1
  4. If your sdcard is not already formatted btrfs from SteamOS BTRFS, do mkfs.btrfs /dev/mmcblk0p1
  5. Add the sdcard to the home volume: btrfs device add -f /dev/mmcblk0p1 /home
  6. (optional) Balance the filesystem: btrfs filesystem balance start /home. This can take a VERY long time.
  7. Reboot and go back to desktop mode.

Restoring data

I will go through the steam folder, but for other files you can pretty much drag and drop.

  1. Copy all the data you backed up to /home/deck
  2. Enter your steam library folder that was originally on your sdcard.
  3. Merge the steamapps folder with your main steam library folder (usually /home/deck/.steam/steam/steamapps)
  4. Go to your steam library and click install on all the games that were on your sdcard. Steam should verify them and then let you play. If you know a way to merge the .vdf file please mention it.

Check your swap file

In my case, the swap file was not working, you may have to create a new one.

  1. Run the command free -m.
  2. If the Swap row doesn’t say 0 0 0 your all good. If it does, continue on.

No swap file

Note: I was not able to use the existing @swapfile subvolume from SteamOS BTRFS for some reason, so I will show the process of making a new one.

  1. Open konsole and enter a su shell: sudo -s
  2. Create the new subvolume: btrfs subvolume create /home/@swap.
  3. Set the attributes to allow swap: chatter -R +C /home/@swap.
  4. Create the swapfile with truncate -s 0 /home/@swap/swapfile
  5. Allocate storage to the swap file. You can allocate as much as you’d like. I tend to do a lot of memmory heavy things, so I will make it 16 gigs: fallocate -l 16384M /home/@swap/swapfile.
  6. Set the permissions for it: chmod 600 /home/@swap/swapfile.
  7. Make it a swap file: mkswap /home/@swap/swapfile
  8. Add the following line to /etc/fstab and save it: /home/@swap/swapfile swap swap defaults 0 0
  9. Enable swap: swapon /home/@swap/swapfile
  10. Run free -m to check if it worked.
  11. Reboot and run free -m in konsole again to make sure it stuck.

Leaving extra unallocated space

Btrfs is bad at handling running out of space! Like, really bad! It basically makes its self read only with no way out. To avoid this you should leave a few gigs of unallocated space.

Setting up pacman

If you already have pacman set up skip this.

  1. Open konsole and disable the read only filesystem: sudo steamos-readonly disable
  2. Run sudo pacman-key --init
  3. Populate the keyring: sudo pacman-key --populate archlinux
  4. Update with sudo pacman -Syu

Gparted

  1. Install gparted: sudo pacman -S gparted
  2. Run gparted and give it your sudo password.
  3. Select the physical device you want to shrink the partition on.
  4. If possible prevent anything from writing to the disk to avoid corruption.
  5. Right click the allocated space and hit resize/move.
  6. Add to Free Space Following (MiB). I did 3 gigabytes, so that would be 3072.

“Help I ran out of space!”

If you have done this process, just expand the btrfs partition with gparted, delete some files, and run sudo btrfs balance start /home in konsole and wait. Wait a long time. Probably several hours.

After that re-create the unallocated space in case it happens again.

Done!

You now should have a home partition that spans across multiple devices and a working swap file.

P.S. I’m writing this because I have a migraine and can’t do anything, but I’m bored. So if there are any mistakes please yell at me in the comments 😂

  • @jmf
    link
    211 months ago

    Thanks for moving this here!