ECS150 Course Website

last updated
Using Minix

Installation

CSIF Installation

To install Minix on the CSIF lab computers, see the document "A Document about Minix on Bocks/Linux by Andrew Wong". You can find the downloads necessary at http://wwwcsif.cs.ucdavis.edu/downloads/.

Bochs is already installed on the CSIF computers. However, you *may* not have enough space to download and uncompress the Minix and virtual floppy images. If this happens, please contact myself, Dr Levitt, or CSIF support so we can quickly address this issue.

Home Linux Installation

To install Bochs and Minix on your own Linux computer, see pages 6 and 7 of "A Document about Minix on Bochs/Linux by Andrew Wong". You should be able to download all the necessary files from http://wwwcsif.cs.ucdavis.edu/downloads/.

Home Windows Installation

To install Bochs and Minix on your own Windows computer, please see this online guide.

Mounting

Instructions on how to mount the physical and virtual floppy drives under Minix can be found towards the bottom of the "A Document about Minix on Bocks/Linux by Andrew Wong" document. You must learn how to at least mount the virtual floppy drive to hand in programming assignments. Also, it is highly recommended you back up your files to the virtual floppy. With the modifications you may be making to the Minix kernel, it is likely you may have to reinstall Minix (and thus will lose any files not backed up to a physical or virtual floppy).

Remember, you MUST mount the virtual floppy before saving any files to folder fd1. Otherwise, you are just saving to the fd1 folder under Minix, but not the actual virtual floppy. You may want to add the line:

mount /dev/fd1 /fd1

to your .profile file in Minix. This will mount the virtual floppy for you every time you login to Minix. Also, don't forget to unmount the drive when you are done!

There are shortcuts for mounting and unmounting floppy drives. They are as follows:

commandshortcutdescription
mount /dev/fd0 /fd0M 0mount physical floppy drive
umount /dev/fd0U 0unmount physical floppy drive
mount /dev/fd1 /fd1M 1mount virtual floppy drive
umount /dev/fd1U 1unmount virtual floppy drive

Shutting Down Minix

Several people have corrupted their Minix installations by not shutting down Minix properly. If you are getting file system checks every time you start Minix, then you are most likely not shutting down properly. This will eventually lead to problems. To shutdown, you first want to type the command:

shutdown

in Minix, and then hit the power-off button. (Dont forget to unmount any mounted drives first!)

Editors in Minix

The following is a list of editors compiled from the 'Text Editors' post on the newsgroups, and the Minix website.

  • elvis (emulates vi and ex)
  • elle (similar to emacs)
  • mined (minix editor)
  • ed (simple editor)

For more information on these text editors, please refer to the man pages.

Running Executables

Suppose you compiled a file and now have an executable called a.out. If you just try to enter a.out at the shell prompt, you will get a message like "a.out: No such file or directory". This is because the current directory is not part of the PATH variable. Therefore, to run a file like a.out we would actually have to add a ./ to the front of the filename. For this example, we would have to enter ./a.out at the shell prompt.

It is possible to add the "current directory" to the PATH variable. The command to do this is:

export PATH=$PATH:.

Doing this will allow you to enter a.out at the shell prompt without any problems. Below is an example illustrating this (where # and * are shell prompts):


 Minix  Release 2 Version 0.3

 noname login: root
 # cd test/
 # ls
 test.c
 # cc test.c
 # ls
 a.out   test.c
 # a.out
 a.out: No such file or directory
 * ./a.out
 hello world!
 # export PATH=$PATH:.
 # a.out
 hello world!
 #

Customizing Minix

The .profile file in the root directory contains commands that are run on startup. It is sometimes useful to edit this file and add a few commands. Below is a sample .profile file with two customizations:


 # Share the .profile of bin.
 test -f /usr/src/.profile && . /usr/src/.profile

 # Add current directory to path.
 export PATH=$PATH:.

 # Mount virtual floppy image
 M 1

If you choose to use vi to write your programs, you can customize a few settings by editing the .exrc file in the root directory. For example, set nu turns on line numbering. Below are some example customizations:


 set autoindent autowrite report=2 showmatch

 set nu
 set sw=4
 set ts=4

There are many vi references on the Internet with different settings you can change. However, since vi in Minix is actually a vi-clone, not all settings will work.

Transfering Files To/From Minix

Transfering files to and from Minix under Bochs is not trivial. In most cases, you *must* have a physical floppy drive present. Below are instructions on how to get files off of Minix:

Linux Systems

  1. Mount a Minix-formatted floppy under Minix. For instructions, see this document (instructions towards the end of the document).
  2. Copy your files to the floppy disk using cp <filename> /fd0
  3. Unmount the floppy drive using umount /dev/fd0 and shutdown Minix
  4. On your Linux system, mount the floppy
  5. Copy files from floppy onto hard drive

Windows Systems

  1. Place a DOS-formatted floppy in the floppy drive
  2. Start Minix. Mmake sure the A: icon is not crossed.
  3. Copy your files to the floppy using mtools copy <filename> a:/
  4. Shutdown Minix
  5. On your Windows system, access the floppy drive
  6. Copy files from floppy onto hard drive

No Physical Floppy

If you do not have a floppy drive, you can try the following method:

  1. Mount the virtual floppy drive in Minix (mount /dev/fd1 /fd1)
  2. Copy your files to the virtual floppy using cp <filename> /fd1
  3. Unmount the floppy drive using umount /dev/fd1 and shutdown Minix
  4. Open floppy.img in a text editor (like vi or WordPad)
  5. Locate your code in the floppy image
  6. Copy-paste your code to a new file

This method is not reliable - and it is often times quite difficult to locate your code within the floppy image.

Recompiling the Kernel

To compile the kernel, do the following commands in Minix. (Note: This may take awhile...)

cd /usr/src/tools/
make hdboot
sync
shutdown

The next time you boot Minix, it should boot to the new kernel.

Note: Last quarter there were some problems when recompiling the kernel. One problem was new changes would not be reflected in the new kernel. If you encounter this problem, there are a few things you may try. The first of these is to run make clean before compiling. The sequence of commands will be:

cd /usr/src/tools/
make clean
make hdboot
sync
shutdown

If this does not remedy the problem, try the following:

rm /minix/2.0.3r*
rm /usr/src/tools/image
cd /usr/src/tools/
make clean
make hdboot
sync
shutdown

Note: It is possible that the new kernel you compiled will not boot (depending on what changes you made to the kernel). In this situation there are two things you may try.

Method 1: Reload Minix with a fresh image. This is the easiest method of getting back up and running - but you will lose any files that were not backed up to floppy. To do this, just redownload minix203.img.

Method 2: Boot to original Minix kernel. This will preserve your files, but may not always work. To do this, follow the steps below:

  1. Startup Minix under Bochs - but do NOT press = to boot Minix.
  2. Press ESC to enter the boot monitor.
  3. Type image=/minix/2.0.3 and press enter.
  4. Type boot and press enter.

This should boot Minix using the original kernel, allowing you to fix any changes you made to the kernel and backup your files.

Helpful Tips & Hints

There are various helpful tips that may make using Minix slightly easier. They are listed below:

  • CPU Usage. Running Minix on Bochs seems to use up 100% of the CPU on some systems. If you are using Bochs/Minix on a laptop, you may want to bring along your powercord (since this tends to ware down battery very quickly).
  • DEL Key. If your programs on Minix get into an infinite-loop, press the DELETE key to send a kill signal.
  • C Comments. Since Minix uses an older c-compiler, you must use /* */ style comments in your code. Comments starting with // will result in compile errors. Also, comments may not be nested.
  • C Variables. Since Minix uses an older c-compiler, all variables must be declared at the start of a block. Otherwise you will get a compile error.
  • Snapshots. Notice that you can not copy-paste text from the Bochs/Minix window? To grab text being displayed, click the "Snapshot" button. That will copy all the text from the screen to a file. See the Bochs User Guide for more information.
  • Background Processes. To run a process in the background, add an & at the end of the executable name before running. For example, to run a.out in the background, type a.out&.
  • Switching Consoles. To switch between two different consoles, press either ALT+F1 or ALT+F2.