1. Hard Disk Structure

Source: Internet
Author: User
1. Hard Disk Structure

1. Hard Disk Parameters

So far, the hard disk parameters are commonly referred to as the old CHS (cylinder/head/sector) parameters. Why are these parameters used? What are their meanings? What are their values?
A long time ago, when the disk capacity was very small, people used a structure similar to a floppy disk to produce hard disks. that is, each track of a hard disk has the same number of sectors. the so-called 3D Parameter (Disk geometry) is generated ). this includes the number of cores (heads), cylinders, sectors, and corresponding addressing methods.
Where:
The number of magnetic heads (heads) indicates that the hard disk has a total of several heads, that is, the number of disks with a maximum size of 255 (stored in 8 binary bits );
Cylinders indicates the number of tracks on each disk of the hard disk. The maximum value is 1023 (which is stored in 10 binary bits );
The number of sectors (sectors) indicates that each track has several sectors. The maximum value is 63 (6 binary bit storage ).
Each slice is generally 512 bytes. Theoretically, this is not necessary, but it seems that there is no other value.
Therefore, the maximum disk capacity is:
255*1023*63*512/1048576 = 8024 GB (1 m = 1048576 bytes) or hard disk vendor commonly used units:
255*1023*63*512/1000000 = 8414 GB (1 m = 1000000 bytes)
In the CHS addressing mode, the value ranges from 0 to heads-1, 0 to cylinders-1, and 1 to sectors (starting from 1 ).
2. introduction to basic INT 13 H calls
The bios int 13 H call is an interrupted call of the basic input and output of the disk provided by the BIOS. It can reset, read/write, verify, locate, and diagnose the disk (including the hard disk and floppy disk, formatting and other functions. it uses the CHS addressing mode, so it can access a hard disk of about 8 GB at the maximum (if not specified in this Article, the unit is 1 MB = 1048576 bytes ).
3. Introduction to modern hard disk structures
In an old hard disk, because the number of sectors of each track is equal, the record density of the external track is much lower than that of the internal track, which wastes a lot of disk space (the same as that of a floppy disk ). in order to solve this problem and further increase the hard disk capacity, people use an equi-density structure to produce hard disks. that is to say, the sector of the outer ring track is more than that of the inner ring track. after this structure is used, the hard disk no longer has actual 3D parameters, and the addressing mode is changed to linear addressing, that is, addressing is performed in units of sectors.
To be compatible with old 3D addressing software (such as biosint13h), an address translator is installed inside the hard disk controller, it translates old 3D parameters into new linear parameters. this is why there are multiple options for the 3D parameters of the hard disk (different working modes correspond to different 3D parameters, such as LBA, large, and normal ).
4. Introduction to extended INT 13 H
Although modern hard disks have adopted linear addressing, due to the limitations of int13h, programs that use the bios int 13 H Interface, such as DOS, can only access hard disk space of less than 8 GB. to break this restriction, Microsoft and other companies have developed extended INT 13 H (Extended int13h) and used linear addressing to access hard disks. Therefore, they have broken through the 8g limitation, it also supports removable media (such as removable hard disks.
II. Introduction to the boot sector structure
1. Composition of Boot Sector
The boot sector is the first sector of the hard disk. It consists of three parts: MBR (masterboot record), DPT (Disk Partition Table), and Boot Record ID.

MBR, also known as the Master Boot Record, occupies the first 446 bytes (0 to 0x1bd) of the boot sector and stores the system Master Boot Program (it is responsible for loading and running the system boot program from the active partition ).
DPT indicates that the primary Partition Table occupies 64 bytes (0x1be to 0x1fd) and 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, a maximum of four primary partitions can be created ).
The Boot Record ID indicates that the boot zone mark occupies two bytes (0x1fe and0x1ff). For a valid boot zone, it is equal to 0xaa55, which indicates whether the boot zone is valid.
The detailed structure of the boot sector is shown in (see the article about the "nightowl ):
The following is the end time of OH (39%) │ <q> │ hour/pgup/pgdn mobile │? Auxiliary instructions │
0000 bytes ------------------------------------------------ bytes
Zookeeper
Zookeeper
Slave Master Boot Record failed
Zookeeper
Zookeeper
Bytes primary Boot Record (446 bytes) bytes
Zookeeper
Zookeeper
Zookeeper
01bd commandid
01be certificate -------------------------------------------------- Certificate
Zookeeper
01cd bytes partition information 1 (16 bytes) bytes
01ce certificate -------------------------------------------------- Certificate
Zookeeper
01dd percentile partition information 2 (16 bytes) bytes
01de certificate -------------------------------------------------- Certificate
Zookeeper
01ed bytes partition information 3 (16 bytes) bytes
01ee certificate -------------------------------------------------- Certificate
Zookeeper
01fd bytes partition information 4 (16 bytes) bytes
Certificate ---------------------------------------------- Certificate
201701fe 000001ff limit
Listen 55 then aa then
Certificate ---------------------------------------------- Certificate

2. Introduction to 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: Start head number of the partition
Word startsc: Start slice and Cylinder Number of the partition. The lowest 6 bits of the base byte are the sector numbers,
The 2-digit height is the 9th and 10th digits of the cylinder number, and the 8-digit height is the 8-digit lower part of the cylinder number.
Byte type: partition type, such as 0x0b = FAT32, 0x83 = Linux, etc,
00 indicates that this item is not used, 07 = NTFS
Byte endhead: the end head of the partition.
Word endsc: End sector and Cylinder Number of the partition, which are defined in the same way as before.
DWORD relative: Address of the partition relative sector in linear addressing mode
(The basic partition is an absolute address)
DWORD sectors: partition size (total number of sectors)

Note: in DOS/Windows, the basic partition must be in the cylindrical unit.
(Sectors * Heads sectors), such
The minimum size is 255*63*512/1048576 = 7.844 MB.

3. Introduction to extended partitions

Because the primary Partition Table can only be divided into four partitions and cannot meet the requirements, an extension is designed.
Partition format. Basically, the extended partition information is stored in the form of a linked list.
Other places.
First, the primary Partition Table must have a basic extended partition item. All the extended partitions belong to it,
That is to say, the space of all other extended partitions must be included in this basic extended partition.
For DoS/Windows, the extended partition type is 0x05.
All other extended partitions except the basic extended partitions are stored in the form of a linked list.
The data items of an extended partition are recorded in the Partition Table of the previous extended partition, but two extended partitions
Does not overlap.
An extended partition is similar to a complete hard disk and must be further partitioned before it can be used.
Only one other partition exists in the displayed partition. This partition is a logical disk in the DOS/Windows environment.
Therefore, the partition table of each extended partition (also stored in the first sector of the extended partition) is the most
There can be only two partition data items (including the data items in the next extended partition ).
The extended partitions and logical disks are as follows:

Certificate ----------------------- certificate --------
Worker primary extended partition (/dev/hda2) Worker ^
Certificate ----------------------- certificate Certificate
Shard expansion shard Item 1 shard -- shard
Certificate certificate ------------ certificate Certificate
Partition Table partition Item 2 partition -- + -- Partition
Certificate ----------------------- certificate Certificate
Too many other users
Worker Logical Disk 1 (/dev/hda5) Worker <-/worker
¦
Certificate ----------------------- certificate master
Shard extended partition 2 shard <----/
¦ ----------------------- ¦
¦ ¦ Partition Item 1 ← -- ¦ ---------- ¦
Partition Table partition Item 2 partition -- + -- partition ----------------------- partition Partition
¦
Primary Logical Disk 2 (/dev/hda6) Primary <-/primary Partition
¦
Certificate ----------------------- certificate Certificate
Shard extended partition 3 shards <----/shard
Certificate ----------------------- certificate Certificate
Shard expansion shard Item 1 shard -- shard
Certificate certificate ------------ certificate Certificate
Partition Table partition Item 2 partition items
Certificate ----------------------- certificate Certificate
¦
Volume Logical Disk 3 (/dev/hda7) volume <-/volume
¦
Certificate ----------------------- certificate ---------
¦ ¦ Partition Item 1 ← -- ¦ ---------- ¦
Partition Table partition Item 2 partition -- + -- partition ----------------------- partition Partition
¦
Primary Logical Disk 2 (/dev/hda6) Primary <-/primary Partition
¦
Certificate ----------------------- certificate Certificate
Shard extended partition 3 shards <----/shard
Certificate ----------------------- certificate Certificate
Shard expansion shard Item 1 shard -- shard
Certificate certificate ------------ certificate Certificate
Partition Table partition Item 2 partition items
Certificate ----------------------- certificate Certificate
¦
Volume Logical Disk 3 (/dev/hda7) volume <-/volume
¦
Certificate ----------------------- certificate -------------

3. The system startup process consists of the following steps (taking hard disk boot as an example ):

1. Boot :-)
2. Power on self test -- Post)
The memory address is 0 FFFF: 0000.
3. Set the first sector of the hard disk (0-header, 0-channel, 1-sector, that is, bootsector)
Read Memory Address 0000: 7c00.
4. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal
Then try another start media. If there is no other start media, it is displayed
"No Rom basic" then crashes.
5. Jump to 0000: 7c00 and execute the program in MBR.
6. MBR first copies itself to 0000: 0600, and then continues to execute.
7. Search for active partitions in the primary partition table.
If there is more than one active partition, stop it.
8. Read the first sector of the active partition into the memory address 0000: 7c00.
9. Check if (Word) 0000: 7dfe is equal to 0xaa55. If not
Show "missing Operating System" and stop, or try
Start a floppy disk.
10. Jump to 0000: 7c00 and continue executing the Startup Program for the specific system.
11. Start the system...

In the above steps, steps 2, 3, and 4 are completed by the BIOS boot program. 6, 7, 8, 9, 10
Step by the MBR boot program.
General multi-system boot programs (such as smartfdisk, bootstar, and pqboot)
Both Replace the standard Master Boot Record with your own boot program and start the program in the running system.
Select the partition to be started.
Some system-provided multi-system boot programs (such as Lilo and NT loader)
You can place your own boot program in the first sector of the system partition.
Is superblock (in fact, superblock is two sectors ).

Note: The above steps use standard MBR and guidance from other multi-system boot programs.
The process is different.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.