Structure of the Hard Disk File System

Source: Internet
Author: User
We can't use a hard disk when we buy it. You need to partition and format it before installing the operating system. We generally want to divide the hard disk into five parts: the Main Boot Sector, the Operating System Boot Sector, the fat table, the Dir directory area and the data area. Generally, the primary Boot Sector MBR is unique in a hard disk. The MBR content is read only when the hard disk is started and then resident in the memory. The other items vary with the number of hard disk partitions.

1. Primary Boot Sector (MBR)

The primary Boot Sector is located in the 0 track 0 cylinder 1 Sector of the entire hard disk, including the Hard Disk Master Boot Record MBR (main
Boot Record) and Partition Table DPT (Disk Partition
Table ). The primary Boot Record is used to check whether the partition table is correct and to determine which partition is a bootstrap partition. At the end of the program, it starts the program for the partition (that is, the operating system boot sector) transfer to memory for execution.

2. Partition Table (DPT)

In the primary boot area, the content of the 64 bytes starting from the address be and ending with FD is usually referred to as the partition table. The partition table starts with 80 h or H and ends with 55aah. Each partition occupies 16 bytes. A hard disk can be divided into up to four primary partitions. The extended partition is also a primary partition. With the rapid expansion of hard disk capacity, the number of hard disk partitions can be extended to "Z" without being limited by four primary partitions ".

The value is that mbris generated by the partition program (fdisk.exe for example, dos). different operating systems may have different content codes for this sector, but only one function is implemented, so that one of the active partitions can obtain the control area and start the system normally.

The primary partition is a relatively simple partition, usually located in the first area of the hard disk, forming a logical C disk. Other logical disks cannot be created in the primary partition. You can also use the partition software to create a primary partition at the end of the partition, or create a primary partition in the middle of the disk.

The concept of extended partitions is complicated, which is also the main cause of confusion between partitions and logical disks. Since the hard disk only saves 64 bytes of storage space for the partition table, and the parameters of each partition occupy 16 bytes, the data in the master boot sector can store a total of 4 partitions. The operating system can only store data in four partitions. If a logical disk is a partition, the system can only store four logical disks. For specific applications, four logical disks cannot meet the actual needs. To create more logical disks for the operating system, the system introduces the concept of extended partitions.

The so-called extended partition is not actually a partition. It is just a pointer to the next partition. This pointer structure will form a one-way linked list. In this way, in addition to the primary partition, only the partition data called the extended partition needs to be stored in the primary Boot Sector, the data of this extended partition can be used to locate the starting position of the next partition (which is actually the next logical disk), and then all the partitions can be found. No matter how many logical disks are created in the system, you can find each Logical Disk one by one in the primary boot sector using the parameters of an extended partition.

Note that each partition after the primary partition is linked through a one-way linked list structure. Therefore, if a problem occurs in the one-way linked list, the Logical Disk may be lost. After the hard disk is damaged by the CIH virus, we can use the F10 function of kv3000 to find the reason for the loss of D, E and subsequent logical partitions.

3. Operating System Boot Sector (obr)

Obr (OS boot
Record) is the operating system boot sector, usually located in the hard disk's 0 track 1 cylindrical 1 Sector (this is for DOS, for systems started in Multi-boot mode, they are located in the corresponding primary partition/
The first sector of the extended partition) is the first sector that the operating system can directly access. It also includes a boot program and a BPB (BIOS
Parameter
This partition parameter record table. In fact, each logical partition has an obr. Its parameters vary depending on the partition size and operating system category.

The main task of the Bootstrap program is to find the system file IO in the root directory. sys, msdos. sys and winboot. if there are three sys files, put Io. the sys file is read into the memory and handed over control to the file. In the Win98 system, there is no msdos. SYS file, the system can be started normally, but cannot enter the desktop; if there is no command. COM file, can be started to the desktop normally, but cannot enter the DOS character mode.

BPB parameter block: records the starting sector, ending sector, file storage format, hard disk media descriptor, root directory size, number of fat, allocation unit (Allocation
Unit. Obr is generated by advanced formatting programs (such as DoS ).
).

4. File Allocation Table (FAT)

Fat (File Allocation
Table) is the file allocation table, which is the file addressing system of the DOS/Win9x system. To prevent accidental damage, fat generally performs two backups (or one can be set), and the second fat is the backup of the first fat, followed by the fat area after the obr (for FAT32 format, the position is the position of the first fat table in the first 32nd sectors starting from the boot sector. The size is determined by the size of the partition space and the size of the file allocation unit.

With the rapid development of hard disk capacity, Microsoft
DOS and Windows are also in the fat12, fat16, and FAT32 formats that we are familiar. However, Windows
NT, OS/2, Unix/Linux, and Novell all have their own file management methods, different from the FAT file format.

Fat12 uses 12bit to represent the cluster location, the maximum capacity is 32 MB, and fat16 uses two bytes of 16bit to represent the cluster location, the maximum partition capacity is 2 GB, FAT32 uses four bytes to represent the cluster location. The maximum partition capacity is 65 GB.

5. Directory (DIR)

DIR is short for directory, which is the root directory. In the fat12 and fat16 formats, Dir follows the second fat table, while in the FAT32 format, the location of the root directory can be anywhere in the partition. The starting position is given by the Boot Sector. A single fat table cannot determine the specific location of the file on the disk. Only when the fat table and the Dir area are used together can the exact location of the file be located accurately.

Dir records the file names and extensions of each file (directory), whether long files are supported, starting units (this is the most important), file attributes, size, and creation date, modify the date and other residential content. When reading and writing files, the operating system can know the specific location of the file on the disk based on the starting unit in the Dir and the fat table, and then read the content of each cluster in sequence.

6. Data Zone)

After the Dir area, it is the real data storage area, that is, the data area.

Although data occupies the vast majority of the hard disk space, it does not have the previous parts. For us, it can only be some boring binary code, without any significance.

Note: The formatting Program (Advanced formatting, such as the format program in DOS) is not used to clear data in the data area, but only to overwrite the fat table, unless you use "Format
X:/u command to force "F6" to be written to each slice ".

As for hard disk partitions, only MBR and obr are modified. The data in most data areas is not changed, which is also the reason why many hard disk data can be repaired. Even so, if one of MBR, obr, fat, and Dir is damaged, our data cannot be read normally.

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.