_ _ _ _ _ __ (_)| |__ __ _ _ _ _ _ (_) ___ | |_ ___ (_)_ _ / _| ___ | || '_ \/ _` | ' \| ' \| |/ -_)| _|/ _ \ _ | | ' \| _|/ _ \ |_||_.__/\__,_|_||_|_||_|_|\___| \__|\___/(_)|_|_||_|_| \___/
For many years I wanted to try Plan 9, a pioneering operating system that was supposed to be a compendium of ideas to shape a new OS and a evolution from UNIX. This operating system is also classified as "dark" operating system on this times and to me, for that reason, I think it is worth to taking a look.
After several days using Plan 9, I just can say that I still don't understand a ton of things and that the traditional (UNIX) concepts differ a lot from the Plan 9 concepts.
I still have a lot to learn, so in this project I will write some notes, tricks and things that I find when I work with Plan 9.
Install qemu through your favorite package manager. Note that qemu configuration may differ from your system. In my case, I'm using Arch Linux, so it's a good idea to follow your favorite distribution's documentation.
Download the ISO:
Run QEMU with the following commands:
qemu-img create -f qcow2 9front 8G qemu-system-x86_64 -hda $image_name -cdrom plan9.iso -boot d -vga std -m 768
The command qemu-img prepares and creates a local QEMU image with 8G of size.
The command qemu-system-XXX launchs a virtual machine with the new image and boots from the ISO
Follow the steps in the installation guide:
Installation time is more or less 5-10 min in my machine.
Boot QEMU without the installation media with the following command:
qemu-system-x86_64 -hda 9front.qcow2.img -boot d -vga std -m 768
Boot from virtual CDROM/ISO:
qemu-system-x86_64 -cpu host -smp $(nproc) -enable-kvm -m 2048 \ -net nic,model=virtio,macaddr=52:54:00:00:EE:03 -net user \ -device virtio-scsi-pci,id=scsi \ -drive if=none,id=vd0,file=9front.qcow2.img \ -device scsi-hd,drive=vd0 \ -drive if=none,id=vd1,file=9front.iso \ -device scsi-cd,drive=vd1,bootindex=0 \ -vga std \ -k es
Boot from virtual HDD:
qemu-system-x86_64 -cpu host -smp $(nproc) -enable-kvm -m 4096 \ -net nic,model=virtio,macaddr=52:54:00:00:EE:03 -net user\ ,hostfwd=tcp::5640-:564\ ,hostfwd=tcp::17019-:17019\ ,hostfwd=tcp::5670-:567\ ,hostfwd=tcp::17020-:17020 \ -device virtio-scsi-pci,id=scsi \ -drive if=none,id=vd0,file=9front.qcow2.img \ -device scsi-hd,drive=vd0 \ -vga std \ -k es
Maybe outdated but still useful info:
NOTE: ports 5640 and 17019 needed for a drawterm connection.
Thanks to Richard Miller for the port to the Raspberry Pi.
Write the ISO to the SD card:
sudo dd bs=4M if=plan9.iso of=/dev/sdb conv=fsync oflag=direct status=progress
Then eject the device and plug the SD Card to the card slot of your Raspberry Pi.
NOTE: I found that you can use raspbi3 with 2Gb of RAM and raspi4 with 4Gb and it's more than enough use it with 2-4 Gb of RAM for a server.
Once the plan9 is booted you may need to change the keyboard layout and the monitor resolution.
Obtain a list of vesa bios modes:
% @{rfork n; aux/realemu; aux/vga -p}
Change the resolution (configure one of the valid modes):
% @{rfork n; aux/realemu; aux/vga -m vesa -l 1920x1080x16}
% cat /sys/lib/kbmap/es > /dev/kbmap
You have to get in to the boot stuff in the 9fat partition:
% 9fs 9fat % cd /n/9fat % acme plan9.ini
TO BE DONE
Left Button: Select
Middle Button: Menu (cus/paste/snarf/plumb/look/send/noscroll)
Right Button: Window Menu (new/resize/move/delete/hide)
In a term:
TO BE DONE
List files (also works with ls):
% lc -lsF
"" -> last command cat >/dev/text -> clear the console
In this link you can get a very useful list with unix to plan9 command translation:
UNIX to Plan 9 command translation
replica/pull
cd /tmp hget https://orib.dev/git/git9/HEAD/snap.tar.gz | tar xvz cd git9 mk all mk install
Note that 9front comes with git preinstalled.
mkdir -p /sys/lib/go/ ramfs cd /tmp hget http://9legacy.org/download/go/go1.18.3-plan9-amd64-bootstrap.tbz | bunzip2 -c | tar x dircp go1.18.3-plan9-amd64-bootstrap /sys/lib/go/
castor9 is a plan 9 gemini client.
ramfs cd /tmp git/clone https://git.sr.ht/~julienxx/castor9 cd castor9 mk install
netsurf is a www browser.
% git/clone git://github.com/netsurf-plan9/nsport % cd nsport % fetch clone http
To build go to the directory nsport and run mk:
% cd nsport % mk % mk install
To update your copy of the sources:
% cd nsport % fetch pull
mkdir -p /dist/replica/client 9fs sources /n/sources/contrib/fgb/root/rc/bin/contrib/install -f fgb/contrib
cd / rc sys/lib/rootstub cd /sys/src mk nuke mk libs #(makes and installs this arch's libs) objtype=amd64 mk all objtype=amd64 mk install cd 9/pc64 mk install 9fs 9fat cp /amd64/9pc64 /n/9fat
Building the system from source
Creating a simple hello world:
% touch hello.c && acme hello.c
#include <u.h> #include <libc.h> void main(void) { print("Hello World from Plan 9!\n"); exits(0); }
Create a mkfile:
% touch mkfile && acme mkfile
</$objtype/mkfile BIN=/$objtype/bin TARG=hello OFILES=\ hello.$O\ HFILES=\ </sys/src/cmd/mkone
Run mk and execute the program:
% mk 6c -FTVw hello.c 6l -o 6.out hello.6 % 6.out
Plan 9 programming in C (great resource)
You must use the drawterm fork from 9front in order to connect to Plan 9 (9front only) console from your favorite OS:
drawterm/drawterm -h 'tcp!127.0.0.1!17019' -u glenda -a 'tcp!127.0.0.1!5640'
Also text-mode only:
drawterm/drawterm -G -h 'tcp!127.0.0.1!17019' -u glenda -a 'tcp!127.0.0.1!5640'
NOTE that if you are using another Plan 9 distro you must use another version of drawterm, which is different that the 9front (authentication mechanism p9sk1 is changed/improved in 9front, 9legacy uses original auth AFAIK)
9fs protocol permits to have your local filesystem avaiable to access on your drawterm session. Your Linux files can be accessed from your drawterm session, in an isolated manner, so that the files are only visible on said drawterm session not for another session, not for another user.
Edit the file $home/lib/profile , right before starting webfs, add the following:
bind -a /mnt/term/home /usr >[2]/dev/null
This will bind all files in /mnt/term/home/ to /usr. So all files in /usr (e.g. your 9front home folder /usr/glenda) will be kept, plus all files in /mnt/term/home/ will also be seen under /usr.
So for example, if your user folder on Linux is at /home/iban, it will now be available on 9front (through a drawterm session only) at /usr/iban.
To add wallpaper support to rio, you want to edit the rio file /sys/src/cmd/rio/data.c, within the iconinit function, you can draw a graphic to the background image by adding the following code. In this example, the graphic is stored at the location defined with open():
int fd; Image *bimg = nil; fd = open("/usr/glenda/lib/wallpaper", OREAD); if(fd >= 0){ bimg = readimage(display, fd, 0); close(fd); } if(bimg){ background = allocimage(display, Rect(0, 0, Dx(bimg->r), Dy(bimg->r)), RGB24, 1, 0x000000FF); draw(background, background->r, bimg, 0, bimg->r.min); } else fprint(2, "iconinit: %r\n");
The file format should be in Plan 9's native raw file format, to convert any jpg into this format, use:
jpg -9t wallpaper.jpg > /usr/glenda/lib/wallpaper
NOTE this information is NOT MINE, is ORIGINAL from Devine Lu Linvega, MANY THANKS to this user.
Modify the file in /rc/bin/rc-httpd/select-handler and change "example.com" with your domain.
#!/bin/rc PATH_INFO=$location switch($SERVER_NAME) { case example.com FS_ROOT=/sys/www/$SERVER_NAME exec static-or-index case * error 503 }
Logs are in /sys/log/www :
% tail /sys/log/www
% cat /dev/window | topng > window.png # Capture the current window % cat /dev/screen | topng > screen.png # Capture entire screen
TO BE DONE
jpg -c avatar.jpg | resample -x 100 | crop -b 255 255 255 -i -30 | mug > myface.1 jpg -c avatar.jpg | iconv -c m8 | resample -x 48 -y 48 > myface.1
TO BE DONE
Configuring Gmail (thanks Lucas S. Vieira)
Sources of information for plan9 and 9front:
Configuring a Standalone CPU Server
UNIX to Plan 9 command translation
The Plan 9 Namespace for Dummies
Setting up 9front on a Raspberry Pi
Devine Lu Linvega on Plan 9 (awesome site)
various tools from a 9front developer
Last Updated: 10/JUL/2022