extipl.txt for FreeBSD/Linux January 6, 2001 (trans. Jan. 6, 2001) takamiti@tsden.org extipl@tsden.org http://www.tsden.org/takamiti/extipl/ (translator Ryutaroh Matsumoto <ryutaroh@tsden.org>) ============================================================================== 1. Introduction 1.1 What is Extipl? 1.2 Limitations and Cautions 1.3 Copyrights and Conditions for Distribution 2. Usage 2.1 Commands of Extipl 2.1.1 save 2.1.2 fdtest 2.1.3 install 2.1.4 restore 2.1.5 show 2.1.6 chgboot 2.1.6 clrboot 2.2 On the Filenames of Hard Disks 3. Before Installation 4. Installation and Usage of Gemini 4.1 Using Gemini on a Floppy Disk 4.2 Installation of Gemini on a Hard Disk 4.3 Additional Operations in Gemini 4.4 Change of Disk Identifiers 5. Boot Selectors in Extipl 5.1 Gemini 5.2 Taurus 5.3 Aquila 5.4 Scorpius 6. Treatment of Extended Partitions 7. Error Codes 8. Appendix 8.1 Structures of Internal Selectors 8.2 Options for Debugging Extipl 1. Introduction 1.1 What is Extipl? There was an educational OS "Minix" written by Andrew Tannenbaum. It was compatible with UNIX version 7, and ran on Intel 8086 CPU. Several people, including me (T. Kimura), made it able to print Japanese. The Japanese version of Minix was called Minix-V. In the development of Minix-V, they have to select which Minix or Minix-V is booted. But I could not find a favorite boot selector, and I wrote one, which is called assistIPL. The name was changed to extipl later. AssistIPL can only be installed on Minix(-V). But users want to install it on other OS. So I rewrote it using bcc and tasm, added an installer on MS-DOS, and released it as extipl. Currently extipl is maintained on the following environments: caldera DR-DOS 7.02 lsic-86 3.30c for trial nasm 0.98 FreeBSD/Linux gcc nasm 0.98 Extipl version 5 has 4 internal boot selectors, which have the following properties. See Section 5 for more details. (1) They have complete upper compatibility with the Original IBM IPL. (2) They can boot an OS in a nonactive partition. (3) They can boot an OS in an extended partition. (4) They support the DR-DOS password function. (5) They can change the active partition before booting. (6) They can boot an OS in the second or later hard disks. (7) They can be installed on a floppy disk, and leave your hard disk unchanged. (8) They support LBA access. Thus they can boot an OS at the end of a large hard disk. The boot partition selectors installed from extipl are independent of OS, while the installer depends on OS. The boot partition selectors of extipl work even if Linux/FreeBSD partitions are deleted or hard disk is repartitioned. 1.2 Limitations and Cautions Please note the following: * DISK BIOS (int 13h) limits the capability of boot partition selectors. For example, you cannot boot an OS in a partition that cannot be accessed through BIOS. * The boot partition selector installed from extipl only read an OS specific loader at the first sector in a partition and execute it. It depends on the OS specific loader whether you can boot an OS in a nonactive partition, an extended partition, or the second hard disk. * When all partitions are made nonactive by "clrboot" command of extipl, some BIOS cannot boot an OS. In such a case please make some partition active. * If the order of boot devices is C: -> A:, you cannot use extipl installed on a floppy disk. * Extipl changes the contents of MBR (the first sector of a hard disk). Be careful, if you use an OS that uses MBR in its own way. * Extipl cannot coexist with other programs that use MBR (the first sector of a hard disk), for example other boot selectors. * When you change the compilation flags in Makefile so that you can save user defined names of OS, those names are saved the second sector of EVERY hard disk. Make sure that those sectors are not used by other programs. 1.3 Copyrights and Conditions for Distribution (1) * This package is maintained by Takamiti KIMURA <takamiti@tsden.org>. * This English document is translated by Ryutaroh MATSUMOTO from the Japanese document written by Takamiti KIMURA. * The signer has the copyright of each signed source or document. * This package can be used, modified, and distributed under the GNU General Public License Version 2. (2) Warranties THIS SOFTWARE IS PROVIDED BY TAKAMITI KIMURA ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TAKAMITI KIMURA OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (3) Support Enhancements and bug fixes of extipl will be distributed at http://www.tsden.org/takamiti/extipl/. If you have comments, bug reports, etc., feel free to email them to extipl@tsden.org. Although we do not make any guarantees, we will make the best effort to respond to your report. 2. Usage The program "extipl" contains the boot partition selectors, and installs one of them at the first sectors of a hard disk. The general syntax of the installer is extipl command device-name [arg1, arg2, ...]. 2.1 Commands of Extipl The installer extipl accepts the following 7 commands. Optional parameters are given after the device name. 2.1.1 save filename-of-HD file Current content of MBR in HD is backed up in "file." Content of MBR can be restored by "extipl restore" described below. If filename is omitted, default value "master.ipl" is used. Backed up file is made read-only. 2.1.2 fdtest filename-of-FD [iplname] Install the boot partition selector specified by "iplname" to floppy disk "filename-of-FD." The default selector is Gemini. See section 5 for what selectors are available. You usually don't have to specify iplname. Put "@" before iplname in order to specify a selector built in the installer "extipl", for example "@gemini". If the first character of "iplname" is not "@", the installer installs the file specified by "iplname" to the floppy disk. 2.1.3 install install filename-of-HD [iplname] Install the boot partition selector specified by "iplname" to "filename-of-HD." The partition table is retained. Before installation, you are forced to back up MBR to some file. You are asked the filename as Enter file name to save: If you only hit the enter key, MBR is saved in "fdiskipl.001". Backed up file is made read-only. The default selector "Gemini" occupies the first 18 sectors of a hard disk. Other selectors occupy the first sector only. 2.1.4 restore filename-of-HD file MBR contains partition information and an OS loader. You are asked as: C)ode: restore ipl code only T)able: restore partition table only A)ll: restore ipl code and partition table restore (c/t/a)? Reply 'c', 't', or 'a'. It is not examined whether specified file is valid copy of MBR. Filename cannot be omitted. 2.1.5 show device-name Display the content of the partition tables in "device-name". The content of an extended partition is also displayed. [Example] # extipl show wd0 ========= Partition TABLE on "/dev/wd0" ========= [1] 0B: FAT32 1866MB [2] 06: FAT16(>32MB) 125MB A[3] A5: FreeBSD 2596MB [4] 05: Extended DOS -- ( 1) 83: Linux native 256MB ( 2) 83: Linux native 1153MB ( 3) 83: Linux native 86MB ( 4) 82: Linux swap/Solaris x86 62MB 2.1.6 chgboot device-name Change the bootable partition in the specified device interactively. If you mark an extended partition bootable, you can also mark a partition in the bootable extended partition bootable. The following keys are understood: number : mark the selected partition bootable. w : write back the modified partition table to the device. q : quit without any modification to the device c : clear the bootable mark. b : back to the parent partition when you are in an extended partition. If you are in the top level partition, quit without any modification. # extipl chgboot wd0 ========= Partition TABLE on "/dev/wd0" ========= [1] 0B: FAT32 1866MB [2] 06: FAT16(>32MB) 125MB A[3] A5: FreeBSD 2596MB [4] 05: Extended DOS -- >>> Select partition to make bootable (? for help): 4 Partition #4(Extended DOS) specified, Can you make bootable(y/n)? y ### Inside [4] Extended DOS ( 1) 83: Linux native 256MB ( 2) 83: Linux native 1153MB ( 3) 83: Linux native 86MB ( 4) 82: Linux swap/Solaris x86 62MB >>> Select partition to make bootable (? for help): 1 ### Inside [2] Extended DOS *( 1) 83: Linux native 256MB ( 2) 83: Linux native 1153MB ( 3) 83: Linux native 86MB ( 4) 82: Linux swap/Solaris x86 62MB >>> Select partition to make bootable (? for help): w Ok. In this example, we make the Linux native partition in the extended partition bootable. First, we make the extended partition in the top level partition bootable. Since the specification does not allow us boot from an extended partition, extipl asks user's confirmation. Then we set the Linux partition bootable. Finally we write back the modification to the device by `w' command. If you want to verify your modification, use "extipl show device-name". 2.1.7 clrboot device-name marks all partition in "filename-of-HD" not bootable. This forces the boot partition selector to enter partition selection even if shift key is not pressed down. Original booter in MBR cannot boot OS if all partition is marked non-bootable. You have to use a selector in extipl to boot something. If BIOS loader of MBR checks the validity of MBR strictly, it considers the MBR invalid and YOU BECOME UNABLE TO BOOT ANY OS IN YOUR HARDDISK. BE CAREFUL. 2.2 On the Filenames of Hard Disks In order to install extipl, you have to specify the filename of the (first) hard disk (or the floppy disk). The common case is as follows. * FreeBSD : 2.2.x 3.x 4.x IDE HDD #0 - wd0 wd0 ad0 SCSI HDD #0 - sd0 da0 da0 Floppy #0 - fd0 fd0 fd0 * Linux : 2.x.x IDE HDD #0 - hda SCSI HDD #0 - sda Floppy #0 - fd0 3. Before Installation We will explain the installation of the boot partition selector (Gemini) using the program "extipl" (the installer) in Section 4. Before installation, please back up the content in the first sectors of your hard disk that will be replaced by extipl. To back up the first sectors with extipl, do "extipl save filename-of-harddisk". Now the first 18 sectors are saved in "./master.ipl". If you want to restore MBR to backed up one, do "extipl restore filename-of-harddisk master.ipl". 4. Installation and Usage of Gemini You might hesitate to rewrite the first sectors in HD. You can try extipl without making any changes to your HD. The boot partition selectors in extipl can be installed on a floppy disk. If you want to install a selector to HD now, go to Section 4.2. Extipl version 5 has 4 selectors. We will explain the installation of "Gemini", the default selector. 4.1 Using Gemini on a Floppy Disk To install the selector "Gemini" on a floppy disk, insert a formatted disk to A: and type extipl fdtest filename-of-floppy-drive. Then Gemini will be installed on the floppy disk. Let's use the Gemini selector on floppy. Make sure that the floppy disk is tried for booting before hard disks. Otherwise you cannot boot from the floppy disk. Insert the floppy disk and reboot your computer. After messages by BIOS, "extipl ..." is displayed. The selector Gemini counts 15 seconds before loading an OS in the active partition. If you press the space key, Gemini displays the menu for selecting OS. If you press the enter key, it immediately loads an OS. If you press the space key, you will see the following menu: +-------------------------------------------------------------------------+ | Drive: 1/2 mode:LBA | +-------------------------------------------------------------------------+ | | | | 0B: FAT32 1866MB | Change target Drive | | | | | 06: FAT16(>32MB) 125MB | | | | | | *A5: FreeBSD 2596MB | Mark active and Boot | | | | | 05: Extended DOS -- | Boot | | | | +-------------------------------------------------------------------------+ The upper row in the menu shows which disk is selected, and how Gemini reads OS in disk. The lower left part of the menu shows the contents of the partition table, and the lower right does available commands for the Gemini selector. The cursor is placed at the active partition initially. The active partition is also marked with asterisk (*). If there is no active partition, the cursor is placed on the first partition. Operations should be visually self-explanatory. The easiest way to select and boot an OS is as follows: Move the cursor to a partition by Up and Down key. Move the cursor to the lower right part of the menu by the Right (->) key, and move the cursor to "Boot". Then press the enter key. If the selected partition is an extended one, the Gemini selector boots an OS in the active partition in the extended partition. If there is no active partition in the selected extended partition, Gemini shows the following display and asks the user for further selection. +-------------------------------------------------------------------------+ | Drive: 1/2 (Inside: #4 Extended DOS) mode:LBA | +-------------------------------------------------------------------------+ | | | | [1] 83:Linux native 256MB | Change target Drive | | [2] 83:Linux native 1153MB | | | [3] 83:Linux native 86MB | Return to MBR | | [4] 82:Linux swap/Solaris x86 62MB | | | | Mark active and Boot | | | | | | Boot | | | | +-------------------------------------------------------------------------+ In the upper row, there is "(Inside: #4 Extended DOS)" indicating that we are in the extended fourth partition in the master partition. An additional command "Return to MBR" appears in the lower right part. It is used for returning the master partition table. Operations are the same as for the master partition table. The Gemini selector can display at most 7 partitions in an extended partition at once. If there are more than 7 partitions, it scrolls the lower left part as the cursor moves. It reads at most 16 partitions in an extended partition. 17th and later partitions are ignored. The meaning of the upper row and the lower right part is as follows: Drive: 1/2 | +--- the number of hard disks recognized by BIOS +----- the selected hard disk mode: LBA The hard disk is accessed in the LBA mode. If the BIOS or the hard disk does not support the LBA mode, "CHS" is displayed. Change target Drive is displayed only if there are more than 1 hard disks are recognized by BIOS. Disks are changed cyclically. Return to MBR is displayed only if an extended partition is displayed in the lower left part. It is used for returning to the master partition table. Mark active and Boot marks the selected partition and boots it. Boot boots the selected partition. If the cursor is in the lower left part, the following keys are recognized. They can be used for making operations quicker. <Enter> Same as "Boot" in the lower right part. <End> Same as "Mark active and Boot" in the lower right part. <Space> is valid only if the cursor is on an extended partition. Display the content of the selected extended partition. No counterpart in the lower right part. <Backspace> Same as "Return to MBR". "0" Same as "Change target Drive". Cursor moving keys of vi(1), "h, j, k, l", can be also used. 4.2 Installation of Gemini on a Hard Disk Booting from floppy is inconvenient. You may want to install a boot partition selector to HD once you convince that it is safe. To install it to HD, type extipl install filename-of-hard-disk Then you are asked to what file MBR is backed up. After backing up, you asked for final confirmation. Hitting `y' key allows extipl replace MBR with the specified boot partition selector (usually Gemini). You must log in as root to do the installation. The usage is exactly the same as one installed on a floppy disk. 4.3 Additional Operations in Gemini In this subsection we explain advanced functions in Gemini. They can be used by typing the following keys. <Alt> + t : changes the number of seconds counted before automatic booting. This operation is accepted only if the first hard disk is selected. You can change waiting time from 0 to 999 seconds. The initial value is 15. If these keys are pressed, Time to pause before boot: 15 -> _ is displayed at the bottom of the screen. You can enter a number. If you want to leave the waiting time unchanged, type the escape key, or type immediately the enter key. The value of 0 disables automatic booting and always asks the user which OS is booted. The change is not automaically saved, and is lost unless you save it by <Alt>+s described below. <Alt> + n : sets the name of partition This operation is accepted only if the cursor is in the lower left part. You can change the name of partition. Move the cursor to the partition that you want to rename, and type <Alt>+n. Then Enter Name (20 chars max): is displayed at the bottom of the screen. If you press the escape key, no change will be made. If you press the enter key with no string, the default name will be displayed for the selected partition. You can name at most 12 partitions. Your change is lost unless you save it by <Alt>+s below. CAUTION: Those names are saved in the second sector of a hard disk. By default only names of partitions in the first hard disk are saved. If you want to save names in other disks, you can do so by changing Makefile, read Makefile for details. In this case the second sector of every had disk is changed. Make sure that the second sector is not used by other programs. <Alt> + s : save changes You can save changes by <Alt>+s. *************************** *** Caution *** *************************** The following limitations apply only to Gemini installed on a floppy disk. 1. Changes are written to the floppy disk instead of the first hard disk. In particular, Gemini writes the configuration on the initial boot even if no changes are made. If you eject the floppy disk and insert it again, you always get the "media change" error. In this case you have to do <Alt>+s twice. Otherwise changes are lost. 2. Only names for partitions in the first hard disk are saved. 4.4 Change of Disk Identifiers The Gemini selector can change the BIOS identifier of the second (or later) hard disk from 0x81 to 0x80 so that DOS or Windows can be booted from the second or later hard disks. But this change of identifier causes problems with UNIX. So the Gemini selector changes the identifier of hard disks only if you select the following OS in the second or later hard disks: 0x01 FAT12 0x04 FAT16(<=32MB) 0x06 FAT16(>32MB) 0x07 NTFS/HPFS 0x0B FAT32 0x0C FAT32(LBA) 0x0E FAT16(LBA) 0x11 Hidden FAT12 0x14 Hidden FAT16(<32MB) 0x16 Hidden FAT16(>=32MB) 0x17 Hidden HPFS 0x1B Hidden FAT32 0x1C Hidden FAT32(LBA) 0x24 NEC DOS 3.x 0x86 NTFS striped FAT 0x87 NTFS striped 0xCB secured FAT32 0xCC secured FAT32(LBA) 0xCE secured FAT16(LBA) 0xF2 DOS 3.3 2nd partition If you want to change identifiers of disks with other OS, select it by <right shift> + <Enter> key. If you don't want to change identifiers with DOS or Windows, select it by <Ctrl> + <right shift> + <Enter> key. This function is removed from the Gemini selector if "-dHOOKUP13" compilation flag is removed from GEMINIFLAGS in src/Makefile 5. Boot Selectors in Extipl Besides the selector "Gemini" explained in the previous section, the installer "extipl" contains 3 other selectors that fit in the first 446 bytes of a hard disk. They can be specified as an optional argument in fdtest/install (see 2.1.2 and 2.1.3). To specify these selectors, put @ before the name of a selector. For example, # extipl install wd0 @taurus ; Taurus is specified. # extipl install wd0 @gemini ; Gemini is specified. The default selector is "gemini". If "@" is omitted, the argument is treated as a filename. 5.1 Gemini has the most visual user interface and the largest program size (8 KB). It has the following features. It consists of two parts. The first part is called pollux that resides in the first sector. The second is called castor. Pollux loads and executes castor. Castor does the most job. 1) CHS/LBA is automatically detected. 2) It can boot an OS in any hard disk recognized by BIOS. 3) It can boot an OS in an extended partition, where active partitions are recognized in a reasonable manner. 4) Change active partition before boot. 5) If castor (the second part) cannot be executed, an OS in the active partition is booted. 5.2 Taurus occupies only the first sector. 1) CHS/LBA is automatically detected. 2) It can boot an OS ONLY in the first hard disk. 3) It can boot an OS in an extended partition, where active partitions are recognized in a reasonable manner. 4) It CANNOT select which OS is booted. It is an extension of the ordinary MBR with LBA and boot from an extended partition. 5.3 Aquila occupies only the first sector. 1) CHS/LBA is automatically detected. 2) It can boot an OS ONLY in the first hard disk. 3) It can boot an OS in an extended partition, where active partitions are recognized in a reasonable manner. 4) It CAN select which OS is booted. 5) It CANNOT change the active partition. 6) The OS selection menu is called by the Caps Lock key. If you want to assign other key, modify the definition of TRIGGER_BIT in the file altair.asm, and recompile it. Usage: 1) If you want to boot an OS in the active partition, do nothing. The OS is automatically booted. 2) If you want to boot an OS in a nonactive partition, press the Caps Lock key and wait for the selection menu. The initial selection menu shows pairs of partition number and system ID in the master partition table in hexadecimal format. The number after the prompt "Boot>" indicates which partition is active. ------------ No Sys 1 0B 2 06 3 A5 4 05 Boot>3 ------------ In this example you can boot OS in the partitions 1 to 3 by selecting its number and press the enter key. If you select the fourth partition, it displays the content of the extended partition and prompts further selection. ------------ No Sys 1 83 2 05 3 4 Boot>4.1,1 ------------ More information is shown after "Boot>". The first number indicates which extended partition in the master partition table is selected. The second indicates the depth of the selected partition table. If you select "2" here, you enter the deeper extended partition. ******************************* *** limitations of Aquila *** ******************************* Due to the limitation on the program size (446 bytes), Aquila has the following limitations: a) You cannot return to the parent partition of an extended partition. But you can return to the master partition table by the Back Space key. b) If you failed to select the correct logical partition to boot up, then you can not go further unless you return to the master partition table by the Back Space key. 5.4 Scorpius This is the selector in the extipl version 4.x. It occupies only the first sector. 1) It accesses a hard disk only in CHS mode. Thus it cannot boot an OS at the position of 8 GB or later. 2) It can boot an OS in any hard disk recognized by BIOS. 3) It can boot an OS in an extended partition, where active partitions are recognized in a reasonable manner. 4) Change active partition in the FIRST hard disk before boot. 5) It CAN select which OS is booted. Details of this selector are explained in scorpius.txt. 6. Treatment of Extended Partitions By an extended partition we mean a partition with ID 0x05 or 0x85. The specification by IBM says that an extended partition is not bootable, and an extended partition should not be marked active. However, all the selectors in extipl can automatically boot an OS in a partition within an extended partition, if an extended partition is marked active. We added this functionality because installers for Linux can make a partition containing a kernel in an extended partition. Currently we have verified that only Linux can be booted from a partition in an extended partition. We guess that other OS cannot be booted. An extended partition consists of a partition and an optional extended partition, which can also contain a partition and an optional extended partition. This structure can be shown by "extipl -d show device-name". [4] 05: Extended DOS ( 1) 83: Linux native ( 1) 05: Extended DOS ( 2) 83: Linux native ( 2) 05: Extended DOS ( 3) 82: Linux swap/Solaris x86 In the example above, there are two extended partitions in an extended partition. Although all the selectors in extipl can boot an OS in an extended partition, it cannot boot it if only the extended partition in the master partition table (4th partition in the example above) is marked active. The partition containing an OS and all its parent extended partitions should also be marked active. In the example above, we have to mark partitions as follows in order to the second Linux native partition. *A[4] 05: Extended DOS ( 1) 83: Linux native *( 1) 05: Extended DOS *( 2) 83: Linux native ( 2) 05: Extended DOS ( 3) 82: Linux swap/Solaris x86 "extipl chgboot" and "Mark active and Boot" command in Gemini selector mark partitions consistently as above. 7. Error Codes Selectors other than Gemini stop and print the error in the hexadecimal format if BIOS returns an error. Gemini prints an error in the following format: Disk BIOS Error, code=0x???? where 0x???? is the drive number * 256 + the error code, and tries to continue the task. You should try to figure out the cause of the error and remove it. The error codes by BIOS are defined as follows: 0x01 Bad command 0x02 Bad address mark detected 0x04 Record not found 0x05 Reset fail 0x07 Cannot drive initialize 0x09 DMA boundary error 0x0B Bad track flag detected 0x10 Uncorrectable ECC error 0x11 Correctable ECC error 0x20 Bad controller 0x40 Seek error 0x80 Time out 0xBB Undefined error 0xFF Sense operation fail 8. Appendix 8.1 Structures of Internal Selectors If you have interest in the internal structure of selectors in extipl, please refer to technical.txt. Although it focuses on the Scorpius selector, many descriptions also apply to other selectors. 8.2 Options for Debugging Extipl The program extipl accepts the following flags. -d If this flag is specified, extipl writes a selector to the file "./BootSec.???" instead of a hard disk or a floppy disk, where ??? is a sequential number starting from 000. It is mainly used for the debugging purpose. -f This flag suppresses the query of the back up filename on the installation of a selector. The first sectors are backed up to "./fdiskIPL.???".