Boot sector
From Wikipedia, the free encyclopedia
This article includes a list of references or external links, but its sources remain unclear because it lacks inline citations. Please improve this article by introducing more precise citations where appropriate. (November 2007) |
A boot sector is a sector of a hard disk, floppy disk, or similar data storage device that contains code for booting programs (usually, but not necessarily, operating systems) stored in other parts of the disk.
On a IBM PC compatible machine the BIOS selects a boot device, then it copies the first sector from the device (which may be an MBR, VBR or any executable code), to address location 0x7C00.
Contents |
[edit] Kinds of boot sectors
There are several major kinds of boot sectors could be encountered on IBM PC compatible hard disks, floppy disks and similar storage devices:
- A master boot record (MBR) is the first sector of a data storage device that has been partitioned. The MBR sector may contain code to locate the active partition and invoke its Volume Boot Record.
- A volume boot record is the first sector of a data storage device that has not been partitioned, or the first sector of an individual partition on a data storage device that has been partitioned. It may contain code to load and invoke an operating system (or other standalone program) installed on that device or within that partition.
To be a valid boot sector, the two-byte hex word 0xAA55, called the boot sector signature, must exist at the end of the sector; otherwise, either the BIOS or MBR code will report an error message and halt any OS bootstrapping process.
- CD-ROMs usually have their own structure of boot sectors, for IBM PC compatible systems this is subject to El Torito specifications.
- Non IBM PC compatible systems may have different boot sector formats on their disk devices.
[edit] Operation
On IBM PC compatible machines, the BIOS is ignorant of the distinction between VBRs and MBRs, and of partitioning. The firmware simply loads and runs the first sector of the storage device. If the device is a floppy or USB flash drive, that will be a VBR. If the device is a hard disk, that will be an MBR. It is the code in the MBR which generally understands disk partitioning, and in turn, is responsible for loading and running the VBR of whichever primary partition is set to boot (the active partition). The VBR then loads a second-stage bootloader from another location on the disk.
Furthermore, whatever is stored in the first sector of a floppy diskette, USB device, hard disk or any other bootable storage device, is not required to immediately load any bootstrap code for an OS, if ever. The BIOS merely passes control to whatever exists there, as long as the sector meets the very simple qualification of having the boot record signature of 0xAA55 in its last two bytes. This is why it's easy to replace the usual bootstrap code found in an MBR with more complex loaders, even large multi-functional boot managers (programs stored elsewhere on the device which can run without an operating system), allowing users a number of choices in what occurs next. But with such freedom, there's also the possibility for abuse as addressed in the section on boot viruses.
[edit] Boot sector viruses
Since code in the boot sector is executed automatically, boot sectors have historically been a common attack vector for computer viruses. To combat this behavior, the BIOS often includes an option to prevent writing to the boot sectors of attached hard drives.
[edit] See also
[edit] References
[edit] External links
- Mary Landesman. "Boot sector viruses". http://antivirus.about.com/cs/tutorials/a/bsvirus_2.htm.
- Microsoft. "How to Protect Boot Sector from Viruses in Windows". KnowledgeBase. http://support.microsoft.com/kb/122221.
- Denny Lin. "Inexpensive boot sector virus detection and prevention techniques". http://www.lasierra.edu/~dlin/computer/virus.htm.
- Kaspersky Lab. "Boot sector viruses". Virus Encyclopedia / Malware Descriptions / Classic Viruses. http://www.viruslist.com/en/virusesdescribed?chapter=152540474#boot.
- Arman Catacutan. "Glossary of Virus Terms". Boot Viruses. http://www.trendmicro.com/en/security/general/glossary/overview.htm#Boot%20Sector%20Viruses.
- Greg O'Keefe. "Sample to build a boot program on x86 real mode". http://gok.customer.netspace.net.au/resources/.
- Susam Pal. "Writing boot sector code using GNU tools". http://susam.in/articles/boot-sector-code/.