setup_hd.txt This document describes setting up a hard disk system under MINIX version 1.1. I have obtained this information through my own experience, the comments of other people in the MINIX Study Group, and USENET transmissions in comp.os.minix. This information is intended to supplement the information found in the text, "Operating Systems Design and Implementation" by Andrew S. Tanenbaum (Prentice Hall, 1987) and the file READ_ME found on the MINIX distribution diskettes. Disclaimer: Although the information in this document is correct to the best of my knowledge, I assume absolutely no responsibility for the accuracy of any part of this document. You are completely responsible for any and all consequences that may result from use of this information. Distribution: This document may be freely distributed and modified by anyone as long as the header information above is included, the modifications are clearly noted, and the distribution list just below is maintained. Originally distributed to Public Domain Software Exchange, Sunnyvale, CA (data: 408-735-7190) 26 July 1987 by Henry Neugass (voice: 415-962-9610). ----------------------------------------------------------- Overview -------- MINIX may or may not be installable on your PC or AT hard disk drive. It is possible that known patches or the new MINIX hard disk driver will solve some installation problems; however, it is tedious and awkward to rebuild the system to incorporate these changes without a functioning hard disk sytem. Listing which systems work and which don't is difficult because of the many possible configurations. The determining factor appears to be the hard disk controller board, that is, the similarity of your to the "standard" XT or the "standard" AT controller. (A PC with PC-II ROMs is lumped with XT's for these purposes.) Here is some experience that people report: * Many XT hard drives don't function with MINIX at all. Third- party disk subsystems appear to vary widely. Some symptoms of failure are: Š --MINIX won't boot, even as a floppy-only system until the hard disk is physically removed from the system. --MINIX will boot, but the hard disk activity lamp lights simultaneously with the boot floppy drive lamp. When this happens, the boot may fail. Checking the nonexistant hard disk file system several times before mounting the root file system diskette seems to increase the probability of success. (This is admittedly superstitious.) --MINIX will boot and run correctly as a floppy-based system. However, the hard disk will not respond. --MINIX will boot and run correctly as a floppy-based system. However, attempting to build a file system on the hard drive fails, or fails above a certain size. If a file system can be built on the hard drive, the system may generate a large number of often-cryptic error messages during accesses to the file system. * AT systems won't boot PC/XT distribution diskettes, even though they can read them. (They can also write them, subject to the known uncertainties of recording 360 Kb diskettes on a 1.2 Mb drive. Best to have a 360 Kb diskette drive on your AT for this.) * AT clones are generally more compatible with respect to hard disks than IBM AT's ("Tanenbaum's Paradox"). This said to be due to a mid-production manufacturing change in the IBM AT hard drive controller. * There are reports that unusual drive types may give difficulty, even if the controller is compatible. Under DOS (on the AT, at least) disk type information is stored in battery-backed up CMOS RAM to account for variations, for example, in the number of heads. * Hard disk partitioning on both AT and XT models is often difficult. Even if everything works, it is often difficult to get exactly the partition you want for MINIX in terms of size or order. Very large disks have been reported as difficult to partition. The DISKFIX utility supplied with MINIX is very primitive, and the DOS FDISK utility is little better. (Note: at least two partition editors--of unknown quality--have been distributed recently.) * There presently is no way of backing up your hard drive even if it works. The "tar" supplied will fill one diskette and stop. (Someone is reportedly working on a multivolume version.) In sum, there is really no way of knowing beforehand if your hard disk system can be used with MINIX successfully. (There is a bias here that assumes that most people don't have Šthe patience to do anything significant with MINIX unless they have a functioning hard disk system. If you disagree with this bias, try something like rebuilding the the kernel and writing it to the boot diskette without a hard disk.) ----------------------------------------------------------- Preparation ----------- To set up your hard disk under MINIX, prepare as follows: 1. Backup your hard disk drive if there is anything valuable on it. It is USUAL to wipe out the entire disk during this process. T H I S C A N N O T B E O V E R -- E M P H A S I Z E D. 2. Write-protect your MINIX diskettes. Make and use copies if at all possible. (Some versions of DOS will not DISKCOPY non-DOS diskettes. A DOS utility to solve this problem may soon be available. A short-term workaround is described further below.) 3. Boot MINIX, and locate the file /doc/READ_ME. (The location varies with the distribution format.) Read the file; if you have a parallel printer, you may be able to print a copy. Alternatively, use DOSWRITE to move a copy to a DOS diskette and use your DOS facilities to examine and print it. 4. Obtain a copy of "diskfix.asm" from your MINIX diskettes. (The location varies with the distribution format). Move a copy to DOS using DOSWRITE. Under DOS, assemble and link diskfix, but don't execute it yet. Also prepare an executable variant of diskfix called "pfix.asm" as follows: diskfix pfix ------------------------------ ----------------------------- change proc near change proc near ... ... cmp al,DOS_TYPE cmp al,MINIX_TYPE ... ... mov byte ptr [di],MINIX_TYPE mov byte ptr [di],DOS_TYPE ... change endp change endp As supplied, "diskfix" sets DOS partitions to MINIX partitions. The new program, "pfix," sets MINIX partitions back to DOS partitions. If you make a mistake during partitioning and need to delete a partition, you will find that FDISK will fail to delete a non-DOS partition. (Somå  versioî oæ FDISË wilì deletå á noî-DOÓ partition® Iæ  yoõ havå sucè á version¬ yoõ wilì noô neeä tï creatå pfix.) Š 4. Make a DOS "Transition Diskette" containing at least: a. system files (i.e., must be bootable) b. command.com c. chkdsk.com d. restore.exe e. diskfix.exe f. pfix.exe g. fdisk.exe h. format.com i. debug.com Write-protect this diskette. Check it to make sure that it boots. 5. Format some diskettes using DOS FORMAT. It is a good idea to have at least 5 formatted diskettes available, just in case. Note: MINIX uses the physical formatting only. All information placed on the diskette, like the directory or system files, will be overwritten. You may use either 360 Kb or 1.2 Mb diskettes with an AT, since MINIX figures out which is present. 6. Decide how you want to partition your hard disk. The recommended minimum MINIX partition, according to Tanenbaum, is 5 Mb. (This seems reasonable, if a little cramped, in practice.) This discussion assumes that you want to divide a disk between DOS and MINIX only. The presence of a third partition confuses the issues and is not recommended. Consider using the first partition for DOS. It seems that it is more difficult to install MINIX on the first partition, due to the difficulty of accounting for one extra sector at the start of the disk. (This sector contains the partition table.) On a AT-type 20 Mb hard disk, the following are examples of failure and success: 154 cylinders -- MINIX, partition 1, starting at 0 (FAILS) 460 cylinders -- DOS, partition 2, starting at 154 460 cylinders -- DOS, partition 1, starting at 0 (OK) 154 cylinders -- MINIX, partition 2, starting at 459 It is helpful to know how many heads your disk has so that you can verify your MINIX file system size. On AT-type systems, you may often find this out from the configuration or set-up program. (The information is also available via ROM BIOS Int 13h as follows: mov ah,08h ; return drive parameters mov dh,080h ; first hard drive--081h for second, etc int 13h ; ROM BIOS ; dh = maximum head# value 7. MAKE SURE YOUR HARD DISK IS BACKED UP. 8. Boot the transition diskette and run FDISK. Review the current configuration of your hard disk. This discussion assumes that you are starting from a disk that is unpartitioned. Delete all partitions. To remove non-DOS partitions, run PFIX. When you rerun FDISK, you will find that all partitions are marked "DOS." To use PFIX: A>pfix 0 /* for drive C: */ A>pfix 1 /* for drive D:, etc. */ 9. Use FDISK (on the Transition Diskette) to create a DOS partition of the size you want for MINIX. As recommended above, it seems best to avoid starting this partition at cylinder 0. Make sure you record the size of this partition. 10. Use CHKDSK (from the Transition Diskette) to verify that the DOS partition is the size you want for MINIX. Compare the total disk size given by CHKDSK with the size you selected in FDISK. They should be equal. You will need the size value later on. 11. Run FORMAT to format this partition. FORMAT apparently works only on the active DOS partition. (It is probably unwise to depend on this). This step assures that you are starting fresh in the MINIX partition. 12. Use DISKFIX to change that partition to non-DOS, specifically to MINIX-type: A>diskfix 0 /* for drive C: */ A>diskfix 1 /* for drive D:, etc. */ 13. Use FDISK to verify that the partition is now marked non- DOS. 14. Use FDISK to create a new DOS partition, and make it active. Usually this partition will comprise the balance of the disk. This is your new DOS partition. 15. Use CHKDSK to check that the DOS partition is the size you intended. 16. Use FORMAT to format the hard disk with system files: A>format c:/s /* for drive C: */ A>format d:/s /* for drive D:, etc. */ 17. Attempt to boot from the hard disk. (Remove the Transistion Diskette.) MSDOS should come up normally. You may restore your DOS files at this point, but is often advisable to wait until you are certain that the MINIX partition works. (If it does not, you may want to repartition the disk to DOS-only use and you will have to restore again.) 18. Insert the MINIX Boot Diskette. Reset (ctrl-alt-delete) to boot MINIX. Login as the superuser. 19. Figure the size, in K bytes, of the MINIX partition. It is helpful to figure this directly from the number of cylinders, if you know how many heads your hard drive has. For example, for a nominal 5 Mb partition: n_cylinders x 4 heads/cyl x 17 sec/cyl 154 x 4 x 17 = 10472 sectors = 5236K In theory, you should subtract 1 if MINIX is the first partition, to account for the sector containing the partition table, but this is an obscure issue. 20. Locate and mkfs, for example, as follows: # /usr/bin/mkfs /dev/hd2 5236 This makes a file system on the second partition of the first hard disk drive. If this step generates no errors, you will probably have no trouble with MINIX on your hard disk. Otherwise, either you have made an error up to this point, or your system is not sufficiently compatible. Note carefully: /dev/hd0 refers to the entire, UNPARTITIONED 1st hard disk /dev/hd1 refers to the first partition of the 1st hard disk /dev/hd2 refers to the second partition 21. Mount the hard disk: /etc/mount /dev/hd2 /usr "/usr" is the right place for the hard disk because many files are expected to be found there. 22. Run df to check space on the hard disk: df /dev/hd2 The "used" + "free" values should equal the MINIX partition size ----------------------------------------------------------- System Configuration -------------------- This following recommendations are intended to reduce dependence on the ram disk and diskettes. The examples given are for an AT system. The procedure for PC-types will vary somewhat. Assumptions: * your hard disk partitioned as described above. * you have at least 5 Mb hard disk storage assigned to MINIX * your want to use MINIX for development * you are logged in as super-user * you know the correct way to shut down the system * you have write-protected all the distribution diskettes Note: Some AT's cannot copy the distribution diskettes. This procedure builds new diskettes to replace distribution media. 1. Mount the hard disk, if it is not already mounted: # /etc/mount /dev/hd2 /usr 2. Make a directory on the hard disk for yourself. By convention, its name is . # mkdir /usr/ 2. Mount the "/usr+/user" floppy (#3): # /etc/mount /dev/at0 /user 2. Make new directories in /usr (hard disk) for each of those in /user. Copy the contents to the corresponding directory. The following transfers are recommended: AT floppy3: to hd: /user/bin/* /usr/bin /user/doc/* /usr/doc /user/lib/* /usr/lib /user/lib/* /usr/lib /user/ast/* /usr/ e.g., # mkdir /usr/bin # cp /user/bin/* /usr/bin You may also copy the directories /user/commands and /user/test but these are less important right now. The contents of "ast" will be the prototype for your home directory. 3. Now set the path: PATH=/bin:/etc/:/usr/bin This will eliminate some extra floppy accesses. Make sure "PATH" is all upper-case. 4. Unmount the current diskette, and mount the tools diskette: # umount /dev/fd0 # mount /dev/fd0 /user Make a directory /usr/tools and copy /user/tools/* and /user/tools/MINIX/* to it. Then unmount the floppy and remove it. Some of the procedures given below assume that /usr/tools has been configured this way. ----------------------------------------------------------- Making Boot Diskette -------------------- This section describes how to make a new boot diskette. This is in case your AT (under MSDOS) won't copy the distribution disks. This method uses the "make" option described in the text, page 430. 1. Change directory to /usr/tools. Enter # make build This will result in a "up to date" message, in which case everything is fine, or a compile ("cc") step. If the compile fails, you may have to clear some space on the root. Try removing /doc/READ_ME and moving all of /bin to /usr/bin. The executable file "build" is required to build the boot image. 2. Make dummy files "fsck.s" and "init.s" as suggested. (If they are not found, "make" will misguidedly try to create them. Here is a simple method: # cat > fsck.s this is dummy text # cp fsck.s init.s Check the dates of "fsck," "fsck.s," "init," and "init.s": # ls -l fsck* # ls -l fsck* If the date of "fsck" is before that of "fsck.s" or the date of "init" is before that of "init.s" then "make" will try to use the dummy files to rebuild "fsck" or "init." Prevent this by: # touch init # touch fsck This makes sure the dates are in the right order. 3. Create the boot diskette as directed by the text: # make image Follow the directions given. Test the resulting diskette as soon as possible. If it works, put away the original for safekeeping. ----------------------------------------------------------- Making Root File System Diskette -------------------------------- This section describes how to make a new root file system diskette. This is in case your AT (under MSDOS) won't copy the distribution disks. This procedure is also useful in case you want to reduce the contents of / (the ram disk) because you have copied the files to /usr (the hard disk). It is recommended that you remove as much as possible from the ram disk to facilitate development options. If there is not enough space on the ram disk, large compile or assembly+load steps will fail. 1. Dismount the floppy, change to /user/tools, and copy the prototype file for the ram disk: # umount /dev/fd0 # cd /user/tools # cp proto.at.ram proto.root 2. Now edit the new file "proto.root" to make it conform to the current situation. # mined proto.root 3. The source paths of each file to put on the root file system are at the right end of many of the lines. Changes these paths so that cp getlf sh synch are taken from "/bin" mount umount update are taken from "/etc" passwd rc message ttys are taken from "/etc" e.g., the fifth line should read cp --755 2 1 /bin/cp 4. Very carefully, add the following line in the same group with "cp": login --755 2 1 /usr/bin/login 6. Now save the new proto.root, insert a blank formatted diskette and execute # mkfs /dev/fd0 proto.root You may use the "-l" option of mkfs and redirect the output to a file, but the map information is not very useful at this point. Evidently the "boot" string at the beginning of the prototype is ignored; this is not a boot disk. It may be possible to eliminate more of the contents of the ram disk (i.e. the root directory) by changing the file proto.root. The only limitation are programs that are hardwired to expect files there. Logout, reboot, and test this new root file system. If it works, put away the original for safekeeping. ----------------------------------------------------------- Customizing the System ---------------------- This procedure assumes that you have a copy of the root file system diskette, either via DISKCOPY (under DOS) or the procedure above. It assumes that you have created a directory for yourself on the hard disk, e.g. /usr/ 1. Login as super-user. Dismount the root file system floppy. 2. Set the path and mount the hard disk: # PATH=/bin:/etc:/usr/bin # /etc/mount /dev/hd2 3. This should be the last time you set these manually. Now edit the file psswd: # mined /etc/passwd add the following line to the end of the file: yourname::9:3:yourname LASTNAME:/usr/yourname:/usr/bin/sh Put your first and last name in. The string "yourname" should be the same as the name of the directory you created earlier in /usr. This string your initial password to "none", assigns you a unique uid of 9, puts you in group 3, sets your full name, sets your home directory, and sets your shell. Make life easier by giving the superuser your home directory and the standard shell. The result is the first line reads: root:AIOyvd8Ud0MX6:0:0::/user/yourname:/user/bin/sh 4. Save the file. Login under the new user name and run passwd. # su yourname $ passwd At this point "passwd" will instruct you. If this does not work, you may have entered a bad entry in /etc/passwd or you may not have a matching home directory. 5. Return to being superuser by pressing cntrl-d. Write-enable and mount the root file system diskette (not the original!) and copy the password file: # mount /dev/fd0 /user # cp /etc/passwd /user/etc/passwd 6. Edit /user/etc/rc. Replace the first 2 lines with the following one: mount /dev/hd2 /usr Change "user" to "usr" in what is now the second line. Change the path of "cat" to "/usr/bin/cat". The next time you boot up you won't have to mount the hard disk and you won't have to insert the /usr disk. (However, if you make a mistake in this file, you may put the system into a strange state--the superuser gains control without benefit of a password if the file "rc" has an error in it.) 7. Follow the instructions in READ_ME section 13, to protect against hangs due to nonexistent devices, and to protect from doing i/o on the non-MINIX partition: # cd /user/dev # mv at1 at1_NONEXIST # mv fd1 fd1_NONEXIST # mv hd0 hd0_NONPART # mv hd1 hd1_DOSPART Note that you are directly changing the root file system diskette, so make sure that you are using a copy. These changes will take effect next time you boot up. Change directory to /usr/yourname and dismount the root file system. Write protect the diskette. 8. Edit /usr/yourname/.profile to suit your needs. Here are suggested contents: HOME=/usr/yourname PATH=/bin:/etc:/usr/bin: m="/etc/mount /dev/fd0 /user" u="/etc/umount /dev/fd0 export PATH HOME PS1 PS2 Save this file. Logout and reboot to check all these changes. Login as . Try typing "$m" to mount a floppy. -----------------------------------------------------------