[comp.os.minix] Minix 1.5 --> up

cracraft@ai.mit.edu (Stuart Cracraft) (09/24/90)

I changed my opinion after installing Minix 1.5 on a
Toshiba 5100 laptop. The distribution finally arrived
from Prentice Hall after tremendous delays. I had 
received and installed 1.3 and found it lacking; 
however, after putting up 1.5, it is clear that Minix
wins -- BIG.

My partitioning has about 40mb on partition 1 (/dev/hd1)
for DOS, 57mb on partition 2 (/dev/hd2) for /usr and
user directories, and 3mb on partition 3 (/dev/hd3)
for root on a ram disk of the same size.

My only two problems were really related to DOS and
shoelace rather than Minix. After separating the 
partitions with Minix fdisk, I found the DOS partition
couldn't readily be installed. All sorts of weird root
director entries upon restore, Norton couldn't fix
it with Disk Doctor, and so forth. When I did the fdisk
on the DOS side and repartitioned only the DOS partition
with it, leaving the other partitions intact, it worked.
Minix reported a "-" at the end of the DOS partition
line in Minix fdisk, so maybe it had to do with the even/odd
partition size. Earlier I had made an even-only partition
size believing that would work.

The other problem had to do with shoelace. I installed
it fairly readily but then probably botched the two
calls to 'laceup' in order to install the boot strap.
Also, the presence of the ram disk image on the hard disk
confused me and I may not have selected the proper
partition. Chew may have a reply to this, but I'm sure
that part was my misreading of his documentation, not
the fine code he's made available.

Minix 1.5 is well-documented with extended manual pages,
easy installation, and fast protected-mode running.
Building a kernel is trivial, surprisingly so. My only
nit so far is that the "term" command is minimal. For
terminal communication with the outside world, it's an
important command. I'll try to improve it for myself and
if useful return the mods to AST.

Well, that's the report from Chaos Manor Minix. Minix
1.5 up on a 386, pre-shoelace, pre-Evans, but running
great.

Stuart

cechew@bruce.cs.monash.OZ.AU (Earl Chew) (09/25/90)

In <10936@life.ai.mit.edu> cracraft@ai.mit.edu (Stuart Cracraft) writes:

>The other problem had to do with shoelace. I installed
>it fairly readily but then probably botched the two
>calls to 'laceup' in order to install the bootstrap.
>Also, the presence of the ram disk image on the hard disk
>confused me and I may not have selected the proper
>partition. Chew may have a reply to this, but I'm sure
>that part was my misreading of his documentation, not
>the fine code he's made available.

It seems that most people have some trouble with getting Minix running to their
satsifaction on their hard disk. I posted a `How to Do It' message yesterday
and don't intend to repeat it now. Stuart does mention another point about
confusion about the ram disk image on the hard disk. With shoelace, the ram
disk image becomes optional. You can nominate where your root device will be
(/dev/hd2, /dev/ram, etc). You can nominate where you want the ram disk to be
loaded from (/dev/hd3, /dev/fd0, etc). My hard disk system no longer has a ram
disk. I have two partitions only: DOS and Minix. I set root to be /dev/hd2 and
the ram disk size to be zero. The /dev/hd3 business for Minix is a kludge.
Perhaps it's time for another tutorial...

Earl

-------------------------------------------------------------------------------
1. The BIOS

When the computer is restarted, the CPU is preset to begin execution from a
region in high memory. This is where the BIOS lives, and it is the BIOS that
takes control. After mucking around a bit to do things like memory tests, the
BIOS tries to find a bootable device. It will typically try floppy drive 0 then
hard disk drive 0.

2. Floppy Structure

For the purposes of booting, a floppy disk looks like this:

           +-------------+
Sector 0   | Boot Sector |
           +-------------+   Diagram 1
Sector 1   |             |
	   :    Rest     :
	   +-------------+

3. Hard Disk Structure

For the purposes of booting, a hard disk looks like this:

           +-----------------+
Sector 0   | Partition Table |
           +-----------------+   Diagram 2
Sector 1   |                 |
	   :      Rest       :
	   +-----------------+

The partition table holds a table which records information about each partition
on the hard disk. The information includes such things as starting location,
ending location, size, and type. It is easiest to regard each partition as a
gigantic floppy. For the purposes of booting, each partition looks like this:

                   +-------------+
Logical Sector 0   | Boot Sector |
                   +-------------+   Diagram 3
Logical Sector 1   |             |
	           :    Rest     :
	           +-------------+

Note that adding the starting location of the partition to the logical sector
number yields the physical sector.

4. Boot Code

Notice the similarity between diagrams 1 and 2. This is intentional. When
attempting to boot any device, the BIOS simply reads the data/code in sector 0,
and executes it. Thus, on the hard disk, not only is the partition table
information kept in sector 0, but also the code to boot the OS in the required
partition.

Now notice the similarity between diagrams 1 and 3. Apart from the logical
sector to physical sector translation that must occur, the structure is
identical.

5. Standard Minix Boot

The standard Minix bootstrap is *always* floppy based. A special boot floppy is
always required (refer to diagram 1). The code that lives in sector 0 of this
boot floppy can be found in /usr/src/tools/bootblok.s. build.c is the program
that is used to construct this boot floppy. It copies bootblok.s into the boot
sector, then fills the rest of the floppy with the image of the kernel.

When the floppy disk is bootstrapped, the code in the boot sector reads the
kernel into memory and executes it. All other boot time behaviour (clearing of
the screen, printing ram disk statistics, etc) is done by Minix during its
start up phase. This includes filling of the ram disk and hard disk "boot"
support. Minix will set the root device to /dev/ram and will fill the ram disk
with data from either the floppy disk or from /dev/hd3.

The primary advantage of this approach is that it is easy to program. Problems
with this approach are:

      1. The boot floppy does not have a valid file system (neither DOS nor
	 Minix). It is annoying to maintain a floppy that you can't get
	 directories of.

      2. Booting requires 3 parts:
	      a. A boot floppy
	      b. A ram disk image
	      c. A /usr disk

6. Shoelace Floppy Boot

Shoelace permits the boot floppy to contain a valid Minix file system (much
like a DOS boot floppy contains a valid DOS file system). Thus to create a
Minix boot floppy with shoelace, you would first use mkfs to create a valid
file system on the floppy. The floppy must contain the image of the kernel, but
you can use cp to copy across the a.out file components of the kernel, viz.
kernel, mm, fs and init. This is covered in more detail in the documentation
for shoelace.

Referring to diagram 1, the rest of the floppy now holds a valid Minix file
system containing the kernel image. Laceup is used to write a special boot
sector onto the floppy disk.

When the disk is bootstrapped, the boot sector code loads and executes
the file named /shoelace. Shoelace locates and loads the Minix kernel
components and starts Minix.

Because the floppy now contains a valid file system, shoelace permits you
to nominate your root device (eg /dev/hd2 or /dev/ram). If you nominate
/dev/ram, you can also nominate where you would like the ram disk to be loaded
from (eg bootdev, /dev/hd3, /dev/fd0).

7. Shoelace Hard Disk Boot

The second part of the hard disk boot proceeds as for the floppy boot because
each partition is considered to be a gigantic floppy disk. Thus the code
remains exactly the same.

The first part of the hard disk boot uses the partition table. Laceup is used
to install winiboot which replaces the boot code in the partition table area.
Winiboot permits you to select which partition (either DOS or Minix) you wish
to boot. Once the selection is made, the logical boot sector is loaded and the
process proceeds as for a floppy boot.

8. Lies

In conclusion, it should be noted that I have lied about the Minix file system
structure. Minix leaves a boot block (1kb) not a boot sector (0.5kb) at the
head of the floppy disk or hard disk partition. The descriptions above are
still valid.

Earl
-- 
Earl Chew, Dept of Computer Science, Monash University, Australia 3168
EMAIL: cechew@bruce.cs.monash.edu.au PHONE: 03 5655447 FAX: 03 5655146
----------------------------------------------------------------------

al@escom.com (Al Donaldson) (09/26/90)

In article <3130@bruce.cs.monash.OZ.AU>, cechew@bruce.cs.monash.OZ.AU (Earl Chew) writes:
> Perhaps it's time for another tutorial...

Good job.  What the tutorial shows is that hard disk booting is not
*necessarily* all that complicated.

My main criticism of the Shoelace package is its size -- as I remember, 
it is larger than FS.  I found it hard to "get my head around" the package.  
Part of the problem was that I needed to make changes to the boot package
to support a different file system layout, and Shoelace was so big
that I couldn't figure out what needed to be changed.

There is an alternative hard disk boot package for MINIX.  Glen Overby 
mailed this package to the beta mailing list earlier this year.  
Unfortunately, I (and the other members of the beta group) didn't give
Glen the positive feedback that his package deserved, so I don't think
he ever posted it to comp.os.minix.

Glen's package consists of two small programs (40K bytes of source) plus 
some manual procedures that can be put in tools/Makefile:

1. first stage loader.  Glen used the mfdisk program by Motti Bazar
   to write a new boot sector (saving your existing partition table)
   on your first hard disk drive.  When your machine boots, this code
   prompts for the number of the boot partition (1-4) and reads in
   the partition's boot sector.  On my system I type "3=" to boot MINIX
   or "1" to boot DOS.

   The mfdisk program source is 18K bytes of heavily commented Microsoft
   assembly and a corresponding .COM file (so you don't have to build it 
   under MASM).  I consider it "ugly" that you need to run it under DOS, 
   but you only run the mfdisk program once.  (The first stage boot loader 
   that it builds is independent of any operating system -- consider it
   firmware.)

2. second stage loader.  Glen's program is designed to fit in the boot 
   block of a hard disk partition or floppy disk.  It looks for a file
   in the root partition named "boot" and executes that file.  

   The loader source is about 22K bytes of well commented .ASM code and
   a uuencode'd binary.  You only need to worry about assembling this 
   code if you want to make changes to it. 

   One of the changes I made was to make a bootable diskette loader.
   You can do this by changing a variable and re-assembling, or perhaps
   by patching the binary.  It may sound silly to talk about going back 
   to booting from diskettes, but I've made a bootable miniroot that fits 
   easily on a 1.2 meg diskette and contains everything necessary to do 
   a hard disk installation.

3. manual procedures.  I've put these procedures in tools/Makefile so
   all I have to do when I change FS:MM:kernel is to "make hdboot".

   The first step you need to do is copy the loader binary to the boot
   block on your MINIX root file system:

	dd if=loader of=/dev/hd3

   You need to create the file /boot on your root partition.  To make
   life as simple as possible, Glen uses the tools/image file built
   when you "make image".  He uses dd to strip off most of the diskette
   boot sector:
   
	dd if=image of=/boot bs=496 skip=1

That's pretty much it.  Unless you need to reassemble the code for some 
reason, the binaries seem to work "right out of the box."  I've run this
on a 6 MHz AT, a Zenith TurboSport 386 portable, an AST Research 386,
and various other machines.  

I don't like having to build this under MASM, but them's the breaks.  
A consultant I work with has converted the loader program to ASLD, but 
the .ORG bug (I posted this a month ago, but no one had a solution)
prevents this from working properly.

I'd like to encourage Glen to post his package.  However, the last I
talked to Glen, he mentioned that he was running Shoelace. :-)
I think Glen's package is preferable, if for no other reason than simplicity.  
As some famous person once said, "Everything should be made as simple 
as possible, but not simpler."

Al Donaldson

PS - Please don't contact me for Glen's source.  We've made changes to
the code in order to support a different file system, and I have no idea
if I still have Glen's original mailing.