To understand how LILO works, you must understand how a hard disk is laid out. You probably already know that a hard disk is essentially a set of concentric tracks, radiating out from the center of the disk platter. Each track is divided into a number of sectors.
Hard disks are identified by the number of platters (or more accurately, the number of heads; the number of platters can be greater than the number of heads because one or more surfaces, typically the top and bottom, might not be used for data storage), the number of tracks per inch of disk platter (measured radially), and the number of sectors per track. The capacity of each sector leads to the total capacity of the disk by multiplying by the number of sectors per track, the number of tracks, and the number of platters with heads.
Linux is usually integrally tied with DOS, so it is useful to look at the way DOS uses a hard disk. A single-purpose (single DOS operating system, for example) hard disk (and most floppy disks) has a boot sector, followed by a data area that includes an administrative block. The boot sector is the first sector on the hard disk and is read when the system starts to load the operating system. The boot sector contains a bootstrap to direct the machine to the startup routines. The data area stores files, including the operating system startup code. (A bootstrap is a short piece of code that tells the BIOS how to load the operating system. It essentially starts the operating system load process by providing the bare bones instructions necessary to read the operating system files from disk.)
Although the administrative block is usually part of the data area, users commonly cannot access it directly. Each file on the hard disk has an entry in the administrative block’s tables that indicates the file’s location in terms of the head, track, and sector and the file name. Other information, such as owner, permissions, date and time, is usually stored in the administrative block as well. In DOS, this information makes up the File Allocation Table (FAT); UNIX and Linux use the superblock or i-node tables. The administrative table is not usually read until the boot process has been started.
When the hard disk has lots of space, you will probably want to install more than one partition. Multiple partitions are especially useful if you want to support more than one operating system (DOS and Linux, for example) on the same hard disk. You can create up to four primary partitions on a DOS disk.
With some operating systems, you can have more than four partitions, but if you are using DOS on the hard disk, don’t create more than four primary partitions. Doing so may cause DOS to improperly read any data in the DOS partition because DOS has a built-in limitation of four partitions per disk. DOS’ FDISK can’t handle more than that amount. If you need to provide more than four logical disk drives, you can use extended partitions. An extended partition is a primary partition that has been subdivided.
A partition table that contains the details of the partitions on the disk is written to the first sector (boot sector) of each hard disk (not each platter). This sector is sometimes called the Master Boot Record or MBR. Although the terms boot sector and MBR are often used interchangeably, MBRs differ from boot sectors in that MBRs contain partition information. In other words, you can call a hard drive’s boot sectors MBRs, but floppy disks’ boot sectors are never MBRs. Extended partitions also have partition tables written to their beginning sectors. A program called the map installer creates Linux boot sectors.
When a hard disk has several partitions, Linux refers to them by device numbers after the primary disk name, such as /dev/hda1, /dev/hda2, and so on. In this case, /dev/hda is the first hard drive (/dev/hdb would be the second, /dev/hdc the third, and so on). Within the first hard drive, the partitions are named /dev/hda1, /dev/hda2, and so on. A second hard disk called /dev/hdb has partitions called /dev/hdb1, /dev/hdb2, and so on. The disk names may have other letters, depending on the type of hard disk and its adapter. For example, a hard disk may be called /dev/sd1 instead of /dev/hda. Extended partitions would be numbered /dev/hda5, /dev/hda6, and so on because only four primary partitions, or /dev/hda4, are allowed.