by Bob Starrett
CD-ROM Professional, August 1995 - Copyright © Robert A. Starrett
For years, the thought of a bootable CD-ROM has intrigued many: how could it be done in the DOS world? For Macintosh and Unix, bootability has never been a problem; if you made a byte-for-byte copy of a Mac or Unix hard disk to CD, the system could recognize the device and proceed to boot the disc. You can make a CD-ROM image from a DOS hard drive just like you can from a Mac or Unix drive, but it won't boot.
In DOS, you need two things to access a CD-ROM drive: the first is a device driver that must be loaded so the system can recognize the CD-ROM device. The second is the MSCDEX program or one of its variants from Corel, Meridian, or other manufacturers that assigns a drive letter to the CD-ROM drive and allows DOS to access the files on the disc. And so the problem with a bootable DOS CD-ROM is that to boot the machine, the command interpreter, COMMAND.COM, must be loaded, and then the device driver for the CD-ROM drive can be loaded, and then MSCDEX.EXE can be started, and only then do you get access to the files on the CD-ROM. Hence, a catch-22, to load COMMAND.COM from a CD-ROM you must first load the device driver and MSCDEX. But you can load neither without first loading COMMAND.COM.
The solution is to be able to recognize the presence of a CD-ROM before COMMAND.COM is loaded, and this can be done through the computer's BIOS (Basic Input/Output System) or a BIOS on a SCSI or IDE adapter card. Once the drive is recognized by the BIOS, there must be a structure on the CD-ROM that allows the BIOS to load COMMAND.COM or a command interpreter for another operating system. Phoenix Technologies and IBM have jointly released the "El Torito" Bootable CD-ROM Format specification, which defines how a boot image or images should be placed physically on the CD-ROM. The specification contains a lot of low-level details concerning the structure and makeup of the bootable disc. The bad news is that it takes a while to wade through the specification to figure out exactly how to set up a disc for bootability. The good news is that you can make a bootable CD-ROM using readily available tools and most CD-ROM Recordable software.
More good news: the bootable CD is still an ISO 9660 disc, so it can be replicated and distributed like any other CD-ROM. The disc can contain anything that is normally placed on CD-ROM and you can give the user the option to boot from it or not. [For more on the origins of El Torito Specification, readers should re-visit "Fresh Tortillas and CD-ROM Standards: The El Torito Bootable CD-ROM specification," in the Standards column, by Dana J. Parker, in July 1995 CD-ROM Professional (Volume 8, Number 7)--ed.] Version 1.0 of the El Torito Specification is dated January 25, 1995; it is available without charge to anyone and there are no licensing fees required for the use of any of the information contained in the spec.
WHAT IS A BOOTABLE DISC?
The process of creating your own bootable CD-ROM is tedious, to be sure, but until CD-Recordable software vendors add this support to their software programs, or until someone writes a program that will automatically patch an existing ISO 9660 image file--which is not especially difficult--the tedious way is the only way to do it. And how tedious can the process be? Well, for one thing, it helps to be handy with hexadecimal numbers. The El Torito Specification describes itself as "defining how makers of CD-ROMs can package several 'images' of floppy and hard disks on a single CD with the ability to catalog these images and to selectively boot from a single image." The document, in what must be one of the great failures of public encouragement, also states the assumption that the would-be bootable disc maker is "familiar with standard BIOS INT 13 functions, ISO 9660, IBM/Microsoft INT 13 Extensions and ATAPI." Fortunately, although some familiarity with the sector structure of a CD-ROM is helpful, you can understand and make a bootable CD without being familiar with any of those other things.
To access a bootable CD-ROM, a PC must be equipped with a BIOS that implements the El Torito requirements for accessing the boot sector. Most BIOS manufacturers are incorporating this capability into their BIOS and it is likely that soon, most new PCs will have the ability to boot from CD-ROM. Adaptec is ahead of the pack, having incorporated bootable CD support into the BIOS on their SCSI cards. The current Adaptec 1542CF card with a BIOS revision of 2.10 or later will allow you to boot from CD. (To see if your Adaptec card has this support, enter the Adaptec setup utility by pressing CTRL-A at the Adaptec BIOS sign on, go to "Advanced Configuration Options." If the boot feature is supported, there will be an option for "BIOS Support for Bootable CD-ROMs" in the menu.)
THE BOOTABLE BACKGROUND
Dealing with the location of certain data at certain sectors is necessary to produce a bootable CD. The Yellow Book defines the logical structure of a CD-ROM as having 333,000 sectors of 2,352 bytes each. 2,048 bytes of each sector are available for user data, and the other 304 bytes are reserved for things like sync, header, error correction and error detection code, all of which get added to the sectors in the CD-R creation or mastering process. In standard CD-ROM, the first 15 sectors are unused, with Sector 16 containing the Primary Volume Descriptor (PVD). This can be followed by any number of secondary volume descriptors, followed by a Set Terminator Volume Descriptor. The PVD is always at Sector 16 and on ISO 9660 discs it always starts with the characters "CD001".
Figure 1 - If you know your way around hexadecimal notation, you can see that this screen of Norton's Disk Editor (any number of good file editors will do) shows an offset of 32,768 (upper left hand corner) which, divided by 2048 means sector 16 on the CD-ROM, where the Yellow Book demands ".CD001" be found.
Figure 2 - The normal CD-ROM is not bootable, but a BIOS with a bootable CD capability will access the Initial/Default Entry on a single-boot disc image. If multiple boot images exist on the disc, a comforming BIOS can access any of the bootable disk images in the booting catalog.
The El Torito Specification adds two entries to the CD-ROM. These are the Boot Record and the Boot Catalog. The Boot Catalog consists of five entries: the Validation Entry, the Initial/Default Entry, the Section Header, the Section Entry, and the Section Entry Extension. The El Torito Specification takes advantage of ISO 9660's ability to use more than one volume descriptor, by requiring that a Boot Record Volume Descriptor reside at Sector 17 of the CD, which serves as a Secondary Volume Descriptor. The CD001 header of the Boot Record Volume Descriptor indicates that this disc is an ISO 9660 CD-ROM; the EL TORITO SPECIFICATION identifies the disc as one that is potentially bootable. According to the specification, it is not necessary that the boot catalog reside on any particular sector, but only that the absolute pointer in Sector 17 identifies its location. The boot catalog that shows up in the pointed-to sector potentially has five entries. A single boot image CD-ROM, however, only uses the first two, the Validation Entry and the Initial/Default Entry. The Validation Entry is always the first entry in the boot catalog; this entry validates that there is a boot catalog on the disc, but also reserves space for the identity of the manufacturer.
Figure 3 - In building a bootable disc, changes must be made to Sector 17, where the El Torito Specification requires a Boot Record Volume Descriptor. The entry in Sector 17 is the hexadecimal number 13 (5th line, byte 7) that serves as an absolute pointer to Sector 19, to the boot catalog that must be created.
If you were to look at the hexadecimal for Byte 0 of this sector, it would be 01, which is the header ID that a bootable CD uses at this position to indicate that a boot catalog is present on the disc. Byte 2 indicates the platform for which the disc is intended, where, for instance, 00 designates an 80x86 machine, 01 designates a Power PC, 02 designates a Macintosh. Other entries can serve as an ID string that can be used to identify the maker of the CD-ROM, but on line two, the entries 14 and 15 are designated Key Bytes and must always be set to 55 and AA respectively. The Initial/Default Entry in the boot catalog indicates whether the disc is bootable, what media type it emulates, the load segment of the boot image, the number of sectors to store in the load segment, and the starting address of the floppy or hard disk image. The 88 in the first byte (see Figure 4) indicates that the disc is bootable. If this is followed by 04, then the meaning is that the bootable image is an image of a hard disk; a 1.44MB floppy would be represented by 02. C0 07 is the standard load segment and in most applications this will not change. The 15 indicates that the bootable image resides at Sector 15h of the CD-ROM. Translated to decimal, this is Sector 21. DEFAULT ENTR is an identifier that is used for reference by the disk producer. Using and creating multiple boot images and discs requires that the Section Header, Section Entry, and Section Entry Extension exist to support, for example, a disc that could have four boot images on it. When the BIOS recognizes the CD-ROM as bootable, it will display a menu and allow the user to choose which disk image to boot. An example of the type of choice a multiple boot disc may offer is a disc that has both floppy and hard disk boot images on it. The Section Header Entry would indicate that a group of booting entries follow, that is to say that the BIOS can boot from any of these images instead of the default image defined in the Initial/Default Entry.
Figure 4 - The boot catalog potentially has five entries, although a single-boot disc only uses the Validation Entry and the initial/Default entry. the Validation Entry, through Byte 0 being 01, the Header ID, indicates that a boot catalog is present, but also reserves space for the identity of the manufacturer, which, in the screen shown here, is "BOBSCD". Byte 2, currently set to 00, indicates the platform for which the disc is intended, and 80X86 machine. On line 2, the entries 14 and 15 are designated Key Bytes and must always be set to 55 and AA respectively. 88, in the first byte of line 3 here, indicates that the disc is bootable; 04 means that the bootable image is an image of a hard disk, 15 indicates that the bootable image resides in Sector 15 (hexadecimal) of the CD-ROM, or Sector 21.
In Figure 5, 91 indicates that this is the final header. A 90 would indicate that more headers follow. The 00 in the second byte indicates that the disc is for a PC. As with the Initial/Default Entry, 01 would indicate a disc for a Power PC and 02 would indicate a disc for a Macintosh. The 02 in the third byte indicates that there are two Section Entries following this header. OS Type 01 is an ID string that can be entered by the disc producer. It identifies to the type of boot that will occur when picking this entry from the menu. The first Section Entry is the same as the Initial/Default Entry, with the addition of reserved bytes for selection criteria that is vendor unique. A floppy boot Section Entry would be indicated by an 02 in the second byte. The second and any subsequent Section Entries have the same structure as the first Section Entry, except that its contents are specific to the boot image it identifies.
Figure 5 - Multiple boot discs carry all five entries in the boot catalog. In line 5, the 91 indicates that this is the final header; the 00 in the second byte indicates that the disc is for a PC; the 02 in the third byte indicates that there are two Section Entries following this header; OS Type 1 is an ID string found by the BIOS. If the BIOS finds such a string, it will look for two or more boot entries. Note that the sector for this boot record is the very first sector of the disc; this particular disc used some of Sector 0, which is not assigned by ISO 9660, for placement of the boot record.
Figure 6 - Making a bootable
CD-ROM - at least until premastering software catches up and provides a
more gracious handling of the feature - means a lot of hexadecimal reading.
here, at Sector 21, we see the beginning of the hard disk image, and the
sector in which it appears must be correctly noted in the boot record of
the bootable disc.
A BOOTABLE DISC, STEP-BY-STEP
Anyone writing a bootable disc will need to make an exact image of the hard drive that the Bootable CD will emulate, and then that image will have to be written on another hard disk with a CD-ROM premastering/recording program. The next step is to use Norton's Disk Editor, or other, similarly functional software, to patch the image to make it bootable. After that, it is simply a matter of writing the bootable CD-R disc with any CD-Recordable software.
STEP ONE: A BIT-FOR-BIT COPY OF THE HARD DRIVE
You first need to copy the physical hard drive, bit for bit, to a file. You can do this with Norton's Disk Editor program, which is part of the Norton Utilities or any other disk editor that allows the functions discussed here. (For the disc created in the course of the exploration described here, I used Norton Utilities 7.0, and specific menu selections reflect that particular program). Here is the procedure:
1. Start the Disk Editor and choose the OBJECT pull down menu.
2. Select the first entry, DRIVE.
3. Change TYPE from Logical Disk to Physical Disk.
4. Select the physical disk that you wish to copy, press OK and you will see a hexadecimal representation of the hard disk, set to Cylinder 0 Side 0 Sector 1.
5. Select TOOLS from the pulldown menu.
6. Select WRITE OBJECT TO from the menu; the dialog box will show the total number of sectors on your hard disk and FILE will be selected by default as the destination. A dialog box will come up, prompting you for the directory and filename of the image you are about to write.
7. Enter the directory and filename, confirm the action, and a bit-for-bit image of your entire hard drive, including empty space, will now be written to the source file.
Be prepared to do something else for a while. This will take a long time, two hours or so for a 250MB drive. Remember that the Norton Disk Editor will write a file the size of your full hard disk capacity, even if the hard disk has only a few files on it.
STEP TWO: MAKING AN ISO 9660 IMAGE
Once you have completed the copy, exit Norton Utilities. Now you need to make an IS0 9660 image containing only the file that you just produced. Create the image on a hard disk with your ISO formatting software, using software that writes a real image to a hard drive. (Software that writes virtual images only to CD-R will not work because you will need to patch the image to make it bootable before you can write it to the CD-R disc.)
STEP THREE: PATCHING THE IS0 9660 IMAGE
After your software has created the image, you can proceed to the patching process. Using Norton's Disk Editor program, you can view and edit the ISO 9660 image. To edit the image, start the Disk Editor, select the OBJECT pulldown menu and then select FILE from the menu. A dialog box appears: select the image file you just created. When the file opens, you will see a bunch of zeros, starting at offset 0, hex 0. This is the first sector of the CD-ROM image. Make the following changes:
1. You need to move to Sector 17, which will become the boot record. Sector 17 is at offset 34,816, 8800h in the Norton Disk Editor. (To determine where the next sector starts, add 2,048 to the offset displayed on the screen. Scroll down until you find 8800h.)
2. You should see "CD001" on the right of the screen. This identifies the disc as a CD-ROM. To identify it as a bootable CD-ROM you need to add "EL TORITO SPECIFICATION" right after "CD001". Use the tab key to move to the right portion of the screen. Press your CAPS LOCK key and type in "EL TORITO SPECIFICATION". When you reach the end of a line, Norton may ask you if you want to save changes. Choose OK and move to the next line to finish entering the string.
3. Make sure that the space between CD001 and EL TORITO SPECIFICATION is 01 and not 20, which is the ASCII space character.
4. Check the first byte in the first line. If it is FF or any other number, change it to 00. You can do this by pressing TAB, moving to the first byte in the line with the cursor keys and typing in "00".
5. Double check to make sure that the numbers and characters on your screen match Figure 3 in this article. Don't just check the characters because some of the hex numbers will not show up as characters.
6. When you are sure that they match the numbers in Figure 3, save the changes to disk by pressing ESC and choosing WRITE.
STEP FOUR: DETERMINING BOOT CATALOG PLACEMENT
You need to determine where the boot catalog should begin. While it can theoretically be placed anywhere, since the boot record refers to it, this example places it at Sector 19. Follow this procedure: before you create the boot catalog, go back and tell the boot record where the boot catalog is. Sector 19 is 13 in hexadecimal, so you need to go back to Sector 17 and enter the number at line 8840h, Byte 7. Use the editor to enter "13" at this position. You are now finished with Sector 17.
STEP FIVE: CREATING THE BOOT RECORD
To create the boot record, you need to go to Sector 19. Sector 19 is located at offset 38,912, 9800h, and there will be no data here; the boot catalog will consist of the Validation Entry and the Initial/Default Entry. Follow these steps:
1. Use the editor to enter the bytes shown in Figure 4 on lines 9800h, 9810h, 9820h and 9830h. Save your work as you go or as the Norton Disk Editor prompts you. Don't worry about a mistake--you can just type over it and save again.
2. Check to make sure that the hard drive boot image starts at Sector 21 (15 in hex). There are good reasons to check: the 15 at line 9820h, Byte 8, tells the BIOS about the location of the hard drive boot image, but some premastering software may put it at Sector 20, 22, or 23. Wherever this sector is will be OK, as long as its location is specified in the boot catalog.
3. Determine that the image is in the correct place by moving to offset 43008, A800h (Sector 21) and looking for the string that appears at the beginning of Figure 6. This is the beginning of the hard disk image, and if you do not find it at Sector 21, keep scrolling down until you locate this string. (Again, to find out which CD-ROM sector you are in, divide the offset by 2,048. In this case, 43008 / 2,048 = 21).
4. If you find the start of the hard disk image at another location, determine its sector number and note the number for insertion into the Initial/Default Entry. If the hard disk image starts at a sector other than 21, you will need to determine what sector it is and convert the number to hexadecimal, and then replace the 15h with that number.
AND NOW, THE WRITE MOMENT
Once the boot catalog is completed, save the file for the last time. The image should now be ready to transfer to disc. Write the ISO image file to your CD-Recorder in the normal manner. You can close the disc or write in multisession; if you make a multisession disc, you must close the session. Once done, you can double check the positions of the boot sector, boot catalog and the hard disk image, but it is more fun to just put the disc in your drive and reset the computer.
WHAT DOES IT ALL MEAN, TO BOOT?
Finally, a CD-ROM that boots. Think of the possibilities. In a complex system like the PC, and with demanding and configuration-hungry titles pushing the platform, the biggest wonder of it all may be that bootable CD-ROM has been so long in coming. The possibilities are quite striking and large in number. Even if you count in hexadecimal.