Virtually Minix: A Tutorial & Intro to Minix on XP via Bochs

This tutorial will walk the reader through setting up Minix 2.0.4 on Windows XP via Bochs 2.1.1. These are the latest versions of Minix, Bochs and Windows XP as of May of 2004. In this era of Linux and Windows domination of the OS scene, it is important to remember that there are alternatives. Hence, this article will also serve as an introduction to one such alternative, Minix, which has a very rich heritage, indeed.

Props

Props to Andrew Tanenbaum, Al Woodhull, and Thom Holwerda. Andrew Tanenbaum for Minix, Al Woodhull for the Minix on Bochs on Windows How-to, and Thom Holwerda for introducing me to PearPC.

minix

Background

My interest in Minix has been rekindled in recent days by a combination of events. Thom Holwerda wrote an article on May 18, 2004 about running OSX Panther on a PC. I dusted off the Panther CDs and 5 hours later, Mac on a PC, will wonders never cease. Needless to say, I was raring to emulate every OS I could find, thus I needed Bochs. After about 10 hours of fairly painful downloading and tweaking, I got these OSes working in Bochs, to some extent:

Menuet
NewOS
Oberon
Tomsrtbt

I failed miserably with these:

AROS
ReactOS
Syllable

I archived off the work and forgot about it for a few days. What threw me over the edge and got me to exploring Minix on Bochs was the article that OSNews linked to at CNET News, by Stephen Shankland – Is Torvalds really the father of Linux This article reported on the Alexis de Tocqueville Institution report, which suggested that more credit should be given to Minix. Intrigued, I followed a link to a response by Andrew Tanenbaum, Minix’s creative father, and a few days later the followup.

Andrew Tanenbaum’s concise history of Linux come Unix is quite interesting, if unconventional. I followed a series of links from there and wound up at Al Woodhull’s helpful Minix site. Al Woodhull co-authored the Second Edition of Operating Systems: Design and Implementation and is quite an authority on all things Minix. Long story short, I learned in the space of a couple of days, that Minix was worthy of further study.

About Minix

Minix is a Free, Open Source, Unix-like Operating System. Originally created by Andrew Tanenbaum to compensate for ATT’s prohibition against teaching Unix internals and to provide him with a tool for teaching Operating System design and internals to his students. Minix predates Linux as the first free, unencumbered, Unix clone. The Minix source code was included in the book, Operating Systems: Design and Implementation, by Andrew Tanenbaum, a classic of modern technical literature, for free. Minix is Unix-like and therefore Linux-like, and yet, it differs considerably in it’s architecture. The biggest difference being that Minix is a micro-kernel. The Minix system source code comprises a whopping, 4.5 megs uncompressed. The Linux kernel archive is 176 megs uncompressed. Another striking difference is comments – the Minix source is incredibly well documented and suitable for study.

I decided to compare a couple of comparably sized files from the Linux kernel archive and Minix source at random to get a feel for the comment levels of the two OSes and the results were astonishing:

Linux: compat.c, 533 lines, 8 comments, 26 lines
Minix: keyboard.c 505 lines, 142 comments, (too many to bother counting).

To be sure, Joe Hacker could probably tell by the context, of every line of code in compat.c, what each line does and would likely claim that the comments were superfluous – that compat.c contains nothing but self documenting code, but for us normal, non superhuman types, comments are a necessity for understanding. I realize that my method of random selection is not very scientific. However, having browsed both sets of code, quite extensively, it is my opinion that this is a representative sample.

Requirements

This tutorial assumes that you are familiar with Windows and Unix. You do not have to be a guru or even a power user, but a good understanding of the usage of both of these operating environments is required. Unix, in this context, refers to Linux, Minix, BSD, SCO, Solaris, etc. Windows, in this context, refers to the Windows NT branch of Windows – Windows NT 3.5, 4.0, Windows 2000 and Windows XP. Windows 95 and its descendants might suffice, but I would not be able to say, one way or the other.

Cygwin

If you are going to be playing around with OS emulation, you are going to need Cygwin, to keep your sanity. In order to complete this tutorial you will at least need the dd utility. All of the command-line commands in this tutorial will be Cygwin commands – translation to the XP command prompt equivalents are left as an exercise for the reader.

Here is what the cygwin command prompt looks like:

minix

Cygwin can be downloaded from the Internet here.

Bochs

The current version of Bochs is 2.1.1. Bochs is an IA-32 Emulator and it is Open Source. It is how we are able to run Minix in Windows XP. It can be downloaded here/.

Minix

Minix has been described adequately, above. The current version is 2.0.4 and can be downloaded from either:  here
or
here

The files that you will need from the Minix site are:

i386/ROOT – Installation root floppy image
i386/USR – Installation /usr floppy image
i386/USR.TAZ – Binary /usr files (386 executables)

SRC/SYS.TAZ – if you want man pages

Preparation

Cygwin

Download and install the Cygwin distribution. There is really nothing more to it.

Bochs

Download and install Bochs, configure it to your taste, but the defaults are fine.

Minix

Download the four files above. The rest of the tutorial will describe setting Minix up in Bochs.

Getting Started

Requirements met, preparation done. It is time to begin in earnest.

Create directory

Create a directory to contain the working files.

    mkdir minix-2.0.4

Create image

Create an Empty 40 Megabyte Disk Image.

Run the Bochs Disk Image Creation Tool to create a hard disk image to host the Minix system. The tool can be started in one of two ways, from the command prompt in the Bochs program directory:

    bximage

or from the Start menu:

    Start->Programs->Bochs 2.1.1->Disk Image Creation Tool

Enter the commands as shown to create a 40MB empty disk image:

=============================================================
                                bximage
                  Disk Image Creation Tool for Bochs
     $Id: MinixOnBochsOnWindows-revised.html,\
         v 1.3 2004/05/31 01:17:39 wsenn Exp $
=============================================================

Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd]

What kind of image should I create?
Please type flat, sparse or growing. [flat]

Enter the hard disk size in megabytes, between 1 and 32255
[10] 40

I will create a 'flat' hard disk image with
  cyl=81
  heads=16
  sectors per track=63
  total sectors=81648
  total size=39.87 megabytes

What should I name the image?
[c.img] Minix-2.0.4-emptyHD.img

Writing: [] Done.

I wrote 41803776 bytes to (null).

The following line should appear in your Bochsrc:
  ata0-master: type=disk, path="Minix-2.0.4-emptyHD.img",\
 mode=flat, cylinders=8
1, heads=16, spt=63

Press any key to continue

It is important that you write down the line that begins ata0-master. This is the settings line that will be used to configure Bochs to recognize your hard disk image.

Copy image

The image will be placed into the Bochs program directory. Copy it from there into the working directory:

    cp Minix-2.0.4-emptyHD.img d:\workarea\minix-2.0.4

Backup image

Throughout this tutorial, I will advise that the image be backed up at various stages of its life. It is critical that you do this. Backing up the image is accomplished by zipping it up with your favorite archiving utility – mine is WinRar, but there are plenty to choose from at CNET Downloads and Cygwin comes with gzip, which also works and is used below.

Backup up the image now. It is in a pristine state and can be used in a variety of situations in its current state.

    gzip -9 minix-2.0.4-emptyHD.img

This will create a gzip file that is about 40K. Store the zip file somewhere safe:

    cp minix-2.0.4-emptyHD.img.gz somewheresafe
    gzip -9 minix-2.0.4-emptyHD.img.gz

Initialize Minix

Initialize Minix on the 40 Megabyte Disk Image.

In order to boot Minix on Bochs, a ROOT image, USR image, empty hard disk image, and a bochsrc file is needed. ROOT and USR were downloaded in the Preparation stage and the 40 Megabyte empty hard disk image was created in the previous step. The Bochs emulator uses a text configuration file to control how it runs. In the so-called, bochsrc file, all of the information needed to run the Minix environment will be placed, specifically, how much memory, which BIOS, which VGA ROM, disks, mice, etc. Here is a reasonable bochsrc for installing Minix on the empty hard disk. It will boot from floppy whereas the final version will boot from the hard disk. Save it to a file called Minix-2.0.4-prep.bxrc (bxrc files are associated with Bochs by its install script):

    megs: 8
    romimage: file=$BXSHARE/BIOS-Bochs-latest, address=0xf0000
    vgaromimage: $BXSHARE/VGABIOS-elpin-2.40
    ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
    ata0-master: type=disk, path="Minix-2.0.4-emptyHD.img",\
    mode=flat, cylinders=81, heads=16, spt=63
    floppya: 1_44=ROOT
    floppyb: 1_44=USR
    boot: floppy
    log: Minix-2.0.4-prep.log
    mouse: enabled=0

Pay particular interest to the lines:

ata0-master – this is where the hard disk is defined, the line came from the image creation tool
floppya – specifies the ROOT image for booting the new system
floppyb – specifies the USR image which contains the /usr file system
boot – tell Bochs to boot from the first floppy it finds (a)

Boot Minix using ROOT

This is where the fun begins:

1. Double Click the Minix-2.0.4-prep.bxrc file to start Bochs and boot Minix off the ROOT floppy.
2. Press = when the Minix boot monitor appears, to boot Minix.
3. Type fd1 when asked to: Finish the name of the device to mount as /usr: /dev/.
4. Login as root at the prompt:

    noname login: root

5. Press F3 to turn on Software scrolling (may be needed if text disappears).
6. Type setup to begin the actual setup script.

    # setup

7. Press enter at the : prompt to continue.
8. Press enter to accept the keyboard selection:

    us-std

9. Press enter at the : prompt to continue.
10. Configure the empty hard drive /dev/hd0.

10.1. Arrow-Down (you will see Active flag at the top left) and probably something like:

    /dev/hd0: Invalid partition table (reset), ignore the error -\
 it's just Minix's way of telling you that the empty image \
 is not partitioned.

10.2. Right-Arrow (you will see Hex partition type at the top left).
10.3. Type 81 to change the Type of the partition to Minix.
10.4. Right-Arrow three times (you will see Start head).
10.5. Type ‘+’ to increase the Head count to 1.
10.6. Right-Arrow seven times (you will see Size in kilobytes at the top left).
10.7. Type ‘m’ three times to maximize the size and kb column values to the detected values. You should now see the following line:

    1*  hd1  81 MINIX  0    1   0  80   15  62    63   81585  40792

10.8. Type ‘w’ and ‘y’ to write the partition table to the image.
10.9. Type ‘q’ to exit the partition program, part.

10.10. Type ‘hd1’ when asked to finish the name of the primary partition /dev/.
10.11. Press enter to accept the default layout.
10.12. Wait for Minix to scan the image.
10.13. Press enter to accept the default location of the ROOT floppy – 0.
10.14. Press enter to accept the default memory size of the system [4096 or more].
10.15. Type ‘halt’ to stop the current instance of Minix, when prompted.
10.16. Type ‘boot hd1’ at the fd0> to test out the hard drive instance:

       boot hd1

11. Press = to start Minix on the hard disk image.
12. Login as root:

       noname login: root

13. type ‘shutdown -h now’ at the # prompt to stop the instance:

       shutdown -h now

14. Press the Power button in the Bochs Toolbar to shut down Bochs.

Backup the image

The hard disk image now contains a bootable hard disk with a tiny root file system on it. Make a backup copy of the image in this state.

    cp minix-2.0.4-emptyHD.img minix-2.0.4-rootonlyHD.img
    gzip -9 minix-2.0.4-rootonlyHD.img
    cp minix-2.0.4-rootonlyHD.img.gz someplacesafe
    gzip -d minix-2.0.4-rootonlyHD.img.gz

Create a Bochsrc for the new image

Now that there is a Minix bootable hard disk image, a new bochsrc file is needed. Here it is – name it Minix-2.0.4-rootonlyHD.bxrc:

    megs: 8
    romimage: file=$BXSHARE/BIOS-Bochs-latest, address=0xf0000
    vgaromimage: $BXSHARE/VGABIOS-elpin-2.40
    ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
    ata0-master: type=disk, path="Minix-2.0.4-rootonlyHD.img",\
 mode=flat, cylinders=81, heads=16, spt=63
    floppya: 1_44=floppya.img
    floppyb: 1_44=floppyb.img
    boot: disk
    log: Minix-2.0.4-rootonly.log
    mouse: enabled=0

The relevant new lines are:

ata0-master – now points to our bootable Minix image
floppya and floppyb – now point to non-existent image files, this allows us to insert floppy images at will, without actually initializing with a floppy in the drive (quirky, but effective, if you don’t specify a floppy the emulator seems to disable the floppy – at least on my machine)

Installation

In order to have a useable Minix system, an actual installation must be performed. First, though some preparation:

USR.TAZ and SYS.TAZ

Both of these files are too large to fit on a floppy and for the time being, the floppy is the only mechanism available to get files from Windows XP into Minix. The solution is to slice each file into floppy-sized chunks and read them in piecemeal.

In Windows, this is not as straightforward as I would like. Thankfully, Cygwin provides Windows users with a Unix like environment with which to work in. Feel free to find your own method for doing this and please share.

Hints

1. If you are new to Cygwin, drives are referred to as /cygdrive/[drive letter], as in /cygdrive/d instead of d:
2. If you are in a Cygwin Prompt or a Command Prompt window, and you want to start Explorer in that directory (maybe you want to rename and copy a set of files…), type:

    explorer /e,.

(explore space slash e comma dot)

3. dd is a unix utility that dumps data from one file to another. In unix a device can be a file, this allows the dumping of a floppy to a file and visa versa

Slice Archives

Use the dd utility to do the slicing of USR.TAZ:

    $ dd if=USR.TAZ of=USR-01.img bs=1440k count=1 skip=0
    1+0 records in
    1+0 records out

    $ dd if=USR.TAZ of=USR-02.img bs=1440k count=1 skip=1
    1+0 records in
    1+0 records out

    $ dd if=USR.TAZ of=USR-03.img bs=1440k count=1 skip=2
    0+1 records in
    0+1 records out

    $

You will need three slices with the current version of Minix, later you might need more. You have enough slices when dd reports 0+1 records in or 0+0 records in (in the case of a perfect fit of the last slice).

Use the dd utility to do the slicing of SYS.TAZ:

    $ dd if=SYS.TAZ of=SYS-01.img bs=1440k count=1 skip=0
    1+0 records in
    1+0 records out

    $ dd if=SYS.TAZ of=SYS-02.img bs=1440k count=1 skip=1
    1+0 records in
    1+0 records out

    $

You will need two slices with the current version of Minix, later you might need more. You have enough slices when dd reports 0+1 records in or 0+0 records in (in the case of a perfect fit of the last slice).

Start the Installation

1. Double Click on the Minix-2.0.4-rootonlyHD.bxrc file to fire up Bochs and Minixc
2. Login as root

     noname login: root

3. Press F3 to enable Software scrolling (if the screen blanks)
4. Type ‘setup /usr’ to start the USR setup process

    # setup /usr

5. Press enter to accept the default image size of all
6. Press enter to accept the default floppy drive of 0
7. Click the A floppy button in the Bochs toolbar
8. Click the Browse button and browse to the USR-01.img file to select it as the floppy image. Make sure inserted is checked
9. Click OK to continue
10. Press enter at the Please insert input volume 1 and hit return prompt (this will extract a bunch of files – ignore the Can’t make directory because it already exists messages – they are expected.

11. Click the A floppy button in the Bochs toolbar when prompted for the next volume
12. Click the Browse button and browse to the USR-02.img file to select it as the floppy image. Make sure inserted is checked.
13. Click OK to continue
14. Press enter at the Please insert input volume 2 and hit return prompt (this will extract a bunch more files)
15. and so on until you have extracted the contents of all of the volumes.

You know that you are done, when Minix says:

   Done.

Install the System Sources

The system is useable at this point, however, the man pages are not present and for me this is problematic – I cannot remember half the syntax for the commands. In order to get the man pages working, the SYS images must be imported and extracted. SYS also includes the kernel source code needed for recompiling the kernel, not covered here. Here are the steps for installing SYS:

1. Create a working directory in /usr, say /usr/work. The reason for this is the fact that the root / file system only has about a Megabyte of space.

    mkdir /usr/work
    cd /usr/work

2. Click the A floppy button in the Bochs toolbar.
3. Click the Browse button and browse to the SYS-01.img file to select it as the floppy image. Make sure inserted is checked.
4. Click OK to continue.
5. Read the contents to a file on the disk image:

    dd if=/dev/fd0 of=SYS-01.img

You should get a message similar to:

    2880+0 records in
    2880+0 records out

6. Click the A floppy button in the Bochs toolbar.
7. Click the Browse button and browse to the SYS-02.img file to select it as the floppy image. Make sure inserted is checked.
8. Click OK to continue.
9. Read the contents to a file on the disk image:

    dd if=/dev/fd0 of=SYS-01.img

You should get a message similar to:

    2880+0 records in
    2880+0 records out

10. Repeat this as necessary, until all of the SYS-0x.img files are read into the Minix hard disk image.
11. Concatenate the two images into one SYS.tar.Z file:

    cat SYS-01.img SYS-02.img > SYS.tar.Z

12. Uncompress the SYS.tar.Z file:

    uncompress SYS.tar.Z

13. Untar SYS.tar from /usr:

    cd /usr
    tar xvf /usr/work/SYS.tar

14. Test it out, type:

    man man

15. If all is well, a man page describing how to use man should be on screen.
16. Shutdown the instance by typing the following at the # prompt:

   shutdown -h now

17. Shutdown the Bochs instance by pressing the Power button on the toolbar.

Backup the image

You now have a bare instance of the Minix OS installed on the hard drive instance. This is an excellent time to archive the instance for posterity (and in case you mess up something and want to start over without all the pain of going through this how to again – aka backup).

Copy bochsrc and image

Copy the bochsrc and image files to new files:

    cp Minix-2.0.4-rootonlyHD.bxrc Minix-2.0.4-HD.bxrc
    cp Minix-2.0.4-rootonlyHD.img Minix-2.0.4-HD.img

Edit bochsrc

Edit the new bochsrc file, Minix-2.0.4-HD.bxrc:

    megs: 8
    romimage: file=$BXSHARE/BIOS-Bochs-latest, address=0xf0000
    vgaromimage: $BXSHARE/VGABIOS-elpin-2.40
    ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
    ata0-master: type=disk, path="Minix-2.0.4-HD.img", \
mode=flat, cylinders=81, heads=16, spt=63
    floppya: 1_44=floppya.img
    floppyb: 1_44=floppyb.img
    boot: disk
    log: Minix-2.0.4-HD.log
    mouse: enabled=0

Create a tarball

Create a tarball of the new bochsrc and image file:

    tar cvzf minixfresh.tar.gz minix-2.0.4-HD.bxrc minix-2.0.4-HD.img
    cp minixfresh.tar.gz somewheresafe

Untarring (no need to do it now) the archive is as simple as:

    tar xvzf minixfresh.tar.gz

Should zip up to around 10 Megabytes (amazing, huh?).

Secure the OS – Just for Fun

Until you decide to become a Bochs master and hook up networking, which is not covered here, you probably need not be overly concerned with security. However, you should definitely not be logging in as root, because it’s too easy to muck things up. Minix provides a user called bin that is able to do many of the same things as root – see the documentation for a full description. I tend to create a regular user and su to bin and then, if needed, su to root to do those sorts of things.

Change the root password

1. Boot into Minix and login as root.

The command to set a password is passwd user, if no user is specified, passwd defaults to the current user. Since you are logged in as root, simply type ‘passwd’ and enter a decent password:

    passwd

Note: The root password is also the root of any users that have a group id of 0, such as bin, so changing the root password also changes it for bin.

Create a new user

1. Create a group for normal users:

    vi /etc/group

2. Add the line (9 is the next available group number):

    users:*:9:

Here’s a screenshot of vi /etc/group.

minix

Note: I could not find a groupadd, grpadd, addgroup, addgrp, or vigr command, so this is my approach – please let me know if there’s a better way…

3. Create a home directory to contain the all of the user’s home directories

    mkdir /usr/home

4. Add the user

    adduser usernamegoeshere users /usr/home/usernamegoeshere

5. Assign the user a password – give them a good password

    passwd usernamegoeshere

6. Log out and back in as the user

    exit
    noname login: usernamegoeshere
    password: userpasswdgoeshere

7. Shutdown Minix
8. Power off Bochs
9. Back up the image

The hard disk image now contains a working Minix installation that you can play around with to your heart’s content.

Stuff and Sundry

Time in Minix running on Bochs

Time is funny – fast, slow, where does it go? The Bochs emulator has a bug (feature?) related to it’s timing – time is faster in Bochs than in the outside world. What this means is that some time dependant processes complete much more quickly than they would in ‘real time’. From a practical standpoint, it means that if you take more than a couple of seconds to login, the system will think it has timed out. Thankfully Minix doesn’t have screen savers enabled by default. The solution to the login problem, sadly, is to type fast!

Shutting down Minix

It is absolutely critical that you use the command:

    shutdown -h now

This allows Minix to exit gracefully. I have not had good experiences with:

    halt
    or the three finger salute - ctrl-alt-delete

Powering off Bochs

Do not just exit Bochs, use the Power button.

Conclusion

I hope that this has been an interesting read and that you will give Minix a shot – whether on Bochs or in native mode. Please let me know what you think, constructive criticisms, if you please.

Email the author Will Senn

Resources

Andrew Tanenbaum’s Minix Site at vrije Univeriteit amsterdam
Al Woodhull’s Minix Site at Hampshire College
The Minix 2.0.4 manpages
Browseable Minix 2.0.2 Source Code
MINIX-L Mailing List, Join! We welcome all interested folks.
Read comp.os.minix on usenet
Operating Systems: Design and Implementation 2ed by Andrew Tanenbaum and Albert Woodhull
Email the author Will Senn

References

PearPC 0.1: Is It A Miracle?, Thom Holwerda, OSNews.com May 18, 2004
Is Torvalds really the father of Linux?, Stephen Shankland, CNET News.com, May 19, 2004
Some Notes on the “Who wrote Linux” Kerfuffle, Release 1.5, Andrew Tanenbaum, May 20, 2004
Ken Brown’s Motivation, Release 1.2, Andrew Tanenbaum, May 21, 2004


If you would like to see your thoughts or experiences with technology published, please consider writing an article for OSNews.

40 Comments

  1. 2004-06-08 6:18 am
  2. 2004-06-08 6:24 am
  3. 2004-06-08 6:26 am
  4. 2004-06-08 7:25 am
  5. 2004-06-08 7:48 am
  6. 2004-06-08 8:41 am
  7. 2004-06-08 8:53 am
  8. 2004-06-08 9:14 am
  9. 2004-06-08 9:34 am
  10. 2004-06-08 10:10 am
  11. 2004-06-08 11:17 am
  12. 2004-06-08 11:20 am
  13. 2004-06-08 12:11 pm
  14. 2004-06-08 1:05 pm
  15. 2004-06-08 1:33 pm
  16. 2004-06-08 1:43 pm
  17. 2004-06-08 2:57 pm
  18. 2004-06-08 3:17 pm
  19. 2004-06-08 3:57 pm
  20. 2004-06-08 4:05 pm
  21. 2004-06-08 4:19 pm
  22. 2004-06-08 4:37 pm
  23. 2004-06-08 5:21 pm
  24. 2004-06-08 5:30 pm
  25. 2004-06-08 5:38 pm
  26. 2004-06-08 5:50 pm
  27. 2004-06-08 5:53 pm
  28. 2004-06-08 5:55 pm
  29. 2004-06-08 9:35 pm
  30. 2004-06-08 9:43 pm
  31. 2004-06-08 10:03 pm
  32. 2004-06-08 10:16 pm
  33. 2004-06-09 9:30 am
  34. 2004-06-09 1:15 pm
  35. 2004-06-09 2:20 pm
  36. 2004-06-09 2:26 pm
  37. 2004-06-09 6:49 pm
  38. 2004-06-09 6:53 pm
  39. 2004-06-09 6:58 pm
  40. 2004-06-09 7:24 pm