Today's Question:  What does your personal desk look like?        GIVE A SHOUT

How does computer boot up?

  sonic0002        2013-02-23 23:19:47       8,446        0    

The whole boot process of computer can be summarized in 4 phases.

1. BIOS

In the 70's  read-only memory(ROM) was invented. The boot program is written into ROM, the first thing the computer does is to read and execute this program when it's powered on.

The program in this chip is called "Basic Input/Output System" (BIOS).

1.1 Power-On Self-Test

The BIOS will first check whether the computer hardware can fulfill the basic conditions for booting up, this process is called Power-On Self-Test, simplified as POST.

If the hardware has problems, the mother board will produce different beeps and the boot process will be terminated. If there is no issue, then CPU, memory and hard disk information will be displayed.

1.2 Boot sequence

After the POST, BIOS will handover the control to the next level program. Now the BIOS needs to know which device the next level program is stored, i.e, BIOS needs to know a sequence of external devices to look for the program. This sequence is called Boot Sequence.

In the BIOS console, you can set the boot sequence.

2. Master boot record

BIOS will handover the control to the first device in the Boot Sequence. Now the computer will read the first sector of this device which is the first 512 bytes. If the last two bytes are 0x55 and 0xAA in the 512 bytes, then the device can be booted.If they are not, then this device cannot be booted. The control will be handed over to the following device.

The first 512 bytes is called Master boot record(MBR).

2.1 Structure of Master boot record

Master boot record only has 512 bytes, it cannot contain too much information. The main function of it is to tell the computer where to find the OS in the hard disk.

Master boot record consists of three parts:

    (1) 1-446 bytes:call the machine code of the OS。

  (2) 447-510 bytes :Partition table。

  (3) 511-512 bytes: Master boot record signature (0x55 and 0xAA)。

The function of Partition Table is to divide the hard disk into different partitions.

2.2 Partition table

Hard disk partition have many advantages. Different partitions can have different OS installed. Hence master boot record must know which partition to hand the control over. to.

The size of the partition table is 64 bytes, consisting of 4 parts, each part has 16 bytes. So each hard disk can be divided into 4 primary partition named main partition.

   (1) Byte 1: if it is 0x80,it means this main partition is the active partition,control will be handed over to this partition. Only one partition can be active at any time

  (2) Byte 2-4 :The physical location of the first sector of the main partition

  (3) Byte 5 :main partition type。

  (4) Byte 6-8:The physical location of the last sector of the main partition。

  (5) Byte 9-12:The logical address of the first sector of the main partition

  (6) Byte 13-16:The number of sectors in the main partition。

3. Hard disk boot

In this case, the control of the computer is handed over to one partition, here again we have three cases.

3.1 Case A: Volume Boot Record

Previously we mentioned there are four primary partitions inside hard disk, only one is active among them. The computer will read the first sector of the active partition, called volume boot record(VBR).

Volume Boot Record is to tell the computer that the operating system is in this partition. Then, the computer will load the operating system.

3.2 Case B: extended and logical partitions

With the size increasing of hard drive, four primary partitions are no longer enough, you need more partitions. However, there are only partitions in the partition table, so one partition can be defined as used as extended partition.

The so-called "extended partition" can be further divided into multiple partitions. This partition inside the extended partition is called logical partition.

The computer first reads the first sector of the extended partition called the extended boot record (EBR). It also contains a 64-byte partition table, but only a maximum of two records can be stored (two logical partitions).

The computer then reads the first sector of the second logical partition, and then find the location of the third logical partition in the partition table, and so on, until a logical partition, partition table only contains itself (that is only one partition). Therefore, the extended partition can contain numerous logical partitions.

If the operating system is actually installed in the extended partition, generally we use the following way to start.

3.3 Case C: Boot Loader

In this case, the computer reads the master boot record the first 446 bytes of machine code. The control is no longer forwarded to a partition, but running pre-installed boot loader, asking the user to select which OS to boot.

In Linux environment, the most popular boot loader is Grub.

4. Operating System

After handing control over to the operating system, the operating system kernel is first loaded into memory.

In Linux system, for example, first the kernel in /boot directory will be first loaded. Once the kernel loaded successfully, the first program to run is /sbin/init. It will generate the init process according to configuration file (/etc/initab in Debian system). This is the first process after Linux boot,  PID is 1, other processes are its offspring.

The init thread will load other system modules, such as Window procedures and network program until execute /bin/login program to jump out of the login screen, waiting for the user to enter a user name and password.

At this point, all the startup process is complete.

Author : é˜®ä¸€å³° Source : http://www.ruanyifeng.com/blog/2013/02/booting.html

COMPUTER  PARTITION  BOOT 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.