Changing your monitor size

If you want to change your monitor resolution on your plan9 installation as you selected the default value initially, you will have to edit your plan9.ini file. However when I first searched for its location, I couldn’t find it anywhere? Its supposed to be in /n/9fat/plan9.ini – but on initial inspection it wasn’t there. So of course its worth trying to create it using 9fat.

Make sure you type in:

9fat:

Where the colon will give correct results and just plain 9fat will give you a /bin/9fat does not exist error. Then go into /n/9fat/ and ls for the directory listing:

Its possible you will get:

term% ls

4e

9LOAD

9pcf

plan9.ini

To change your monitor resolution within the virtual box, you have to edit the last line of your plan9.ini file with your monitor type: (acme plan9.ini will do it)

http://plan9.bell-labs.com/wiki/plan9/setting_the_right_monitor_size/index.html

Do this by running acme (or if you are a pro with sam – use that to replace vgasize=1280x1024x16 with your monitor size.

Now its possible to have a screen like this to run the abaco web browser with.

 

 

Advertisements

Installing contributed packages on plan9

Essentially we want to download software and install packages on the plan9 system that we have. One way to do this is to use replica/pull from the contribution source tree located at http://plan9.bell-labs.com/sources/contrib/. These are all of the packages available to users that aren’t part of the official plan9 installation. To make installing software that isn’t in the original plan 9 version we will install a package management GUI to assit in installing packages such as python or a game. Below is the gui version of the package management system.

A package management gui

If you browse the sources via your browser (http://plan9.bell-labs.com/sources/contrib/) you can see all of the users that have contributed software to the plan 9 system.

Contribution index for plan9

Where all of the directories are users that have written software for the system. Essentially you would like to mount this source tree onto your system so that you can install some software.

Open a terminal by right clicking in an empty space and selecting new from the green menu.

Hold down the right mouse button and drag that across the screen to a large enough window size for your gui. Run the command:

term% 9fs sources

A copy of the contributions index is now mounted at /n/sources/contrib in your system. Now that has been accomplished you can browse the sources on your local system by ‘cd’ ing into the directories that are part of the sources, and using  ‘ls’ to get a print out of the source list.

As the package management system contrib is NOT part of the official installation, we will have to install it from the contribution index. We can then download and run the package management gui. So first of all, run all as one command.

term% /n/sources/contrib/fgb/root/rc/bin/contrib/install fgb/contrib

You will see some output, and contrib will have been installed. Now to start the GUI you must run:

term% contrib/gui

Installing Python on plan 9

Now that we have the gui open and we are connected to the internet, we can start downloading some packages. The first package that we might like to get is a python port. The source for this port can be seen in the user n/source/contrib/bichued directory on our local system or at the source tree at the plan9 site( http://plan9.bell-labs.com/sources/contrib/bichued/ ). There is a lot of source code and mostly we don’t need to look at that now, we just want to install the python package, and in this case python is reliant on several other packages that have been ported. You will notice that in the gui there are four buttons in the main portion of the window and one of them is labeled Depends. If you click on that you will notice that it brings up several dependencies for the package selected on the left. In our case we want to install python and its dependencies so we locate Python in the left hand column of  Packages and click on Depends.

You will notice that it depends on three other packages! This current gui installer (and contrib as well) don’t have a system to download the dependencies automatically so we have to install them ourselves by tracking the packages down on the left and installing them and their dependencies.

First of all we will want to install openssh and its dependency openssl.

Locate openssl (openssh ‘s dependancy) on the left hand column by scrolling with the mouse. Once openssl has been located, you can check that it doesn’t have any dependencies by clicking “depends” again. It will give a message telling you that it is fetching some information about the package and then nothing will show up in GUI window.

Then click the bottom left button “install”. That will start the installation and begin running contrib/install on the package. Note that all this can be done in the terminal by using the syntax contrib/install user/package.

Now openssl has been installed we can locate openssh and begin installing that. Follow the same procedure to get all the dependencies for python. These are listed below:

  1. z
  2. bz2
  3. openssh

And once they are fully installed we can select python from the left hand side of the menu and click install. The full installation takes some time, so you might have to be patient at this point before the entire package is installed.

 

Updating your system:

While waiting for python to install fully, we might want to also update the system. Repeat the procedure to create a new window with a terminal. Run,

term% pull

That will get the latest packages for the official release of plan 9 – that as well might take some time, so for now you can probably hide those window and wait while everything updates.

Hello World in Sam (or Acme)

First of all we have to create a file to work with, so create a new window by right clicking the mouse button and selecting new from the menu. Hold down the right mouse button and drag it across the screen to the size you want your new window (again remember to middle-mouse button click and select scrolling from the green menu – that way the terminal will scroll with your text). You will get the term% prompt and it is here that you want to create the new hello world file. So type in touch helloworld.c.

To check that it exists, you can use ls to see if it was created: Your directory might look similar to what is below.

term%
bin
helloworld.c
readme.acme
readme.reo
sam.save
lib

So lets edit the hello world file in Sam. Start the editor by typing in sam -d filename (the -d option disables mouse editing – and that is the option we want).

sam -d helloworld.c

And lets add some lines to the dot.

a
#include <u.h>
#include <libc.h>
#include <stdio.h>
void main(void){
print("Hello World!\n");
exits(0);
}
.

Now that those lines are in our dot we can check that they are all there OK by printing using ‘p’ and hitting enter. You should get the lines of code that we entered that looks something like this:

#include <u.h>
#include <libc.h>
#include <stdio.h>
void main(void){
print("Hello World!\n");
exits(0);
}

Remember that you can undo what you entered by typing in ‘u’ if you have made a mistake or starting again with ‘c’ to overwrite what is in dot – and if everything went in ok then we can write to our helloworld.c file.

w helloworld.c

And hopefully you will get a status message of what happened – in my case it was:

helloworld.c: #104.

Okay! Now we can compile and run the code that we created. Close the window you were using and check the contents of the helloworld.c file that you created by using ‘cat’ helloworld.c.

term% cat helloworld.c

Now its time to compile it with the Intel compiler and link the code. The Intel compiler is run with the command 8c, and the linker 8l. Other compilers are listed below and you are welcome to use those to generate the object file and the binary file.

      1. term% 8c hellworld.c
      2. term% 8l -o helloworld helloworld.8 
      3. term% helloworld
      4. Hello World!
      5. term%

If you struggle in writing this in Sam, there is an easier option that makes editing files simpler, and that is the acme editor. To run and edit a new file on acme (lets say that its helloworld.c again):
term% acme helloworld.c
Will give you a new acme window where you can edit and write text. When you are finished with that, you can hover the mouse over the “PUT” selection and that will save the file. Then just highlight the “EXIT” selection and middle mouse button click to exit acme. Then run the compiler and the linker against helloworld.c.
Man pages for the C compilers available on plan 9 can be located at http://plan9.bell-labs.com/sys/doc/comp.html and http://plan9.bell-labs.com/sys/doc/compiler.html .
And for Sam there is a reference card that is quite good located here http://plan9.bell-labs.com/sources/contrib/steve/doc/sam-refcard.pdf

Using the Sam editor.

Start the Sam text editor by creating a new window in plan 9.

  • Hold down right click on a blank part of the screen and select ‘new’ from the green menu, then right-click and drag the mouse to create a blank window.

You should see term% running in the new window that you created. You want to enable scrolling so that the window will follow the text that you are going to type in, so click the middle mouse-button click and select ‘Scroll’ from the menu. This way the window should scroll as you type in more text.

To start the editor you must type in sam -d. The d option is to disable the mouse to make input only from the keyboard. Once you have done that the editor should be running and the output should look  similar to what is written below.

term% sam -d
-. 

It has begun running and you are ready to enter some text. Adding text is very simple and is most easily done by telling sam that you are going to add some text at the end of the current index ( using the ‘a’ option ) and then typing the text.

a  

Hello World! This is my first text in the sam editor

.

Here the ‘a’ tells sam to add the text before the period, and the dot ‘.’ specifies the end of the selection of our text. These indexes are used to tell sam where to put the text or the command that you are running. Regular expressions, overwriting and copying text from one index to another can be part of the command portion of the statement. To simply print what we have so far you can just enter.

p

And hit enter:

And Sam will print out.

Hello World! This is my first text in the sam editor

To print the first line of the file, type:

1p

Hello World! This is my first text in the sam editor

Or if you want to print everything in a longer file you can specify the start index 0, to the last null line $, and then the command print (‘p’):

0,$p

Hello World! This is my first text in the sam editor

Here the 0,$p command is telling the editor to start at the first line and go to the last line and print. This is a type of addressing. You can run 1,2p or 1,15p or 3,6p to print the selection of lines in the range you are looking for. Occasionally you might accidentally get the range wrong and get an error like:

?address range

Telling you that there isn’t the range that you specified in the selected text. So re-type the range and you will get it right.

eg.

1,2p

Hello World! This is my first text in the sam editor

There are more commands that sam can use at the start of a file, such as ‘c’ to replace,’i’, to insert at the start of the line, ‘a’ to add at the end of the that index. These indexes are usually referred to as the current ‘dot‘. More generally you can think of them as operating on the selection of text that we have created.

Alternative ways to write these commands can be in the syntax command/expression like what is written below.

a/Hello Universe – Appends Hello Universe to the end of dot.

i/Just before Hello  Universe – Inserts string into the start of the dot. 

c/Hello entire universe – Overwrites what’s in dot with “Hello entire universe”

Selecting more than one dot is possible and is easily done with the range commands that we have. So if we wrote all those commands above we might have 3 dot’s to work with and we can set the current dot to 3 for example by typing into the terminal:

sets the current dot to the second ‘dot’

2 

i/Text inserted before dot 2

then

a/Text inserted after dot 2

That inserts those strings at the end of the 2nd dot.

Now we might have:

Hello World! This is my first text in the sam editor

Just before Hello Universe

Text inserted before dot 2

Hello Universe

Text inserted after dot 2

Simple! A full command list is written below so that you can try it on the text that you have already. No changes will be made to the file yet, so you can overwrite and undo as many times as you want. At the end you might like to write the file and that command is simply ‘w‘.

*Image taken from http://plan9.bell-labs.com/sys/doc/sam/sam.html

To run a command on a whole range of text it is possible to select the whole file to do that on, and you simply type in

,x/World/c/Universe

0,$p

Hello Universe! This is my first text in the sam editor

And if you want to change back (in other words undo) then you type in the command:

u

0,$p

Hello World! This is my first text in the sam editor

COMMANDS

You can run eight basic commands on the file that you have in Sam. These are unix commands that allow you to run other commands present in your system. For example using the command > lets you operate on the current text. Using writes to the current text.

For example you are able to count the words in the current text, so you can type in:

1,2>wc

And you will get information like this:

1,2>wc

2             18          87

Word count operates on the current text, in this case it is ( Hello World! This is my first text in the sam editor ).

Alternatively you can run the date command and get some information on the date and time from the system.

!date

Mon MAY   7  02:45:30 EDT 2012

And you may want to write that to the end of the file ( or insert it to the address of dot). So set the address of where you want to write to by typing in our case.

2  (set the address of dot to 2)

2<date  (command date into 2nd address)

0,$p (print the file from 0 to last null line)

And you have written the date to the 2nd address. This will print something like this:

Hello World! This is my first text in the sam editor

Mon MAY   7  02:45:30 EDT 2012

A good outline of many of the features of Sam is located in an HTML version here:

http://plan9.bell-labs.com/sys/doc/sam/sam.html

And a more complicated, but detailed version of how to use Sam, is here.

http://doc.cat-v.org/bell_labs/sam_lang_tutorial/sam_tut.pdf

A quick reference card for Sam is located here:

http://plan9.bell-labs.com/sources/contrib/steve/doc/sam-refcard.pdf

Installing plan 9 on VirtualBox

Download and install plan 9 in a virtual machine.

VirtualBox and Download

The best way to get the experience of plan 9 is to run it in a virtual terminal. I recommend and use VirtualBox if you are running on a Linux system. If you are on a linux system you can use the package manager to download and install this software. If you are on a windows machine the best place to find the software is at https://www.virtualbox.org/wiki/Downloads

Once you have that configured, you can download a copy of plan 9 from the main website.

http://plan9.bell-labs.com/plan9/download.html – and choose the CD download image. Its in a .bz package and you need to unzip this to continue any further. To do that if you are on a windows machine will require WinRAR to decompress the .iso image, but in Linux you can double-click the file to open the archive manager to continue. Once the plan9.iso is present in your system somewhere we can install it in our virtual space.

Its now time to run the program.

Set up a disk for the operating system. Click the ‘NEW’ button in the VirtualBox OSE manager, and you will get a wizard that drives you through the installation. Click next, and type in a name of your installation. Choose ‘Linux’ as the Operating System, and Ubuntu as the version. The memory size should be anywhere near to or greater than the default that it provides ( 512 MB ).

Then you can create a new boot hard disk. Click next and type in the information for your hard disk (it will save this as a .vdi file – which you will need to start the installation) . Set its size to however much you have available, and specify if it is dynamically expanding or a fixed size hard disk.

Its important that you add this hard disk to the list of IDE Controllers . Select settings, and then ‘Storage’ from the left column. In the ‘IDE Controller’ box, it most likely added the hard disk as a SATA controller. Its best to remove this device and add your hard disk as an alternate IDE controller. Click the plus symbol to get a dialog that  lets you select an existing disk. Choose an existing disk and add your .vdi file you created.

Everything should be fine to run after some initial settings have been configured.

Virtual box settings for mouse USB and Network.

Plan 9 relies upon a mouse and as a default, VirtualBox’s settings specify that there is a USB controller selected. Its best that you de-select this option so that you have a mouse when the os starts to run. Go to Settings on the left hand column go to USB and deselect the default USB controller.

You will also want to connect to the internet and so it is important to configure the network adapter in the settings as well. Again go into the settings page and select Network from the left hand column. You need to select

  1. Bridged adapter
  2. eth0
  3. Intel PRO/1000 MT Server (82545EM) 

  4. MAC address (whatever was selected)
Step three is important because your internet connection wont work if this option isn’t selected.

Installation.

Once the virtual box starts the installation ( or if you want to cleanly install onto a new system )  – you are presented with 2 options. Install onto the system or boot a live version. Booting the live version will let you view the OS, but not be able to make any changes to the system, and that’s why we’ll install a full copy.

After selecting ‘1’ you are presented  options for your system.

  • use DMA for ide drives[yes]:  hit enter
  • mouseport is (ps2, ps2intellimouse,0,1,2)[ps2]: – hit enter
  • vgasize [640x480x8]: -hit enter

The next selection is critical, and you should type vesa

  • monitor is [xga]: vesa

Hit enter and you will get something like this:

The start of the installation wizard for plan 9

The defaults the installation chooses are presented between the brackets. By hitting enter at each pass you are selecting those defaults.

Partitioning

Select, ‘fossil’ as your file server and prepare for partitioning options. In my installation, I have sdC0 as the default option (remember the .vdi file) – so you must select the .vdi hard disk you created.

Entering ‘w’ and ‘q’ at the partitioning prompt (>>>)  are enough to create 4 partitions – 9fat, isect, fossil, swap – (note hitting anything else will give ?) so type ‘w‘ and ‘q‘. Select fmtfossil by hitting enter ( the same for mountfs, and configdist ). You will notice that the installation guide has a list of things it has already completed. You might choose to prematurely end the installation, but those tasks it has already completed will remain set in the options.

Then you are able to choose if you want to download the distribution from the net or from a local media. So type in “local” because everything is from the CD we already downloaded. If you’ve come this far and you choose net, you will have to configure your net connection for use – however its best to just install from the CD.

Hit enter at “mountdist” option and you are shown the storage devices on your system: You need to select where the distribution is contained, and because its on our CD, you must type in /dev/sdD0/data. It then asks if the distribution is at the root of the CD or in another location. If you just hit enter here plan 9 will drop you into a shell to browse for the distribution.

Its possible that you will get caught in this shell, so you can type ‘lc’ to look around and if you have a list of files something like

/% lc

386         acme   cron   mips  sparc64

68000   adm     dist     mnt   sys

… … …

You are probably in the right place, so you can type exit to leave, and enter to start into copydist.

Copydist

Hit enter to copy the distribution over to your .vdi you created and it should start installing the file system and this might take some time.

After that, you can hit enter again at bootdisk to let plan 9 decide how to boot the system.

There are 4 options for boot method, floppy, plan9, win9x, winnt. Again choose the default value by pressing ctrl-d and at the finish menu, press enter.

Running the System:

Run the installation from VirtualBox and enter ‘glenda’ as your user name.

Note that on running plan 9 initially you might not have mouse support. The mouse plays a key role in plan 9 and it is important that you have it working: Go to your virtual box settings and select “settings” scroll down the left hand column to USB, and deselect, “enable USB controller” . To do this you might have to shut down the running system to get access to the settings of VirtualBox.

Note that you might also want an internet connection, so ensure that you have changed the network settings in virtual box to Intel PRO/1000 MT Server (82545EM) option. To configure network support at startup you will want to un-comment out one line in the /bin/termrc file: ip/ipconfig! Comments begin with a hash(#). Do this now to avoid having to run ip/ipconfig every time you start a session.

See the next tutorial to learn how to edit files in Sam – or alternatively you can follow the instructions that are given in the start-up page of plan9.

Installation on other systems.

The installation is pretty strait forward, however if you want to install on a system that you use regularly, you must be careful about partitioning your hard disk space so that you don’t overwrite a windows system or even your linux system. You are most likely the safest if  you try to install plan 9 on a virtual system. If your virtual system is not virtualBox then you can look at the man pages for virtual images at http://www.plan9.bell-labs.com/wiki/plan9/virtual_machines/index.html

In summary:

  • Test out plan 9 on your system with Virtual Box.
  • Create a new hard disk, or use an existing hard disk that you can download from http://virtualboxes.org/images/plan-9/ and tell Virtual Box that its the hard disk that you want to use.
  • De-select the USB controller in Virtual Box USB settings.
  • Add the Intel PRO/1000 MT Server (82545EM) option in your network devices to get internet connection with plan9
  • Choose vesa as your monitor option.
  • Choose all defaults for your system (by hitting enter).
  • Partition your system with the recommended settings.
  • At mountdist option, once you find the location of the plan 9 distribution (commands are lc, exit and cd), exit the shell and continue on with the installation.
  • Run the system with ‘glenda’ as your user name.

Introduction

Hello! I have chosen to create some tutorials for the OS Plan 9. Its my goal to introduce some simple aspects of Plan 9 so that more users might get interested with it and are able to use it effectively!