                             MINIX BEDROCK
                             =============


INTRODUCTION -
------------
This is a quick distribution of the Minix 2 operating system by Andrew Tenenbaum.
Unlike the original, it comes in a single image.

WHAT IS MINIX BEDROCK? -
----------------------
Minix is a pedagogical operating system designed for teaching an OS course,
first developed in the 1990s. Despite being restricted in scope and suitable
for understanding by students, it's actually a surprisingly powerful and
thoroughly usable Unix clone; older versions will run in tiny amounts of RAM.
Their entire distribution, source code and C compiler included, will fit in
about 40MB of disk and it'll recompile its own kernel and userspace in 1MB of
RAM. (Slowly.) They'll run entirely off floppy disk. They'll even boot on an
original IBM PC with 512kB of RAM, although they're a bit cramped.

There are three versions. The current one is Minix 3, which was abandoned some
years ago. Minix Bedrock is my distribution of the older Minix 2.

Minix 2 gives you multi-user logins, all the standard UNIX tools, TCP/IP
networking, swap, a full Bourne shell, an ANSI C compiler, a Standard Pascal
compiler, a VI clone, an Pico clone, source for nearly everything, AWK, BC,
games, all the man pages, and huge amounts of other stuff. It's (almost)
completely self-hosted --- you can hack Minix on Minix. The maximum supported
amount of RAM is 64MB.

Apart from being interesting simply as works of software art, they work so well
they're actually useful on really old hardware; so, this distribution.

SKIP THE BUILD -
--------------
If you do not want to build the image yourself, you can download them from my
personal website[1] or copy them from my personal CD.

Once you have the file, decompress it and write it to the appopriate media;
then boot it in something.

WHAT'S HERE? -
------------
What you will find here is the contents of the last Minix 2 release, 2.0.4,
in the Standard and Small flavour, extracted so that they'll live in a standard user
directory, plus a set of scripts that will take the distributions and turn it
into a bootable Minix hard drive images. Minix is self-hosting, so we need to
bootstrap a Minix somehow to build it on.

You won't find *all* the source here, because Minix came with most source,
but not all; the C compiler is ACKPACK, a special version of the [Amsterdam
Compiler Kit](http://tack.sf.net), carefully cut down and modified to run on
Minix. Back when this was released, this wasn't open source.

Note: this is Minix i86. The largest binaries can get is 64kB+64kB. This is
restrictive compared to Minix i386, but it'll also build and run on machines
with as little as 1MB of RAM, which is the main case I'm interested in.


INSTRUCTIONS -
------------
You will need a Linux machine and `qemu-system-i386` and `rsync`.


-- Building and Booting --

Do:

  ./make.sh

This will rebuild all the installation images from the files in `fs` for both
versions.  (Alternatively, you can download these from the [release
page](https://github.com/davidgiven/minix2/releases/latest).)

  * `combo-1440kB.img.gz`, `combo-1200kB.img.gz`: combined root/usr floppy
    disk images. These contain a single filesystem with no division into root
    and usr. You can boot these. By default, the disk image will be loaded
    into a ramdisk to free up the floppy disk drive, but if you have less than
    about 3MB of RAM you should mount them directly; at the boot monitor prompt.
    hit ESC, then type `rootdev=fd0`, then `boot`.

  * `hd-64MB.img.gz`: is a bootable hard drive image containing absolutely
    everything; compilers, games, all the source code, the lot. Don't be put
    off by the size. Use this if you want to run Minix in a virtual machine.

  * `root-720kB.img.gz`, `usr-720kB.img.gz`: split root and usr floppy disk
    images. A 720kB floppy isn't big enough for the combined disk, so you need
    to boot the root disk, let it load itself into a ramdisk, and then it'll
    prompt you to replace the floppy with the usr image. It'll ask for a device;
    you want `/dev/fd0`.


-- Installing onto a Hard Drive --

Once you have a floppy based system booted, you want to copy Minix onto your
computer's hard drive.

The detailed instructions are long and complicated, but the short version for
Minix 2 is to log in as root, and then:

  part

...is the partition editor; the Minix partition type is 81. If you have less
than 4MB RAM, create a swap partition (of about 4MB). You'll probably want to
reboot (Minix sometimes forgets to reload the partition table). I'm going to
assume you have the swap in `/dev/c0d0p0` and your filesystem in
`/dev/c0d0p1`. Don't make your filesystem too big; 64MB is probably as large
as you want.

To mount the swap:

    # mkswap /dev/c0d0p0  # controller 0, drive 0, partition 0
    # mount -s /dev/c0d0p0

To create the filesystem and copy all the data:

    # mkfs /dev/c0d0p1
    # mount /dev/c0d0p1 /mnt
    # cpdir -vx / /mnt/
    # cpdir -vx /usr/ /mnt/usr/   # only if you're using the usr-720kB floppy
    # echo "root=c0d0p1" > /mnt/etc/fstab
    # echo "swap=c0d0p0" >> /mnt/etc/fstab   # vi is also available
    # umount /dev/c0d0p1   # note that you use a device name here, not a path

To make the hard drive bootable:

    # installboot -m /dev/c0d0 /usr/mdec/masterboot
    # installboot -d /dev/c0d0p1 /usr/mdec/bootblock boot
    # edparams /dev/c0d0p1
    c0d0p1> rootdev=c0d0p1
    c0d0p1> save
    c0d0p1> exit
    # shutdown -h now

...then reboot. Hopefully your new system will boot.

HACKING -
-------
If you just want to fiddle with it, or do builds, then do this:

  ./make.sh -f regular # or small

...and it will create an `hd.img` file, similar to the `hd-64MB.img.gz` one
above. It's also lightly massaged for use as a build box, so when it boots
it'll take you straight to a shell, etc. This then allows you to then do:

  ./runqemu.sh

That will run QEMU and you should see Minix boot. It'll take about a second.

Once you've finished working with Minix, exit the shell with ^D. It'll shut
down cleanly. Then you kill the qemu window (sorry, Minix doesn't know how to
tell qemu to shut down!) and then you can do:

  mount -o offset=512 hd.img /mnt

...and you can now copy files to and from the image.

REFERENCES -
----------
  * The official upstream source with downloads of all versions of Minix, including
    these: http://wiki.minix3.org/

The included HD image contains a blank filesystem with a preinstalled version
of Boot 2.19 in a single bootable partition.

COPYING -
-------
Minix 2 is licensed with BSD 3-Clause. Everything else is dedicated to the
public domain.

[1] http://stone.local/releases/
