Understanding hard disk partitioning

Source: Internet
Author: User

Understanding hard disk partitioning

A new hard disk cannot be used directly. You must partition and format it to store data.

Hard Disk partitioning is a common topic during operating system installation. For some simple applications, hard disk partitioning does not become a obstacle, but for some complex applications, we cannot help but understand some details of the hard disk partitioning mechanism.

Hard Disk crashes often occur, especially in the era of virus. You must master the techniques for restoring and backing up partitions.

When using a computer, you often use several operating systems. How do I install multiple operating systems on a hard disk?

If you need to understand this knowledge or solve the above problems, the "Hard Disk partitioning" topic will tell you the answer!

Hard Disks are one of the most commonly used storage devices on computers. We all know that computers are amazing because they have the ability to analyze and process data at a high speed. These data are stored in the hard disk as files. However, computers are not as intelligent as humans. When reading the corresponding file, you must give the corresponding rules. This is the concept of partitioning. Partitioning is essentially a format of the hard disk. When we create a partition, we have already set the physical parameters of the hard disk, specifying the Hard Disk Master Boot Record (Master Boot Record, generally referred to as MBR) and the location where the Boot Record backup is stored. For file systems and other operating systems, the required information for disk management is achieved through the advanced formatting, that is, the format command.

Surface, channels, and sectors

After a hard disk is partitioned, it is divided into a side, a track, and a sector ). It should be noted that these are just virtual concepts, and they are not really track on the hard disk. Starting from the surface, the hard disk is generally made up of one or more circular films. As we said, each circular film has two "faces", both of which are used to store data. The number of faces is called 0, 1, and 2 ...... Since each side has a dedicated read/write head, it is also commonly used with 0 heads and 1 heads ...... . According to the disk capacity and specifications, the number of hard disk faces (or heads) is not necessarily the same. Only two sides are missing, and dozens of sides can be reached. A cylinder (1) is a cylinder ). (Figure)

We mentioned the concept of track above. So what exactly is the track? Since the disk is rotated, the data written continuously is arranged in a circle. We call this circumference a track. (2) If the read/write head moves a distance along the radius of the circular film, the data written later will be arranged on another track. Based on Different Hard Disk specifications, the number of tracks can range from several hundred to several thousand; a track can accommodate several KB of data, and the host does not need to read and write that much at a time, therefore, the track is divided into several segments, each of which is called a sector. A single slice generally stores 512 bytes of data. The sector also needs to be numbered. The sectors in the same track are called one sector, two sectors ......

The efficiency of the computer's read and write to the hard disk is the basic unit of the sector. Even if the computer only needs a certain byte stored on the hard disk, it must read all the 512 bytes in the sector where the byte is located into the memory at a time, and then use the required byte. However, as we mentioned above, there is no trace on the hard disk's top, track, or sector division. Although the head can be aligned with the proper radius of a track, but how can we find the desired sector in the first and end links in a circle of sectors? It turns out that each sector is not only composed of 512 bytes, but also has some specific data before and after the data accessed by the computer, the data constitutes the boundary mark of the slice, which contains the slice number and other information. The computer uses these labels to identify the sector. (Figure)

Hard Disk Data Structure

In the previous article, we talked about the general principle of data storage on hard disks. In order to gain a deeper understanding of the hard disk, we must also have a simple understanding of the data structure of the hard disk. The data on the hard disk is divided into five parts according to their different characteristics and functions: MBR, DBR, fat, Dir, and data. Let's introduce them separately:

1. MBR Zone

MBR (Main Boot Record primary Boot Record) is located in the 0 track 0 cylinder 1 Sector of the entire hard disk. However, in a total of 512 bytes of the primary Boot Sector, MBR only occupies 446 of the bytes, And the other 64 bytes are handed over to the DPT (Disk Partition Table hard disk partition table) (see table), the last two bytes "55, AA" are the end mark of the partition. This constitutes the primary Boot Sector of the hard disk. (Figure)

The Master Boot Record contains a series of Hard Disk parameters and a boot program. The main function of the hard disk boot program is to check whether the partition table is correct and boot the operating system on the partition with the activation mark after the system hardware completes the self-check, and hand the control to the boot program. Mbris generated by a partition program (such as fdisk.exe). It does not depend on any operating system, and the hard disk boot program can also be changed to realize coexistence of multiple systems.

Next, we will use an example to help you better understand the Master Guide record:

Example: 80 01 01 00 0b Fe bf fc 3f 00 00 00 7E 86 BB 00

Here we can see that the "80" at the top is the activation mark of a partition, indicating that the system is bootable; "01 01 00" indicates that the head number starting with the partition is 01, the START slice number is 01, and the START cylinder number is 00. "0b" indicates that the partition system type is FAT32. Other commonly used slice numbers include 04 (fat16) and 07 (NTFs ); "Fe bf fc" indicates that the head number after the partition ends is 254, the end slice number is 63, and the end cylinder number is 764; "3f 00 00" indicates that the relative sector number of the first sector is 63; "7E 86 BB 00" indicates that the total number of sectors is 12289622.

2. DBR Zone

DBR (DOS Boot Record) refers to the Operating System Boot Record area. It is usually located in the hard disk's 0 track 1 cylindrical 1 sector, is the first sector that the operating system can directly access, it includes a boot program and a known as BPB (BiOS parameter block) this partition parameter record table. The main task of the boot program is to determine whether the first two files in the partition and directory are operating system boot files when the MBR gives control of the system (DOS is used as an example, that is, Io. sys and msdos. sys ). If it exists, read it into the memory and give control to the file. The BPB parameter block records important parameters such as the starting sector, ending sector, file storage format, hard disk media descriptor, root directory size, fat number, and allocation unit size of the partition. DBR is generated by advanced formatting programs (such as format.com.

3. Fat Zone

After DBR, we are familiar with the fat (File Allocation Table) area. Before explaining the concept of a file allocation table, let's talk about the concept of a cluster. When a file occupies disk space, the basic unit is not a byte but a cluster. In general, each floppy disk cluster has one sector. The number of sectors in each cluster of the hard disk is related to the total capacity of the hard disk, which may be 4, 8, 16, 32, 64 ......

The data of the same file is not necessarily completely stored in a continuous area of the disk, but is often divided into several segments and stored like a chain. This storage method is called the chained storage of files. Because the hard disk stores the connection information (FAT) between segments, the operating system can always accurately locate and read each segment while reading files.

To achieve file chain storage, the hard disk must accurately record which clusters have been occupied by files, and specify the cluster number of the next cluster for each occupied cluster. For the last cluster of a file, you must specify that the cluster has no successor cluster. These are all stored in the fat table. There are many table items in the table, and each item records the information of a cluster. Because of the importance of fat for file management, fat has a backup, that is, the same fat is created after the original fat. All items in the initial fat are marked as "not occupied", but if the disk is partially damaged, the formatting program will detect the damaged cluster, when the corresponding item is named "Bad cluster", the cluster will no longer be used when files are stored. The number of fat items is the same as the total number of clusters on the hard disk. The number of bytes occupied by each item must be consistent with the total number of clusters, because the number of clusters must be stored. There are multiple fat formats, the most common of which are fat16 and FAT32.

4. dir Zone

Dir (directory) is the root directory, followed by the second fat table (that is, the backup fat table), records the starting unit of each file (directory) in the root directory, file attributes. When locating the file location, the operating system can know the specific location and size of the file on the hard disk based on the starting unit in the Dir and the fat table.

5. Data Area

The data zone is the place where data is stored in the real sense. After the Dir zone, it occupies most of the data space on the hard disk.

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.