Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!goanna!minyos!monu6!monu1!bruce!cechew From: cechew@bruce.cs.monash.OZ.AU (Earl Chew) Newsgroups: comp.os.minix Subject: Re: Minix 1.5 --> up Message-ID: <3130@bruce.cs.monash.OZ.AU> Date: 24 Sep 90 23:14:29 GMT References: <10936@life.ai.mit.edu> Organization: Monash Uni. Computer Science, Australia Lines: 156 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 ----------------------------------------------------------------------