Merge pull request #14 from VagabondAzulien/deck

Update Steam Deck Syncthing post
This commit is contained in:
Bill Niblock 2022-07-12 17:05:35 -04:00 committed by GitHub
commit c4b0af282b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,120 +1,149 @@
--- ---
tabtitle: "Syncthing on the Steam Deck" tabtitle: "Syncthing on the Steam Deck"
title: "Setting up Syncthing on the Steam Deck" title: "Setting up Syncthing on the Steam Deck (Updated!)"
topics: [gaming] topics: [gaming, technology]
pub: "2022-07-04" pub: "2022-07-12"
short_desc: "Syncthing is an incredible tool that I use to keep pictures, short_desc: "Syncthing is an incredible tool that I use to keep pictures,
music, notes, and games synchronized across multiple platforms. The form music, notes, and games synchronized across multiple platforms. The form
factor of the Steam Deck makes it a perfect emulation target, and Syncthing factor of the Steam Deck makes it a perfect emulation target, and Syncthing
can help keep games and saves in-sync with other machines." can help keep games and saves in-sync with other machines."
--- ---
# Syncthing on the Steam Deck # Syncthing on the Steam Deck (Updated!)
## Update
Turns out, when you update the SteamOS, it completely over-writes the operating
system. All of the setup I had originally written was great, if I never update,
which is unacceptable. Not all is lost; the quest simply gets harder. If I can't
rely on system-wide services, then I rely on user services.
### The Wrong Way: System-Wide Services
My first attempt was to setup Syncthing as a system-wide service managed by
`systemd`, installed via `pacman`. There are several problems with this. First,
it requires disabling the read-only file-system. Next, `pacman` is not setup nor
reliable, since every SteamOS update will over-write any changes I make to any
of the read-only file-system, including the directories that `pacman` relies on.
Related, the update will also erase the Syncthing package. This means I either
never update (inadvisable, and unacceptable), or I setup Syncthing not in the
read-only file-system.
### The Right Way: User Services
systemd allows for non-root-based services, called user services. The Arch Wiki
[systemd/User](https://wiki.archlinux.org/title/Systemd/User) article describes
this functionality much more than I will. Here are the relevant details:
- User services can be enabled to start when a user logs in
- Service files are stored in the user's home directory (specifically
`~/.config/systemd/user`)
- No root privileges are required. No modifying the read-only file-system
## Syncthing
Syncthing is incredible. I've [written about it Syncthing is incredible. I've [written about it
before](2020/07/19/syncthing-part-1.html), but the setup here is a bit more before](2020/07/19/syncthing-part-1.html), but the setup here is a bit more
involved. The Steam Deck runs Arch Linux (and have I told you yet today that I involved. The Steam Deck runs Arch Linux (and have I told you yet today that I
do too?), so the Arch Wiki [article on do too?), so the Arch Wiki [article on
Syncthing](https://wiki.archlinux.org/title/Syncthing) gives some good insight. Syncthing](https://wiki.archlinux.org/title/Syncthing) gives some good insight.
When I initially started this process, I installed the `SyncthingGTK` When I initially started this process, I installed the SyncthingGTK application
application from the Discover Store. This means it is a Flatpak application, and from the Discover Store. This means it is a Flatpak application, and so doesn't
so doesn't require elevated user privileges. After setting it up, I realized require elevated user privileges. I also tried the Syncthingy application, which
that I would need to run the application in order for the Syncthing daemon to explicitly calls out Steam Deck users. However, both require running the Flatpak
start and sync. I see in the options that `SyncthingGTK` can be configured to in the background (like some users do for Discord or Spotify). I don't like
start at launch minimized, and this _may_ resolve that issue. I decided to go a this, it feels off, and thus I sought a different approach.
different route and setup Syncthing how I'm used to it. This required disabling
the Steam Deck's read-only file system, configuring `pacman`, installing the
Syncthing daemon, enabling and starting the service, and then configuring
Syncthing through the web-UI.
### Preface ## SSHD: Still Incredibly Useful
Disabling the Steam Deck's read-only file system is not advised if you're not
comfortable with the reality that you can seriously mess up the device with
little to no effort. Use the `SyncthingGTK` option, and just start it when you
need to sync. Heck, do what I'm too lazy to do, and check if by enabling the
options to start it on login minimized, it still synchronizes in the background!
If you want to do what I did (which, as a final warning, may not be a good
decision), read on.
I got real tired real quick of using the on-screen keyboard. After I got real tired real quick of using the on-screen keyboard. After
complaining, a friend recommended I enable `sshd` and just remote in to the complaining, a friend recommended I enable `sshd` and just remote in to the
device. Doing so was a breeze, and I recommend to others who don't have a device. Doing so was a breeze, and I recommend to others who don't have a
physical keyboard they can plug into their device. Drop to desktop mode physical keyboard they can plug into their device. Drop to desktop mode
(hold the power button for a few seconds, and select the option), and start a (hold the power button for a few seconds, and select the option), and start a
terminal (default is `Konsole`). Start the service, `sudo systemctl start sshd`, terminal (default is Konsole). Before remotely accessing the device, or using
and optionally enable it to have `sshd` automatically started on each boot
(`sudo systemctl enable sshd`). Before remotely accessing the device, or using
elevated privileges via `sudo`, I need to set a password for the default user, elevated privileges via `sudo`, I need to set a password for the default user,
`deck`. From the same terminal, type `passwd` and set it (and then put it in _deck_. In the terminal, type `passwd` and set it (and then put it in your
your password vault so you don't forget. You _do_ have a password vault, password vault so you don't forget. You _do_ have a password vault, right?).
right?). Next, get the device IP with `ip addr list`, from my desktop run `ssh Start the service, `sudo systemctl start sshd`, and optionally enable it to have
deck@ip-address`, type in the password, and now I'm a grade-A Hackermans. `sshd` automatically started on each boot (`sudo systemctl enable sshd`). Get
the device IP with `ip addr list`, from my desktop run `ssh deck@ip-address`,
type in the password, and now I'm a grade-A Hackermans.
### Disable SteamOS Protections This setting is not reset on SteamOS updates, that I can tell. Once enabled,
this will always start at boot, and always be on until explicitly turned off. Be
mindful of that if you decide to wander away from your home network; maybe turn
it off in public if you don't need it.
Using the `steamos-readonly` command, I can enable, disable, and check the ## Setup
status of the read-only protections. For now, I will disable them:
There are 2 things required: a systemd service file, and the `syncthing`
binary. Syncthing is written in Go, and a compiled binary can be downloaded that
has no dependencies or installation requirements. It can be downloaded from
the [Syncthing
Releases](https://github.com/syncthing/syncthing/releases/tag/v1.20.3) page for
many platforms and architectures. The Steam Deck is a Linux platform, using the
AMD64 architecture (or x86_64), so I grab that one. I'll note here, since I have
SSH access, I do all the editing and downloading on my desktop, and then
transfer the files using `scp` to the Deck. All of these steps can be done on
the Deck itself, without SSH access. Once the proper tarball has been
downloaded, extract it, and within will be the `syncthing` binary, ready to
rock. I copy/move the binary to `~/.local/bin/syncthing` on the Deck. The exact
location is less important than ensuring the binary is within my home directory
on the Deck.
The systemd serivce file can also be taken from the extracted tarball, but
requires modification. In the tarball, it is
`etc/linux-systemd/user/syncthing.service`. Copy this file to
`~/.config/systemd/user` on the Deck, and edit the "ExecStart" line in the
"[Service]" section from
``` ```
sudo steamos-readonly disable ...
[Service]
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
...
``` ```
### Pacman Configuration to
Next configure `pacman`:
``` ```
sudo pacman-key --init ...
sudo pacman-key --populate [Service]
sudo pacman-key --refresh-keys ExecStart=/home/deck/.local/bin/syncthing serve --no-browser --no-restart --logflags=0
...
``` ```
(or wherever you decided to put the local `syncthing` binary)
This will initialize the `pacman` key-ring, populate it with the default signing With everything in place, I can now enable and start the Syncthing user service:
keys provided with Arch, and then refresh those keys. Without this step, when I
would try to install I would get errors About untrusted and corrupt packages.
### Install Syncthing
Install the package:
``` ```
sudo pacman -Syu syncthing systemctl --user enable syncthing.service
systemctl --user start syncthing.service
``` ```
Next, enable and start the daemon. I used a user service, since the `deck` user Since I don't have a physical keyboard plugged in, I modify my SSH command
should be the only user ever logging in. It can be set up as a server-wide slightly to forward the Syncthing web-UI from the Deck to my local machine:
service too; check the wiki. Here are the user service steps:
```
sudo systemctl --user --machine=deck@.host enable syncthing
sudo systemctl --user --machine=deck@.host start syncthing
```
A `sudo systemctl --user --machine=deck@.host status syncthing` should show
happy results.
### (Optional) Re-Enable SteamOS Protections
```
sudo steamos-readonly enable
```
### Configure Syncthing
Before returning to game mode, I add a few non-Steam applications to Steam, all
of which were installed using the Discover Store: Firefox, Minetest, and
Retroarch. I opted to return to Game Mode for the Syncthing configuration.
Regardless, the following steps are performed back on the Deck with the
on-screen keyboard (or a physical one attached to the device.) Technically, I
could leverage `ssh` to port-forward the Syncthing web-UI to my desktop.
``` ```
ssh -L 31337:deck-ip-goes-here:8384 deck@deck-ip-goes-here ssh -L 31337:deck-ip-goes-here:8384 deck@deck-ip-goes-here
``` ```
I did not, and suffered through the on-screen keyboard. Within a web browser on Now, on my local machine I can open one tab to `localhost:8384`, to show
the Deck get to the Syncthing web-UI by going to `localhost:8384`. Once there, I Syncthing on my local machine, and another tab to `localhost:31337` to show
added my desktop as a device, and shared several folders from my desktop to my Syncthing on my Deck. From here, I add my local machine as a device on my Deck,
Deck. Those details mostly center around Retroarch, a topic I hope to cover and begin sharing folders.
next.
## Closing Thoughts
I've been using this setup for about a week now. I've synced almost 20GB of
files, including configurations and saves for Retroarch. It works after
restarts, OS and client upgrades, and waking the device from sleep. It sits
quietly in the background, without having to start up applications. The biggest
problem is that it doesn't automatically update to the newest version of
Syncthing. It's also a bit involved to setup. To that end, I've written a tool
to help with setup: [Steam Deck Syncthing
Setup](https://gitlab.com/VagabondAzulien/steam-deck-syncthing). I'm still
finishing it up, but I intend to make use of it to keep my version of Syncthing
up-to-date. If you use it, let me know!