• Aucun résultat trouvé

Boot Disks and Geometry Settings

Most fi rmware implementations enable you to choose the order in which devices are booted. This is an area in which BIOS and EFI differ, and there are substantial implementation-to-implementation differences, too. Generally speaking, though, the rules are as follows:

c03.indd 114

c03.indd 114 11/12/12 8:45 PM11/12/12 8:45 PM

BIOS The BIOS boot process begins by reading a boot sector (typically the fi rst sector) from a disk and then executing that code. Thus, boot options for BIOS-based computers are limited; you can only select the order in which various boot devices (hard disks, fl oppy disks, optical disks, USB devices, and so on) are examined to fi nd a boot sector.

EFI Under EFI, the boot process involves reading a boot loader fi le from a fi lesystem on a special partition, known as the EFI System Partition (ESP). This fi le either can take a special default name or can be registered in the computer’s NVRAM. Thus, EFI comput-ers often present an extended range of boot options, involving both default boot loader fi les from various devices (to enable granting precedence to a bootable USB fl ash drive, for example) and multiple boot loaders on the computer’s hard disks. Some primitive EFI implementations, though, present simple BIOS-like boot options.

Many EFI implementations support a BIOS compatibility mode and so can boot media intended for BIOS-based computers. This feature, intended to help in the transition from BIOS to EFI, can complicate firmware setup and OS installation because it creates extra boot options that users often don’t understand.

Although boot sequences involving removable disks are common, they have their prob-lems. For instance, if somebody accidentally leaves a fl oppy disk in the drive, this can prevent the system from booting. Worse, some viruses are transmitted by BIOS boot sectors, so this method can result in viral infection. Using removable disks as the default boot media also opens the door to intruders who have physical access to the computer; they need only reboot with a bootable removable disk or CD-ROM to gain complete control of your system. For these reasons, it’s better to make the fi rst hard disk (or a boot loader on a hard disk’s ESP, in the case of EFI) the only boot device. (You must change this confi guration when install-ing Linux or usinstall-ing an emergency boot disk for maintenance.) Most modern computers make temporary changes easier by providing a special key to allow a one-time change to the boot sequence. On older computers, to change the boot sequence, you must locate the appropri-ate fi rmware option, change it, and reboot the computer. It’s usually locappropri-ated in an Advanced menu, so look there.

Another disk option is the one for detecting disk devices. Figure 3.1 shows three disk devices: the A: fl oppy disk (/dev/fd0 under Linux), a 1048MB primary master hard disk, and a CD-ROM drive as the secondary master. In most cases, the fi rmware detects and confi gures hard disks and CD-ROM drives correctly. In rare circumstances, you must tell a BIOS-based computer about the hard disk’s cylinder/head/sector (CHS) geometry.

The CHS geometry is a holdover from the early days of the x86 architecture. Figure 3.3 shows the traditional hard disk layout, which consists of a fi xed number of read/write heads that can move across the disk surfaces (or platters). As the disk spins, each head marks out a circular track on its platter; these tracks collectively make up a cylinder. Each track is bro-ken down into a series of sectors. Thus, any sector on a hard disk can be uniquely identifi ed by three numbers: a cylinder number, a head number, and a sector number. The x86 BIOS was designed to use this three-number CHS identifi cation code. One consequence of this

116 Chapter 3 Configuring Hardware

confi guration is that the BIOS must know how many cylinders, heads, and sectors the disk has. Modern hard disks relay this information to the BIOS automatically; but for compat-ibility with the earliest hard disks, BIOSs still enable you to set these values manually.

F I G U R E 3 . 3 Hard disks are built from platters, each of which is broken into tracks, which are broken into sectors.

Pivoting arms with read/write heads

Track Sector

Platters

The BIOS will detect only certain types of disks. Of particular importance, SCSI disks and (on some older computers) serial ATA (SATA) disks won’t appear in the main BIOS disk-detection screen. These disks are handled by supplementary firmware associated with the controllers for these devices. Some BIOSs do provide explicit options to add SCSI devices into the boot sequence, so you can give priority to either ATA or SCSI devices.

For those without these options, SCSI disks generally take second seat to ATA disks.

CHS geometry, unfortunately, has its problems. For one thing, all but the earliest hard disks use variable numbers of sectors per cylinder—modern disks squeeze more sectors onto outer tracks than inner ones, fi tting more data on each disk. Thus, the CHS geom-etry presented to the BIOS by the hard disk is a convenient lie. Worse, because of limits on the numbers in the BIOS and in the ATA hard disk interface, plain CHS geometry tops out at 504MiB, which is puny by today’s standards. Various patches, such as CHS geometry translation, can be used to expand the limit to about 8GiB. Today, though, the preference is to use logical block addressing (LBA) mode. (Some sources use the expan-sion linear block addressing for this acronym.) In this mode, a single unique number is assigned to each sector on the disk, and the disk’s fi rmware is smart enough to read from the correct head and cylinder when given this sector number. Modern BIOSs typi-cally provide an option to use LBA mode, CHS translation mode, or possibly some other modes with large disks. EFI doesn’t use CHS addressing at all, except in its BIOS compat-ibility mode; instead, EFI uses LBA mode exclusively. In most cases, LBA mode is the best choice. If you must retrieve data from very old disks, though, you may need to change this option.

c03.indd 116

c03.indd 116 11/12/12 8:45 PM11/12/12 8:45 PM

Because of variability in how different BIOSs handle CHS translation, mov-ing disks between computers can result in problems because of mismatched CHS geometries claimed in disk structures and by the BIOS. Linux is usually smart enough to work around such problems, but you may see some odd error messages in disk utilities like fdisk. If you see messages about incon-sistent CHS geometries, proceed with caution when using low-level disk utilities lest you create an inconsistent partition table that could cause prob-lems, particularly in OSs that are less robust than Linux on this score.