Setting Up TNFS on Ubuntu

The mini PC from Building a Home Server doesn't just serve this website and Samba shares — it's also where the public RetroLoft TNFS test server mentioned on the SideTNFS page actually runs. This article covers the other half of that machine's job: getting tnfsd, the open-source TNFS server, built, running, and reachable by ACSI2TNFS, SideTNFS and TheHulk.

Getting the source

The server is FujiNetWIFI/tnfsd, MIT-licensed. Pre-built binaries are on its Releases page, but building it yourself takes about thirty seconds and needs nothing beyond a standard toolchain:

sudo apt update
sudo apt install build-essential git
git clone https://github.com/FujiNetWIFI/tnfsd.git
cd tnfsd/src
make OS=LINUX

That produces a single tnfsd binary in the src directory. There's no make install target, so copy it where you want it to live yourself:

sudo cp tnfsd /usr/local/sbin/tnfsd

Trying it by hand first

Before wiring it into systemd, it's worth running it directly so you can see what it's doing. The whole command line is:

tnfsd [-p <port>] [-r] [-a] <root dir>
FlagWhat it does
-p <port>UDP port to listen on. Default is 16384, the standard TNFS port — the same one SideTNFS, ACSI2TNFS and TheHulk expect unless you tell them otherwise.
-rRead-only. Good for a drive you don't want client machines writing to, such as a shared library of disk images.
-a"Atari mode": presents binary files as ATR disk images, for the 8-bit FujiNet side of the TNFS world rather than the ST/GEMDRIVE side this site mostly deals with.
-vPrint the version and exit.

The directory to share is a plain positional argument, not a flag:

mkdir -p /srv/tnfs
tnfsd /srv/tnfs

It stays in the foreground and logs new connections to the console, so this is a good moment to point a drive at it from an Atari (see "Testing it" below) before moving on. Ctrl+C stops it. There's no built-in flag to daemonize — for that, systemd does the job.

Running it as a service

A dedicated user keeps the TNFS process from running with your own full account's permissions:

sudo groupadd --system tnfs
sudo useradd --system --gid tnfs --home-dir /srv/tnfs --shell /usr/sbin/nologin tnfs
sudo chown -R tnfs:tnfs /srv/tnfs

Then a systemd unit, based on the one in the tnfsd repository, at /etc/systemd/system/tnfsd.service:

[Unit]
Description=TNFS Server
After=network.target

[Service]
User=tnfs
Group=tnfs
ExecStart=/usr/local/sbin/tnfsd /srv/tnfs

# systemd's default soft limit is 1024; tnfsd needs far more.
LimitNOFILE=65536

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Add -r to the ExecStart line if this drive should be read-only — exactly what the public RetroLoft test server does. Then bring it up:

sudo systemctl daemon-reload
sudo systemctl enable --now tnfsd
sudo systemctl status tnfsd

Opening the firewall

TNFS is UDP-only, on port 16384 by default:

sudo ufw allow 16384/udp

Optional: reachable as a name, not just an IP

SideTNFS v1.2.0 added support for pointing a drive at a local network name, like myserver.local, via mDNS, instead of typing an IP address. Ubuntu Server doesn't advertise one of those by default — Ubuntu Desktop usually does, Server usually doesn't — so if you want that convenience, install an mDNS responder:

sudo apt install avahi-daemon

Once that's running, the box answers to <hostname>.local on the local network, and a SideTNFS drive can be pointed at that name instead of an address that might change.

Testing it

From any of this site's TNFS-speaking projects — ACSI2TNFS, SideTNFS, TheHulk — add a drive pointing at the server's address (or its .local name) on port 16384, the default, and it should mount straight away. If something's wrong, the client side shows a readable error rather than just hanging, which is usually enough to tell you whether it's a firewall, a wrong address, or the service not actually running.

A word on security

TNFS was designed for small, trusted networks, not the open internet: there's no login and no encryption. The same caution from the SideTNFS page applies here on the server side too — treat it as a LAN protocol, export only what you're comfortable sharing, and lean on -r for anything that doesn't need to be writable.

Between this and Samba Shares for Modern (and a Few Old) Machines, that's the whole reason this little mini PC exists: one box, quietly handing out drives to whatever's asking, whether that's a laptop over SMB or an Atari over TNFS.