Skip to content
Henryk Paluch edited this page Sep 29, 2024 · 6 revisions

Plan 9

"Plan 9" is unique system (from UNIX creators). However it may be hard to grasp first.

Main characteristics:

  • everything is file (including env, sockets)
  • because everything is file there are possible many neat tricks:
    • irc or http client and http server is written in shell (!)
    • even terminal windows uses files for operations, for example /dev/text is completed buffer of your terminal window so you can for example grep it
    • /dev/snarf is clipboard - you can read it or modify it
    • similarly works mouse and keyboard
  • fully UTF-8 compatible (Plan9 authors invented UTF-8)
  • transparently distributed system - remote resources (CPU, files, ...) can be just mounted on local machine and accessed as local files
  • full namespace support - each process has its own view of filesystem

NOTE: There are several distributions of Plan9 - I tested 9front flavour.

Quick install:

Installed system under Proxmox (disk: VirtIO BLK, network: VirtIO NET).

  • Do NOT use lvm-thin - copying will take forever. I suspect that there is significant write amplification
  • I use qcow2 on ext4 (because I will need snapshots, otherwise I would use raw), cache: unsafe
  • 1 CPU, 2 GB RAM

There is really good installation guide - and mostly you just press enter when asked for something:

Both installation (and after installation) runs GUI called rio(1) very good intro is at:

How to create New Terminal window:

  • Right click and Hold on empty background
  • move mouse to New menu item and release Right button
  • when Cross (+) appears again Right-click (important) and hold - draw new Window
  • move mouse to draw rectangle of new window. When done - release button and Terminal will start in that rectangle area.

You can use man ITEM for most commands...

System info - run sysinfo script. Most commands are in /rc/bin (try ls /rc/bin).

How to shutdown:

fshalt

Basic terminal tips

Terminal window is called rio(1) and it works like full screen editor.

I strongly recommended watching at least these YouTube Videos for introduction:

NOTE: Autoscroll is disabled by default. You have two choices:

  1. press ENTER to show next page
  2. click-and-hold Middle button and select scroll and release Middle button - this will enable auto-scroll

Selecting text - again 2 choices: a) double-click on text to select word or text inside quotes b) left-click and hold left button - move mouse to select text - but see below for details.

Copy/Cut & Paste using "chords":

  1. left-click and hold left button - select text - still hold left-button
  2. now also press middle button (keep holding left-button) - it will Cut text 2.b) if you want to Copy instead of cut - still hold left and middle button. Additionally press Right button - text will be pasted back - same effect as Copy.
  3. release all buttons (I'm rather releasing from Right to Left)
  4. position mouse to place where you want paste text
  5. left-click, hold and right-click - text will be pasted
  6. release all buttons

Copy/Cut & Paste using menu:

  1. select text with any method - release left-button when selection is done
  2. Middle click and hold to show menu. Select Snarf (Copy) or Cut and release mouse button
  3. Position your mouse to place where you want paste text
  4. Middle click and hold to show menu. Select Paste and release mouse button.

Other menu items:

  • plumbing -> will open selected file in application (typicaly in page viewer)
  • send -> will run command in clipboard

Random tips

  • Use Del key instead of Ctrl-C to stop program
  • To find assigned IP address: cat /net/ndb or netstat -i
  • To see routing tables cat /net/iproute
  • most scripts are under /rc/bin
  • default shell (equivalent of /bin/sh under Unix) is named rc - try man rc

Generating graphical manual pages (from Video tutorial):

  • example: man -t rio | page -w

Building docs

Try:

cd /sys/doc
mk

Should generate lot of *.ps files in /sys/doc

WARNING! OpenSUSE Viewer (gv) is somehow broken (strange rendering of fonts). However you may use ps2df file.ps (included with ghostscript package) and then evince file.pdf.

Serving filesystem from Plan9 server to Linux client

After lot of digging found working example on: https://mitjafelicijan.com/mount-plan9-over-network.html

On Plan9 I run:

ip/ipconfig # enables network
aux/listen1 -tv tcp!*!9999 /bin/exportfs -r /sys/src

On Linux client:

mount -r -t 9p -o version=9p2000,port=9999,trans=tcp IP_ADDRESS_OF_PLAN9_SERVER /mnt/9p
# should see contents of /sys/src
ls -l /mnt/9p

Connecting remotely

Default plan installation is so called "standalone terminal" - single user. Although it is possible to run "manually" some services as single user it is not standard way.

There are at least 2 guides:

Or:

Trying:

  • http://wiki.9front.org/cpu-setup
  • verify that we are now in terminal (single user + GUI) mode:
    echo $service
    
    terminal
  • note also sysname:
    echo $sysname
    
    Server1
  • create new hostowner user kvik:
    con -C /srv/cwfs.cmd
    newuser kvik
    newuser sys +kvik
    newuser adm +kvik
    newuser upas +kvik
  • to exit con you have to:
    • press Ctrl-\ (documented)
    • press ENTER to get >>> prompt (undocumented!)
    • press q followed by ENTER to quit
  • now reboot with fshalt -r
  • on boot remember to enter new hostowner name kvik (instead of glenda)
  • there will be error message regarding ./lib/profile we have to fix it with:
    /sys/lib/newuser
  • it will boot empty rio
  • to create terminal - click and hold right-button, select New, release button
  • and draw window.
  • verify that ./lib/profile now exists with:
    ls -l $home/lib/profile
  • again reboot with fshalt -r
  • again enter username kvik
  • now empty rio should start without errors.

TODO: verify

To study:

On your client you have to build drawterm

TODO:

Probably this guide is most close: http://wiki.9front.org/cpu-setup

Problems:

  • there was nothing listening on port 5356 (secstore) I tried to run on plan9:
    auth/secstored
  • I then run on client (Linux) machine:
    drawterm -a IP_OF_PLAN9 -c IP_OF_PLAN9 -u genda -d -d -d
  • but on terminal there was error:
    cpu: negotiating authentication method: IP_OF_PLAN9:
    
    goodbye
    
  • on plan9 server terminal there was error:
    incoming call for tcp!*!ncpu from CLIENT_IP in /net/tcp/4
    aux/listen1: exec directory entry not found: /bin/cpu
    

It seems that I have to edit /n/9fat/plan9.ini and add service=cpu there... Following FAQ I have to mount with 9fs script - in case of VirtIO SCSI under Proxmox:

WARNING! Do not do that below - it will cause boot failure!!!

9fs 9fat /dev/sd00/9fat
# Do NOT use quotes "" - it will cause error
echo 'service=cpu' >> /n/9fat/plan9.ini
cat /n/9fat/plan9.ini

Resources

Interesting stories:

Clone this wiki locally