The purpose of this guide is to help someone new to the Plan9 operating system install, configure, and explore the system.
Plan9 from Bell Labs is an operating system that was developed in the late 1980s by the same people who developed UNIX. It was an effort to explore operating systems design, and pushed the boundaries of using the concept of a file system interface for nearly everything. Plan9 is concise, simple, and well documented.
My best advice for learning plan9 (and its modern fork 9front) is to read the documentation. It is extensive and very informative. Usually, a combination of the man pages and the FQA will have answers to almost all of your questions. This guide is a distillation of some of the wisdom from those pages, as well as some hints to get you to look in the right direction.
This guide will cover installing 9front, a fork of Plan9 that has been kept continually updated and is compatible with some modern hardware. I will cover installation on a virtual machine, but the process is very similar for installation on real hardware as well. These instructions closely follow the 9front FQA, however, I have made some slight changes that solved some issues I ran into.
You can download 9front from here: http://www.9front.org/releases/. I recommend the iso version which will allow you to install it on a virtual machine from scratch. Unless you are running a Raspberry Pi, you will most likely want the "amd64.iso" version.
The 9front FQA encourages the use of qemu over VirtualBox, and I would agree. You never know when an update of VirtualBox might break your installation. Therefore, make sure you have qemu installed on your machine. You can get it from here: https://www.qemu.org/. If you're running linux, use your favorite package manager to install qemu.
Create a disk image: qemu-img create -f qcow2 9front.qcow2.img 30G
.
To boot the image, use the following command:
qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
-net nic,model=virtio,macaddr=00:20:91:37:33:77 -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
qemu-system-x86_64 -enable-kvm -cpu host -m 2048M \
-audiodev id=alsa,driver=alsa \
-device AC97,audiodev=alsa \
-net nic,model=virtio,macaddr=00:20:91:37:33:77 -net user \
-device virtio-scsi-pci,id=scsi \
-drive if=none,id=vd0,file=9front.qcow2.img \
-device scsi-hd,drive=vd0
9front has a section covering installation in the FQA. I would recommend following that guide with the following changes.
The recommended vga size of 1024x768x16
is likely too small for your monitor.
If you have a 1440p monitor, I would recommend 1920x1080x32
.
If you have a 4k monitor, then I would recommend 2560x1440x32
.
For the mouseport I would recommend ps2intellimouse
.
That will allow 9front to recognize the scroll wheel, which is very convenient for scrolling.
Even though it says it is experimental, I recommend using the hjfs
filesystem.
I recommend reading the all the instructions in the FQA before installation so that you are familiar with them. Outside of the few differences I suggested, all the rest of the instructions should be fine.
Plan9 was designed to make heavy use of a 3-button mouse, therefore I recommend using such a mouse when experimenting with Plan9.
Many programs in Plan9/9front use context menus.
Holding down the right mouse button on the grey desktop background will bring up a context menu with the options of New, Resize, Move, Delete, Hide, and Exit
.
Selecting New
will change the mouse cursor to a plus sign.
If you hold down the right mouse button again you can sweep out a new window.
Notice that windows have a teal border. If you hover over the border you will see that the mouse cursor changes. You can left-click drag the borders to resize the window.
Right-clicking on the border allows you to move a window.
To close a window press and hold down the right mouse button on the grey desktop and release it on the Delete
option.
The mouse should change to a crosshairs.
Right-click on the window you wish to close.
Some programs will have a context menu when holding down the middle mouse button over that window. Try doing this on a terminal window and note the options.
If you're using a relatively newer monitor with high resolution, you've probably noticed the font is a bit small. This page has resources for some great fonts. I use iosevka, but you may prefer another.
Here is an example of installing a new font.
cd /lib/font/bit
hget https://ftrv.se/_/plan9_fonts/iosevka.18+20+24+32.tar.gz | tar xz
Iosevka is now installed. All that is left is to set the font of the system, which you can do like so:
cd $home
sam lib/profile
You can now edit your profile file to change the font. I recommend commenting out the previous font declaration with '#' and creating a new line with the new font declaration. If you are not familiar with Sam, take a look at the 5 Using Sam section.
Once you've done this you'll need to restart Plan9 for it to take effect.
You can restart Plan9 with the reboot
command.
There are 2 major text editors in Plan9, Sam and Acme.
Acme is a a very powerful editor, and could be considered an IDE (Integrated Development Environment).
Sam by contrast, is a fairly simple program used mostly for text editing.
You can learn about Acme by entering man acme
into the terminal.
Similarly, you can learn about Sam by typing man sam
into the terminal.
You can also find information on the web about Acme here, and information about Sam here.
I will also cover some basic usage of Sam here to help you survive using Sam as a newbie.
If you've typed in a command, such as sam hello.txt
, and the file already exists, you may be wondering why you don't see the file.
Acme appears empty.
If you hold down the right mouse button in the bottom white area of Sam you will see a context menu with the file you opened.
Hover over the file name and release the right mouse button and the cursor will change to a box.
Right-click in the white area and the file will open in the space.
You can also switch between files using this context menu.
Right-hold on the file area to bring up the context menu, and release off the 'write' selection. The mouse cursor will change to crosshairs. Right-click on the file and it will be written to disk (saved).
When you are done using Sam, you can close the program by clicking on the blue area at the top of the window, typing q
and then pressing the 'Enter' key.
This will close Sam and bring you back to the terminal.
If you've enabled ps2intellimouse
on installation then you will be able to use the scroll wheel to scroll through the document.
However, keep in mind the the amount you scroll depends on the y position of your mouse.
If your mouse is near the top of the file window, then it will scroll only a few lines at a time.
The closer your mouse is to the bottom of the window the more lines it will scroll at once.
This is also true of the scrollbar. You do not drag it around like other scrollbars. Instead, it responds to clicks. Left-clicking on the scrollbar will scroll up, while right-clicking will scroll down. The further down on the scroll bar you click, the more lines Sam will scroll at once. Keep in mind, this kind of behavior is also found in Acme and rc, the shell.
Sam has some wonderful and powerful features, including structural regular expressions. The more you learn, the more productive you will become in both Sam and Plan9. There are some quirks that you'll need to get used to. For example, Sam doesn't have the typical Ctrl+c for copy and Ctrl+v for paste. Instead Sam wants you to use the mouse and the context menu. Also, if you are familiar with vim, the top blue part of Sam is compatible with some vim-like commands such as 'w' for write and 'q' for quit. This traces back to its ancestor 'ed'. Read the man pages or the web pages for more info.
Rc is the shell for Plan9. While similar to bash, there are some differences such as quotations, which you can learn about in the documentation. I won't go into many details about rc here, but list some of the things you should know.
When you create a new window, it automatically starts with rc.
Keep in mind that you can find detailed info on rc by typing man rc
as well as by reading this paper that has excellent exampls here.
You might be used to hitting the 'tab' key in order to complete a filename.
Instead use Ctrl+f
to complete a filename in rc.
Use Ctrl+b
to go from anywhere back to the last line in the command prompt.
Unlike other shells, rc allows you to edit your shell history as if it was a text file. If you mis-typed a command, you can go back and edit it and then run it again.
In order to re-run a command, left-drag to highlight the command. Then middle-press the highlighted command to bring up a context menuand selectsend
.
This will execute the command again and its output will be at the bottom of the shell.
The man pages are the primary documentation for Plan9.
You can read details about the man program by running the man man
command.
If you run lookman <word>
, you will get a list of all man pages containing 'word'.
As an example, lookman compiler
will return a list of all man pages containing the word 'compiler'.
Reboot Plan9 with the reboot
command.
Shutdown Plan9 with the fshalt
command.
There are a number of languages available for Plan9.
However, by far the most popular lanugage is Plan9 C, written by Ken Thompson.
It is very similar to C99, and you can find information about the C compilers by using the man 2c
command, as well as reading How to Use the Plan9 C Compiler by Rob Pike.
I would also recommend the Plan9 Go compiler which can be found by expanding the 'Other Ports' section here.
That's it. Have fun!