System Boot Process and hard disk partition structure I. Introduction to System Boot Process
The system boot process consists of the following steps)
1. Start the instance;
2. BIOS power-on self-test (post --- power on self test). The memory address is 0fff: 0000;
3. Read the first sector of the hard disk (0-headed, 0-way, 1-sector, that is, Boot Sector) into the memory address 0000: 7c00;
4. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal to, switch to another media. If there is no other starting media, the system displays "no rom basic" and then crashes;
5. Jump to 0000: Execute the MBR program at 7c00;
6. Copy the MBR to 0000: 0600 and continue the execution;
7. Search for active partitions in the primary partition table. If no active partition or more than one active partition is found, stop;
8. Read the first sector of the active partition into the memory address 0000: 7c00;
9. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal, "missing Operating System" is displayed, and then stop, or try to start a floppy disk;
10. Jump to 0000: 7c00 and continue executing the Startup Program of the specific system;
11. Start the system.
Steps (2), (3), (4), (5) are completed by the BIOS boot program; (6), (7), (, (9 ), (10) steps are completed by the MBR pilot program.
Generally, multi-system boot programs (such as smart Boot manager, bootstar, and pqboot) replace standard Master Boot records with their own boot programs, select the partition to be started before running the system startup program. some system-provided multi-system boot programs (such as Lilo and NT loader) can place their own boot programs in the first sector of the system partition, in Linux, It is a superblock of two sectors.
Note: Standard MBR is used in the preceding steps. The guiding process of multi-system boot programs is different from this.
Ii. Hard Disk structure and parameters
3D parameters (Disk geometry): CHS (cylinder/head/sector) C-Cylinder Number of cylinder cylinders indicates the number of tracks on each disk of the hard disk, the maximum size is 1024 (with 10 binary bit storage). H-head indicates that the hard disk has several heads, that is, several disks, the maximum value is 256 (which is stored in 8 binary bits). The S-sector number table shows that each track has several sectors, and the maximum value is 63 (which is stored in 6 binary bits ).
1. Boot Sector
Boot Sector
Boot Sector is the first sector of the hard disk. It consists of MBR (Master Boot Record), DPT (Disk Partition Table), and Boot Record ID. MBR, also known as the Master Boot Record, occupies the first 446 bytes of the Boot Sector (0 ~ 0x1bd), which stores the system primary Boot Program (which is responsible for loading and running the system boot program from the active partition). DPT means that the primary Partition Table occupies 64 bytes (0x1be ~ 0x1fd), which records the basic partition information of the disk. The primary Partition Table is divided into four partition items, each of which is 16 bytes and records the information of each primary partition respectively (therefore, there can be a maximum of four primary partitions ).
The Boot Record ID indicates that the boot zone mark occupies two bytes (0x1fe ~ 0x1ff). For a valid boot area, it is equal to 0xaa55, which indicates whether the boot area is valid ).
Detailed Structure of boot secor
2. Partition Table Structure
A partition table consists of four partition items. The structure of each item is as follows:
Byte state: partition status, 0 = inactive, 0x80 = activated (note this option );
Byte starthead: the start head number of the partition;
Word startsc: Start sector and Cylinder Number of the partition. The bottom 6 bits of the base byte are the fan area number, and the height 2 bits are the 9th and 10th bits of the cylinder number, the high byte is the low 8-bit of the cylindrical number;
Byte type: partition type, such as 0x0b = FAT32, 0x83 = Linux. 00 indicates that this item is not used;
Byte endhead: The ending head number of the partition;
Word endsc: End slice and Cylinder Number of the partition, which are defined in the same way as before;
DWORD relative: Address of the relative sector of the partition in linear addressing mode (absolute address for the basic partition );
DWORD sectors: partition size (total number of sectors ).
In DoS or Windows systems, basic partitions must be divided by cylindrical units (sectors * Heads sectors), for example, for hard disks with CHS of 764/256/63, the minimum partition size is 256*63*512/1048576 = 7.875 MB.
Because the first sector of the hard disk has been occupied by the Boot Sector, generally, the other 62 sectors of the first hard disk track (0 first 0) will not be occupied by the partition. some partition software may even leave all the first cylinder empty.
Extended partition structure
-------------------------------------------------
The above content is a conceptual description, which is simplified in my simple language as follows (for beginners only, do not worry about whether it is rigorous or accurate)
When the system starts, the BIOS is run first after power-on, and the BIOS then gives control to the MBR. The MBR determines the partition from which to continue the boot. The first sector of the pilot partition may be another boot program, which can further determine how to boot the system and boot.
Generally, when we only use Windows, MBR finds a Windows partition in a standard way and directs the partition to give control to ntldr (excluding WIN98 and earlier windows, ntldr is not used at that time ), ntldr to Boot Windows. If multiple Windows instances are installed together, the installer automatically adds a boot entry in the ntldr configuration.
(We recommend that you use FAT32 for the first partition and install DoS/Windows versions. We do not recommend that you use NTFS format for partitions. The reason is: first, there are more read/write restrictions than FAT32 due to system problems, is not conducive to solving the problem)
If multiple systems are installed together, boot programs may be installed on each operating system. Common is grub in Linux. Similar boot programs are available in other systems, and ntldr is used in windows. The difference is that when Windows is installed, windows always/and does not prompt, there is no other choice to overwrite MBR, and set your partition to active partition to start with ntldr. Generally, Linux, BSD, and other systems can choose to install the boot program to MBR/install the boot program to the first sector of their own partition/do not install.
For the above reasons, there is usually only one boot program installed in MBR. When different Linux systems coexist, grub can be installed in MBR by combining the boot menu. Therefore, you can select the installation sequence and select a main Bootstrap program. If you have an accurate understanding of the above content, the installation sequence is not important, as long as you finally select a boot program you want to use and you can use this boot program configuration to guide all systems.
We can choose either of the following methods:
1. Use ntldr to boot. In this way, you can first install windows in the first primary partition, then install other Linux/Unix systems in the following primary or logical partitions (note that BSD/Solaris and other UNIX systems can only be installed in the primary partition, while Linux can be installed in the logical partition ), remember not to install the boot program to MBR during installation. After the installation is complete, use some disk tools (which can read the binary data of a specific disk sector) locate the first sector of the system partition and write it as a binary file (you can view the position of the starting sector using a partition tool such as PM). Put the file under C, then in the boot. add a cxx file in ini (the name of the Sector file you obtained) = "the system you want To Boot. Available disk tools, such as diskgen under DOS. Dd available in Linux/Unix
If =/dev/xxx of = to obtain the file, it is equivalent
When ntldr is used for boot, other partitions may be set to activate and start. ntldr cannot be started at this time, and the operating system of the partition can be started directly without the ntldr Startup menu, in this way, you may not be able to Boot Windows. In this case, you only need to use the partition tool to reactivate the Windows partition.
2. Use GRUB boot. In this way, select a Linux installation and install grub to MBR. Generally, grub can automatically identify and add Windows boot. You can manually add startup items for systems such as BSD and Solaris.
My general practice is to use grub of suse10.0 as the main boot program, because SuSE has a graphical and simple grub configuration interface.
Generally, the MBR may be overwritten when the system is re-installed later (Windows will inevitably re-occupy the MBR, and Linux/Unix boot programs are generally optional ), in this case, 1) You can use the above configuration to boot with ntldr; 2) Find a Linux boot CD and reinstall grub; 3) back up the original MBR.
My practice example:
GB hard drive, five operating systems are installed, as follows: win2003 server (primary partition 1), freebsd6 (primary partition 2), Solaris 10 (primary partition 3) debian Linux and SuSE Linux (logical partitions in the extended partition share swap, and then install Suse and use grub of SUSE ), the following logical partition uses the FAT32 format as the data storage zone that can be shared by various systems. From: http://hi.baidu.com/kylfang/blog/item/2abdfa366469a1330a55a99f.html