‘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
- You must have a btrfs formatted home partition. You can find how to do this [here](https://gitlab.com/popsulfr/steam os-btrfs)
- 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.
- (optional) Back up your /home partition to an external device or off site location such as cloud storage.
- 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
- Make sure your home partition is btrfs and that all the data you care about is backed up.
- Open konsole and enter a su shell:
sudo -s
- Unmount your sdcard using
mount /run/media/mmcblk0p1
- If your sdcard is not already formatted btrfs from SteamOS BTRFS, do
mkfs.btrfs /dev/mmcblk0p1
- Add the sdcard to the home volume:
btrfs device add -f /dev/mmcblk0p1 /home
- (optional) Balance the filesystem:
btrfs filesystem balance start /home
. This can take a VERY long time. - 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.
- Copy all the data you backed up to
/home/deck
- Enter your steam library folder that was originally on your sdcard.
- Merge the
steamapps
folder with your main steam library folder (usually/home/deck/.steam/steam/steamapps
) - 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.
- Run the command
free -m
. - 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.
- Open konsole and enter a su shell:
sudo -s
- Create the new subvolume:
btrfs subvolume create /home/@swap
. - Set the attributes to allow swap:
chatter -R +C /home/@swap
. - Create the swapfile with
truncate -s 0 /home/@swap/swapfile
- 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
. - Set the permissions for it:
chmod 600 /home/@swap/swapfile
. - Make it a swap file:
mkswap /home/@swap/swapfile
- Add the following line to
/etc/fstab
and save it:/home/@swap/swapfile swap swap defaults 0 0
- Enable swap:
swapon /home/@swap/swapfile
- Run
free -m
to check if it worked. - 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.
- Open konsole and disable the read only filesystem:
sudo steamos-readonly disable
- Run
sudo pacman-key --init
- Populate the keyring:
sudo pacman-key --populate archlinux
- Update with
sudo pacman -Syu
Gparted
- Install gparted:
sudo pacman -S gparted
- Run gparted and give it your sudo password.
- Select the physical device you want to shrink the partition on.
- If possible prevent anything from writing to the disk to avoid corruption.
- Right click the allocated space and hit resize/move.
- 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 😂
Thanks for moving this here!