Tuesday, September 26, 2006

Introduction to Minix 3

Andy Tanenbaum has an article on OSNews introducing Minix 3:
How often have you rebooted your TV set in the past year? Probably a lot less than you have rebooted your computer. Of course there are many "reasons" for this, but increasingly, nontechnical users don't want to hear them. They just want their computer to work perfectly all the time and never crash.


Categories: ,

Saturday, August 05, 2006

Downtime for upgrade

There was an approximately 10 minute outage today while I updated some server software. This is the first time I've taken the Minix machine down since transitioning to the new dedicated server. With an uptime of about 40 days it seems that Minix is proving a nice stable server OS.

I installed a CGI script that runs the 'uptime' command for those curious about the uptime of the server.

Categories: ,

Saturday, July 15, 2006

CVS access to Minix Source Code

The Minix source is now available by CVS. This post on comp.os.minix explains the details. The command to check out the source is:
cvs -d :pserver:anonymous@derelict.cs.vu.nl:/cvsup/minix co src

As well as the 'src' module there is a 'bigports' module that contains the source to a number of application ports to Minix.

The repository can also be browsed via CVSWeb: http://derelict.cs.vu.nl/cvsweb/cvsweb.cgi.

I generated a ChangeLog using cvs2cl.pl which gives an idea of the changes being made recently to the source.

Categories: ,

Friday, July 07, 2006

wmii Window Manager for Minix 3

I've ported the wmii X11 window manager to Minix 3. Details of some of the things I changed are mentioned in my previous post on the topic.

To install you'll need to compile from source. The source is in minix-wmii-3.1.tar.bz2 (about 52Kb). To compile:
$ bzcat minix-wmii-3.1.tar.bz2 | tar xvf -
$ cd wmii-3.1
$ make
$ su
<...enter root password...>
# make install

You will need the X11 libraries installed. You should not use the GNU compiler, rather use the standard Minix 'cc' and 'make'. The installation will 'chmem' the installed files with reasonable values to run. It's important that you read the notes about this port and the end of this post!

To use this window manager, edit your .xsession or .xinitrc file (the setup of these files is described here). Remove the current code that runs 'twm' and the other programs and replace with the single line:
exec wmii


When you next start X11 the wmii 'welcome' note will appear. You can follow those instructions to get an idea of how to use this window manager. If you get stuck, pressing 'ALT+ENTER' will open an xterm.

'wmii' is a very light weight window manager. When you start it you'll see a status bar at the bottom of the screen and nothing else. Pressing ALT+ENTER will open an xterm and you'll see that it takes the entire screen. If you press ALT+ENTER again the screen will split into two with an xterm above and below. This is what 'wmii' refers to as 'dynamic window layout'.

You need never drag or layout windows yourself, the window manager will do it for you. You can create multiple columns, move windows above and below each other, or across into the other columns. You can switch to a 'stacked' view by pressing 'ALT+s'. Or a maximised view with 'ALT+m'. Or back to the dynamic layout with 'ALT+d'. To change from application to application in a view with the keyboard use 'ALT+j' or 'ALT+k'.

'wmii' gets really powerfull though when you take advantage of 'tagging'. You can tag a particular running application with a number by pressing 'ALT+SHIFT+[0-9]'. This will assign that number as the 'tag' for the application and move the application to a view for that tag. To change to a dynamic layout for all apps with that tag press 'ALT+[0-9]'.

This doesn't give much more than 'workspaces' gives in other window managers. But you can also assign multiple tags to an application in 'wmii'. And they don't need to be numbers. So I could have firefox open (running using remote X11 from another machine) and give it the tag 'browser' and by pressing 'ALT+SHIFT+t' and typing in 'browser' and pressing enter. Or give it multiple tags by pressing 'ALT+SHIFT+t' and typing in 'browser+2'. This gives it the tags 'browser' and '2'.

Pressing 'ALT+2' now will take me to that application and so will pressing 'ALT+t' and typing in 'browser' (or a partial completion). This allows you to give applications multiple tags, switch to the tag and all applications with that tag will appear, dynamically layed out by the window manager. Neat!

It gets even better. 'wmii' exposes a scripting interface via a Plan 9 based filesystem. If you have Plan 9, Inferno, or some other OS that supports this filesystem you could mount it from there and manipulate the display. Since Minix doesn't have 9P support you can use the tool 'wmiir' which allows you to do this. For example, to get a directory listing of the root of the virtual filesystem:
wmiir read /

This will display a list of virtual directories which you can drill down on:
wmiir read /event

This reads all events that occur in 'wmii' and displays it. You'll see tag switching, focus changes, etc. With this you can write scripts to react to events. Which is how some of the utilities in 'wmii' are written - as shell scripts. You can change that status bar with:
echo -n Hello! | wmiir write /bar/status/data

The 'status' script in /usr/local/etc/wmii-3/status' does this to display the current time and machine load.

There is much more that can be done and browsing the wmii web site will go through the various things.

This is a 'work in progress'. I've had to work around some things that I'd like to tidy up. Some current limitations are:
  • A temporary file is created in /tmp/ that is supposed to have a random suffix but does not in this version. This is due to the lack of 'mktemp' in Minix. I'll fix this in the next release.
  • The 'tcp' port used for 'wmii' communication is hard coded to port 5000 and is not bound to the IP address of the machine. Anyone can connect to it. If your machine allows incoming connections on that port you probably don't want to run to run this version or use a firewall to block that port.
  • Sometimes the 'status' script exits due to not being able to connect to the 'wmii' server. You can restart it by using 'ALT+a' and choosing 'status'.

The first two these issues can be changed by editing the 'wmii' script. You'll see in there where the '5000' port and the filename is hardcoded. Unfortunately the open access to the socket is in the C source code as I did that to work around a problem I was having which I hope to resolve in the next release.

This version is based on the wmii 3.1 source code. The current development snapshot for wmii is on to version 4. I'll look at porting that when I've got 3.1 stable. For those interested in hacking at the code I have a git repository here:
git clone http://www.minixtips.com/repos/wmii/.git


If you come across any other problems or have any suggestions please leave a comment.

Categories: , , ,

Thursday, July 06, 2006

Tweaking X11

Once you've got X11 up and running you'll probably want to change what programs are run when you start it, and tweak a few settings. With the exception of the 'chmem' section, none of this is Minix specific and you can read most any X11 tutorial on the internet to get more details.

The set of programs that are run when you first log on using 'xdm', or run 'startx' from your user account are controlled by a configuration file in your home directory. If you used 'startx', the configuration file is called '.xinitrc'. If you logged in under 'xdm' then the file is '.xsession'.

You can copy the default file from '/etc/X11/xinit/xinitrc' to one or both of these names and start editing it:
$ cp /etc/X11/xinit/xinitrc ~/.xinitrc
$ cp /etc/X11/xinit/xinitrc ~/.xsession
At the end of this file you'll see something like:
# start some nice programs
twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

'twm' is the window manager. This is the program that allows you to drag windows around, resize, etc. If that's not running you'll only have the initial programs started in this configuration file and you won't be able to manipulate them.

The last statement in the file should 'exec' a program. If it doesn't then X will run the programs and then immediately close.

The default 'chmem' values of programs like 'xclock' and 'xterm' are quite high. If you want more free memory I recommend lowering these. I use 2MB but could probably go lower.

Minix does not have a great deal of X programs ported yet. For example there is no GUI web browser. But with X you can run programs on a remote machine (which needs to be running an X server) and have the display appear on your Minix machine. This is how I use firefox under Minix.

To set this remote display up all you need to do is tell Minix to authorise the other machine to use the desktop. The 'xhost' command can do this. I have a Linux machine with IP address 192.168.1.100 and the Minix machine is 192.168.1.101. On Minix, with X started, I do:
$ xhost +192.168.1.100

This uses the IP address of the Linux machine. Now from Minix I can 'ssh' to the Linux machine, and run programs there that appear on the Minix display:
minix$ ssh chris@192.168.1.100
<...login...>
linux$ export DISPLAY=192.168.1.101:0.0
linux$ konsole &
linux$ firefox &

The DISPLAY environment variable dictates what display the program will run on. In this case I set it to the IP address of the Minix machine, and the display number (0.0). Running 'konsole' and 'firefox' will cause them to appear on Minix and I can use them normally. Remember though that they are actually running on the Linux machine - only the display is on Minix. So all file paths, etc are relative to the Linix file system.

This setup works fine even using VMware. I use the 'bridged networking' option and can run Minix in VMware, running programs from the host Linix machine. For 'qemu' you may to do some additional tweaking if you are using the '-net user' option. See this newsgroup posting for details.

The default window manager (and only one currently available) is 'twm' which is quite basic. I've ported 'wmii' which is another minimal window manager but has a little more functionality.

If you have any tips on configuring X11 or programs to run with Minix please leave a comment.

Categories: ,

Running X11 on Minix

Minix 3 has X11 as one of the optional packages that can be installed. It works very well and I've been using it as on my main machine to test some software I've been porting.

To get started with X11 you'll first need to install the X11 package using 'packman' signed on as root:
$ su
<...enter root password...>
# packman
<...select X11R6 package...>

As part of the install you may notice the X binary has its memory value changed using 'chmem'. Usually this is set to a too large value which can result in X not starting. This will depend on how much physical memory you have on your PC. If you have 512MB you will probably be alright but if you have less then I'd advise manually chaning the value to something smaller. The following command works on my 256MB VMware session:
# chmem =80000000 /usr/X11R6/bin/Xorg

The higher you go the more memory X will require to run and the less free memory you'll have available for other applications. Going too low will cause it to not start at all. To do a quick test to see if X starts I recommend logging in as a non-root account and runing 'startx':
$ startx

Some log information will display on the screen and after 20-30 seconds (depending on the speed of your machine) you will see X appear running the 'twm' window manager and a couple of terminal windows and a clock. You can close it down by pressing CTRL+ALT+BACKSPACE or kill the running X process:
$ ps ax |grep X
174 co 0:00 /bin/sh /usr/X11R6/bin/startx
176 co 0:10 X:0
$ kill 176

Remember that with X you will need have the mouse cursor over the terminal window for it to get focus so you can type into it.

If it doesn't start when running 'startx' you've probably run out of memory. There is log information on the console or in '/usr/log/XLogFile.0.log' which should help track the problem down. Try increasing the 'chmem' value for the '/usr/X11R6/bin/Xorg' program. And have at least 256MB of RAM. With tuning it will run in less but these are the values I've had working.

Another way of running X is to run 'xdm' logged in as 'root'. This will bring up an X session prompting for a username and password. By entering your normal username and password you can then get an X session customised for that user. When you exit X as that user it'll then take you back to the username/password request.

To configure the screen size you need to create a file called '/etc/X11/xorg.conf'. This file contains quite a bit of configuration information and the easiest way to create it is to run 'xorgconfig'. This is a text mode program that will run through a series of questions to create a basic 'xorg.conf' file.

When asked for the device name of the mouse enter '/dev/kbdaux'. You'll need to know things like your monitor's horizontal and vertical refresh rate and the type of video card you have (for VMware installations choose 'vmware' here).

Once the 'xorg.conf' is created there are some simple changes that you can make that are quite useful. The first is enabling the scroll wheel on your mouse if you have one. Edit '/etc/X11/xorg.conf' (using something like 'mined' or 'vim') and search for 'InputDevice'. You should come up with a section like:
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Buttons" "4"
Option "Protocol" "ExplorerPS/2"
Option "Device" "/dev/kdbaux"

Add to this section a line containing 'Option "ZAxisMapping" "4 5"'. So it will now look like:
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Buttons" "4"
Option "Protocol" "ExplorerPS/2"
Option "ZAxisMapping" "4 5"
Option "Device" "/dev/kdbaux"

If you start X again you can use the scroll wheel. To change the screen size search for the section 'Screen'. My 'Screen' section looks like:
Section "Screen"
Identifier "Screen 1"
Device "** VMware Guest OS (generic) [vmware]"
Monitor "My Monitor"
DefaultDepth 16
Subsection "Display"
Depth 16
Modes "1024x768"
ViewPort 0 0
EndSubsection
EndSection

By changing the 'Modes' option to another resolution size and restarting X you will have a different screen size. For more on configuring X any resource for Linux or other operating systems that use it will be useful.

Categories: ,

Tuesday, July 04, 2006

Port of wmii window manager in progress

Posts have been a bit lighter as I've been immersed in porting the wmii window manager to Minix. I've managed to get it running and am currently testing it.

I had to do some workarounds I'm not too happy with and I'll tidy those up over the next few days before I release it. For example it currently uses about 10% CPU while it runs which I want to get down. To port it I had to do the following:

  • Use TCP sockets instead of Unix domain sockets as Minix does not have the latter
  • Modify the code to compile using 'cc' instead of 'gcc' so I can link to the X11 libraries (which were built using 'cc' in Minix 3.1.2a)
  • Convert 'long long' use to a structure containing two longs ('cc' doesn't have the 'long long' type)
  • Various socket modifications. Some of these I need to clean up before release as it's not binding the socket to the IP, it's instead using INADDR_ANY which is a security risk. This is the result of my modifications/hack not due to Minix or wmii!


So far I like using 'wmii' - it uses less memory than the default 'twm' leaving me with much more space to run applications. This could be due to the 'chmem' sizes on the application vs 'twm' defaults of course.

'wmii' uses the Plan 9 filesystem protocol to allow it to be scripted. By reading and writing from/to a virtual filesystem you can get information about running applications and change them. It's pretty neat. It comes with a tool, 'wmiir', to allow access to this virtual filesystem. It should be possible to write a Minix device driver that allowed this to be mounted to the filesystem so you could interact with 'wmii' using standard Minix utilities. This would make an interesting device driver project.

Categories: ,

Perl Updated

The version of Perl on the Minix 3.1.2a install does not include any of the modules which means that many scripts don't work correctly. This has been fixed and the new version can be obtained using 'packman'. Make sure you choose the Perl option from 'net' and not 'cdrom' to pick up the corrected version. Information obtained from this comp.os.minix thread.

Categories: ,

Tuesday, June 27, 2006

Git port updated

I've updated the Minix 3 Git port so retrieval of remote repositories via HTTP work. This requires the recent Curl port.

Once installed you'll be able to retrieve directly from the Minix Git repository hosted here with something like:
git clone http://www.minixtips.com/repos/minix-git.git/ minix-git

Updated source here: minix-git-1.4.0a.tar.gz.

Categories: ,

Curl ported to Minix 3

The following files provide a port of Curl for Minix 3:

The source can be built and installed with:
$ gmake
$ su
<...root password...>
# gmake install

Curl is a command line utility for transferring files via protocols like HTTP, FTP, etc. It's used by the Git version control system to access remote repositories which is why I ported it.

Categories: ,

Preliminary Git port for Minix 3

[ Updated 2006-06-27: Now includes HTTP support using the Minix Curl port ]

I've done a first cut at a port of the Git version control system. This is the system currently used for managing the Linux kernel. It's a distributed version control system, similar in manner to the way 'darcs' and 'arch' work.

I've not got everything working yet. The 'git' protocol requires a program to be running on the server hosting the repository, which I haven't ported yet. Still, the port is useful as it is. You can publish repositories using HTTP for example and you can retrieve remote repositories using 'git' or 'http'.

You can get the buildable distribution from minix-git-1.4.0a.tar.gz. It's about 850KB in size. To build you'll need your path setup as:
/usr/gnu/i386-pc-minix/bin:/usr/gnu/bin:/usr/gnu/bin:$PATH

You'll need bash, as well as a variety of the GNU tools. I installed everything off 'packman'.

To build just do:
make
make install
chmem =25000000 ~/bin/*

This will do a 'local install' into a $HOME/bin directory. Add this to your path and it should work. A quick tutorial is available here

The Git repository for the changes I've made is here: http://www.minixtips.com/repos/minix-git.git/

You can retrieve it with git:
git clone http://www.minixtips.com/repos/minix-git.git/ minix-git

Once you have the repository it will default to the 'master' branch. To build from the repository you'll want the 'minix_1_4_0' branch - this is the one that contains my Minix changes. You can change to it with:
git clone http://www.minixtips.com/repos/minix-git.git/ minix-git
cd minix-git
git checkout minix_1_4_0

The 'git' protocol works for retrieving remote repositories too. For example, to retrieve the original Git repository:
git clone git://git.kernel.org/pub/scm/git/git.git

Be aware that this is an 'in-progress' port so will very likely have bugs. I wouldn't use it on your only copy of your important source just yet!

Categories: ,