9front in your pocket: drawterm on Android

Some of my favorite corners of the internet are short notes on personal sites, the kind that skip the life story and the newsletter popup and just say "here's how I did this weird thing" with a few commands.

One of those is 9front and Android, by Sigrid, on ftrv.se. It explains how to build drawterm on an Android phone and connect to a 9front machine without ever touching a PC. It's a tiny post and it sent me down a very happy rabbit hole. Thank you, Sigrid, for the inspiration. This post is my expanded version of it, with some context for people who have never touched Plan 9, and a few extra paths you can take.

9front and Android

ftrv.se

First, what are we even talking about?

Glenda, the Plan 9 bunny mascot, floating in a space suit

Plan 9 from Bell Labs is the operating system the people who made Unix built next. Ken Thompson, Rob Pike, Dave Presotto and Phil Winterbottom led it at Bell Labs, and the first edition went out to universities in 1992. The big idea was to take "everything is a file" seriously, all the way across the network. Your mouse, your screen, a remote machine's processes, all of it shows up as files, served over one small protocol called 9P. Each program can have its own view of that file tree, its own namespace. It never took over the world, but its ideas leaked everywhere: UTF-8 was born there, and you can see its influence in /proc on Linux and in the way modern systems mount remote things.

9front is a fork of Plan 9 started around 2011 by a community that kept developing it after Bell Labs stopped. It has modern hardware support, wifi, its own installer, and a sense of humor. Its latest release is literally called "DO NOT INSTALL".

drawterm is the piece that matters today. In Plan 9 you don't really "log in" to a server the way you do with SSH. You run your terminal on one machine and your computing happens on a cpu server, which borrows your keyboard, mouse and screen through 9P. drawterm is a small program that lets a non-Plan 9 machine play the role of that terminal. You run it on Linux, macOS, Windows, or, as we'll see, a phone, and suddenly you're sitting in front of a 9front system.

There's a lovely side effect: while you're connected, the files of the machine running drawterm appear on the 9front side under `/mnt/term`. Your phone's files, inside Plan 9.

What you need

F-Droid

The Termux logo: a white terminal prompt symbol on a black square

Building drawterm on the phone

Open Termux and run these, one block at a time. These are the same steps from Sigrid's post, which also ended up in the 9front wiki:

9front wiki

pkg install unstable-repo && apt upgrade

pkg install x11-repo build-essential libx11 libxt xorgproto git binutils

git clone git://git.9front.org/plan9front/drawterm

cd drawterm

make CONF=unix -j4

What each part does:

When it finishes, you have a working `./drawterm` in that folder.

Connecting without graphics

The simplest way to use it is text only. The `-G` flag skips graphics, and you get an rc shell on the 9front machine right inside Termux:

./drawterm -G -h yourcpuserver -a yourauthserver -u yourname

`-h` is the cpu server, `-a` is the authentication server (often the same machine), and `-u` is your user. The original post wonders if maybe `drawterm -G` is all one needs, and for a lot of quick tasks on a phone, it might be.

Running rio, the full graphical desktop

A Plan 9 rio desktop with several overlapping terminal windows on a gray background

If you want the real thing, rio, Plan 9's window system, you need an X server on the phone. Sigrid used XServer XSDL.

First, install XServer XSDL and open it. Go to "Configuration", then "Downloads", and check "additional fonts". Look around the mouse emulation and video settings while you're there. One warning from the original post, in capital letters: don't enable 24-bit display.

Then leave the settings. When the black screen appears, tap once quickly, pick your resolution and zoom, and press OK. A blue screen means the X server is running. Note the display number, usually 0.

Back in Termux, start a tiny window manager and drawterm:

export DISPLAY=:0

pkg install xorg-twm

twm &

./drawterm -h yourcpuserver -a yourauthserver -u yourname

Finally, switch to XServer XSDL, place the window, and you're in rio.

If XServer XSDL gives you trouble, the Termux project now has its own X server app, Termux:X11, which is worth a try with the same idea: start the X server, set `DISPLAY`, run twm and drawterm.

Your phone's files, from 9front

While drawterm is connected, the phone shows up on the 9front side under `/mnt/term`. The Termux home folder is at:

/mnt/term/root/data/data/com.termux/files/home

One small tip: go straight to that path instead of trying to list your way through the folders above it, since Android doesn't let you see most of them.

Bonus: serve your phone's storage over 9P

Sigrid's post ends with a bonus. With a tiny 9P server called 9pro and `socat`, you can expose your phone's shared storage to 9front over the network, without drawterm at all. In Termux:

pkg install git socat

git clone https://git.sr.ht/~ft/9pro

cd 9pro

./build.sh

termux-setup-storage

ifconfig | grep 'inet '

socat TCP4-LISTEN:5640 EXEC:"./9pex -e $HOME/storage"

`termux-setup-storage` asks Android for permission to your files (tap Allow). The `ifconfig` line shows your phone's IP address. Then, on the 9front machine:

9fs tcp!phoneIPaddress!5640 /n/phone

ls /n/phone

When the post was written, this worked read-only and without encryption, so only do it on a network you trust. If you need read and write access, `u9fs` is an older, bigger alternative that also serves Unix files over 9P.

The easy way: an app

If compiling things on your phone isn't your idea of fun, there's also a Drawterm app on F-Droid. It supports original Plan 9 and 9front, all three mouse buttons, a working `/mnt/term`, connection profiles, and even camera and notification support. It hasn't been updated since 2022, so your mileage may vary, but it's the fastest way to see rio on a phone.

Drawterm app on F-Droid

Caveats

A Plan 9 terminal in your pocket

There's something delightful about carrying a Plan 9 terminal in your pocket, a system designed by the people who made Unix to fix what they thought Unix got wrong, running on a phone made decades later. It's useless in the best way, and you learn a lot about how systems talk to each other along the way.

Thank you again, Sigrid. Go read the original, and the rest of ftrv.se while you're there.

the original

ftrv.se

Gemlog

Home

Proxied content from gemini://pablomurad.com/gemlog/9front-in-your-pocket-drawterm-android.gmi

Gemini request details:

Original URL
gemini://pablomurad.com/gemlog/9front-in-your-pocket-drawterm-android.gmi
Status code
Success
Meta
text/gemini;lang=en
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.