Basic hard disk knowledge

Source: Internet
Author: User

Basic hard disk knowledge

Hard Disk dos management structure
1. Number of tracks, sectors, cylinders and Magnetic Heads
The most basic components of a hard disk are hard metal disks coated with magnetic media. The number of disks varies with the disk capacity. Each disk has two sides.
Record information. A disk is divided into multiple slices. Each slice is called a slice. Each slice can store 128x2 n (n = 0.1.2.3) bytes. In DoS
Each sector is 128 × 2 to the power of 2 = 512 bytes. The disc surface is centered around the disc. concentric circles with different radius are called magnetic channels. Hard Disk, with the same radius for different Disks
Is called a cylinder. Both the track and the cylinder are circles with different radius. In many cases, the magnetic channels and the cylinder can be used interchangeably. We know that each Magnetic Field
The disk has two sides, each of which has a head, which is used to be distinguished by the head number. Slice, track (or cylinder), and head number constitute the basic parameters of the hard disk structure.
You can obtain the disk capacity by using the following formula:
Storage Capacity = number of cores x number of tracks (cylindrical) X number of sectors X number of bytes per sector
Key points: (1) the hard disk has several disks, each of which has two sides and each side has one head.
(2) The disk is divided into multiple slices, namely, slice.
(3) concentric circles with different radius of the same disk are magnetic Channels
(4) The cylindrical surface with the same radius of different disks is the cylindrical surface.
(5) formula: storage capacity = number of cores x number of tracks (cylinder) X number of sectors X number of bytes per sector
(6) Information records can be expressed as: ×× track (cylindrical), ×× head, And ×× sector
2. Clusters
"Cluster" is the minimum unit for DOS distribution. When creating a small file, if it is a byte, it does not occupy only one byte of space on the disk,
It occupies the entire cluster. DOS depends on different storage media (such as floppy disks and hard disks), hard disks of different capacities, and cluster sizes. The cluster size can be called a disk
Parameter block (BpB. The concept of cluster is only applicable to data areas.
(1) "cluster" is the smallest unit for DOS distribution.
(2) Different storage media, hard disks of different capacities, DOS versions, and cluster sizes are also different.
(3) The concept of cluster is only applicable to data areas.
3. Sector number definition: absolute sector and DOS sector
As described above, we can use a cylindrical/head/sector to uniquely locate each area on the disk, or we can say that the cylindrical/head/sector and each sector on the disk have
One-to-one ing. Generally, DOS calls the "cylindrical/head/sector" notation as the "absolute Sector" notation. However, DOS cannot directly use absolute sectors for disks.
Information management, but the so-called "relative Sector" or "dos Sector ". The "relative Sector" is only a number, such as the relative sector number corresponding to the cylindrical 140, head 3, and Sector 4.
It is 2757. This number corresponds to the absolute Sector "cylindrical/head/sector. When the relative sector number is used, DOS starts from the cylindrical 0, head 1, and sector 1.
(Note: The cylinder is 0, the head is 0, and the sector 1 does not have the DOS sector number. It cannot be accessed under DOS and can only be accessed by calling bios.) The first DOS sector number is 0, and the remaining on the track
The Slice number is 1 to 16 (17 sectors per track), and then 17 slice with the head number 2 and the cylinder number 0. The resulting dos slice number ranges from 17 to 33. Until
All head. Then, move to the cylinder 1, head 1, and sector 1 to continue the DOS sector number, that is, the sequence of increasing by sector number, head number, and cylinder number (Track number) is continuous.
The area code of the DOS fan.
Formula: Remember DH-head number of the first DOS sector
DC-ID of the first DOS slice
DS -- fan ID of the first DOS sector
NS-number of sectors per track
NH -- total Disk Head count
The RS of a sector (cylindrical C, head H, sector S) is:
Rs = NH × NS × (C-DC) + NS × (H-DH) + (S-DS)
If RS, DC, DH, DS, NS, and NH are known
S = (RS mod NS) + DS
H = (RS Div NS) mod NH) + DH
C = (RS Div NS) Div NH) + DC
Key points: (1) an absolute sector is represented by a cylindrical/head/sector, also known as a physical disk address.
(2) A single number represents a relative sector or DoS sector, also known as a logical sector number
(3) formulas for converting relative and absolute sectors
4. Division of DOS disk Areas
After the hard disk is formatted, the entire disk can be divided into Master Boot records (MBR: Main Boot Record) and DOS boot records (DBR: DoS
Boot Record), file allocation table (fat: file assign table), root directory (BD: boot directory), and data zone. The first five important information are outside the disk.
On the track, the reason is that the circumference of the outer ring is greater than the circumference of the inner ring, that is, the storage density of the outer ring is smaller and the reliability is higher.
Key points: (1) the entire hard disk can be divided into MBR, DBR, fat, BD and data zone.
(2) MBR, DBR, fat, and BD are located outside the disk.
5. MBR
MBR is located at the first physical sector (absolute sector) of the hard disk, where the cylindrical 0, the head 0, and the sector 1. Since dos starts from the cylindrical 0, head 1, and sector 1, MBR does not belong
DOS sector, DOS cannot be accessed directly. MBR contains the Master Boot Program of the hard disk and the partition table of the hard disk. A partitioned table has four partition record zones. The record area is used to record the partition information.
A table. It is stored continuously from the offset 01beh of the primary Boot Record, and each partition record area occupies 16 bytes.
Partition Table Format
The offset of the Partition Table item indicates the number of bytes occupied.
00 boot indicator 1b
01 disk ID 1B of the partition guide record
02 partition guide record sector and cylinder number 2B
04 system indicator 1b
05 partition end head 1b
06 partition end slice and cylinder 2B
08. number of sectors before the partition 4B
The total number of sectors in the 0C partition 4B
Only one active partition exists in the four partitions, namely, drive C. The identifier is 80 h at the first byte of the partitioned table. If it is H, it indicates the inactive partition. For example:
80 01 01 00 0b Fe 3f 81 3f 00 00 00 C3 dd 1f 00
00 00 01 82 05 Fe BF 0C 02 de 1f 00 0e 90 61 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00
Key points: (1) MBR is located at the first physical sector of the hard disk, where the cylinder is 0, the head is 0, and the sector is 1. Does not belong to the DOS sector,
(2) The Master Boot Record is divided into the master boot program of the hard disk and the hard disk partition table.
6. DBR
DBR is located in the cylindrical 0, head 1, Sector 1, that is, the logical sector 0. DBR is divided into two parts: DOS boot program and BPB (BiOS parameter block ). The dos boot program is complete.
Location and loading of the DOS system file (Io. sys, msdos. sys), while BPB is used to describe the disk information of the DOS partition. BPB is at the 0bh offset of DBR, a total of 13 bytes.
It contains the parameters used for logical formatting, which can be used for the file allocation table on the DOS computing disk, the starting address of the Directory area and data area, and the physical lattice provided by three words after BPB.
Parameters used for normalization (low-case. Based on this information, the boot program or device driver converts the Logical Disk address (DOS Sector Code) to a physical address (absolute
Fan area number ). BPB format
Meaning of serial number offset address
1 03h-0ah OEM No.
2 0bh-0ch number of bytes per sector
3 0dh number of sectors per cluster
4 0eh-0fh reserved slice count
5-10 h fat backup count
6 11 h-12 h root directory entries
7 13 H-14 h total number of disks
8 15 h description Media
9 16 h-17 h per fat sector
10 18 h-19 h number of sectors per track
11 1ah-1bh head count
12 1ch-1fh special hidden sector count
13 20 h-23 h total slice count
14 24 h-25 h physical drive count
15 26 h extended guide visa
16 27h-2ah volume series
17 2bh-35h volume label
18 36h-3dh file system number
DOS Boot Record formula:
Number of reserved slice in the Partition Table
Number of sectors retained in the root directory + number of fat sectors × number of sectors of each fat
Data Partition root directory logical sector number + (32 × Number of directory items in the root directory + (number of bytes per sector-1) Div bytes per sector
Absolute fan area number, logical fan area number, and number of hidden sectors
Sector number (absolute sector number mod number of sectors per track) + 1
Head number (absolute sector number Div per track sector number) mod head number
Track No. (absolute sector No. Div number per track sector) Div head number
Key points: (1) DBR is located in the cylindrical 0, head 1, Sector 1, and its logical sector number is 0
(2) DBR contains the DOS boot program and BPB.
(3) BPB is very important, so we can calculate the logical and physical addresses.
7. File Allocation Table
The file allocation table is the main component of the DOS file structure. We know that the most basic unit for DOS distribution is the cluster. The file allocation table reflects
You can view the usage of any cluster by querying the file allocation table. DOS scans fat first when allocating space to a file and finds the first
Use a cluster to allocate the space to a file and fill in the cluster number of the cluster to the corresponding segment of the directory. It forms a "cluster ID chain ". Fat is a table that records the file cluster number.
The first two fields of fat are reserved fields, which are 3 bytes for fat12 and 4 bytes for fat. The first byte is used to describe the media, and the remaining byte is FFH.
. The media format is the same as that of BPB.
The 8-bit meaning of the first byte:
7 6 5 4 3 2 1 0
──-┘ │ ┌ 0 non-Dual-sided
Set 1 │ └ ┤
│ └ 1 dual-sided
│ Limit 0 is not an 8-sector
│ Zookeeper
│ Sector 1 is an 8-sector
│ Limit 0 is not interchangeable
Zookeeper
Shard 1 is changeable
Fat structure meaning
Fat12 fat16 meaning
0000 h available
FF0H-FF6H FFF0H-FFF6H retention
Ff7h fff7h bad
FF8H-FFFH FFF8H-FFFFH file last cluster
Next cluster in the xxx File
For fat16, cluster No. × 2 is used as the offset address, and a field from fat is taken as the field in fat.
Logical sector number = start logical sector number of the data area + (cluster number-2) × number of sectors per cluster
Cluster number = (logical sector number-logical sector number starting from the data area) Div number of sectors per cluster + 2
Key points: (1) fat reflects the usage of all clusters on the hard disk. It records the specific location (cluster) of files in the hard disk ).
(2) The first cluster number of the file (in the directory table) and the cluster number of the FAT file form the "cluster number chain" of the file. restoring the damaged file is the root
Data chain.
(3) The cluster number can be used to calculate the logical fan area number. On the contrary, the logical fan area number can also be used to calculate the cluster number. The formula is as above.
(4) After fat is located in DBR, its dos fan area number starts from 1.
8. File directory
The file directory is another important component of the DOS file structure. There are two types of file directories: root directory and sub-directory. There is one root directory and one subdirectory can be
Multiple. Sub-directories can also contain sub-directories to form a "Tree" file directory structure. Sub-directories are actually special files. Dos assigns 32 characters to directory items.
Section. There are three types of directory items: files, subdirectories (including many directory items), and volume labels (only one in the root directory. There are files (or sub-projects) in the directory
Name, extension, attribute, date generated or last modified, time, start cluster number, and file size.
Directory item format
Number of characters in bytes offset meaning
00 h file name 8b
08 h extension 3B
0bh File Attribute 1b
0ch retain 10b
16 h time 2B
18 h date 2B
1ah start cluster number 2B
1ch file length 4B
The first byte in the directory item file name area has special significance: 00h indicates that it is not used.
05h indicates the actual name is e5h.
Ebh indicates that the file has been deleted.
The meaning of each byte in the directory item attribute area is as follows: 7 6 5 4 3 2 1 0
Unrepaired subvolume system hidden only
Use the change object to mark the system as a Tibetan Reader
Labelled genus
Ambition
Note: The windows long file name uses the "retained" area described in the preceding table.
Key points: (1) the file directory records all files, sub-directory names, extension attributes, and the last modification date of Creation or Deletion. File start cluster number and file length
Registration Form.
(2) The content training listed by Dir in DOS is obtained based on the file directory table.
(3) Fill in the starting cluster number of the file in the file directory, and fill in the remaining clusters in the position of the cluster on the fat.
9. Physical drive and logical drive
The physical drive refers to the actually installed drive.
The logical drive is generated after formatting the physical drive.
Key points: Same as above.

Postscript: This article is part of the book "external memory of computer systems", with some changes. This is all about the DOS management structure in the basic knowledge of the hard disk. Others
For more information about hard disks, see the original book.

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.