[Linux] Hard drive construction and partitioning

Source: Internet
Author: User

First let's look at the physical structure of the hard disk storage principle.

  Hard Drive Construction:

  

1. head: Head, magnetic head on disk surface, there are several heads, there are several disk faces. Numbering starting from 0, Max 255, indicates a total of 256 heads.

2. cylinder: Cylinder face. The tracks on each face are superimposed and look like a cylinder, so it is called a cylinder. For a single disk face, a cylinder is a track, and many concentric tracks make up a disk surface. Numbering starting from 0, Max 1023, indicates a total of 1024 tracks.

3. sector: sector. Each track can be divided into segments, each section is called a sector, the sector is the minimum disk storage unit, typically each sector stores 512 bytes of data. Numbering starts at 1, up to 63, representing 63 sectors.

 Sector:

  

You can think of a hard disk as such a cylindrical building, the building has several layers, each layer is a circular track and field, this is the disk, each track and field is composed of N runway, this is the track, each track and field has a transport athletes into the entrance of the feeder, this is the head; N Strip diameter divides the entire track and field into 2N fans, each track is divided into 2N segments, each track is a sector; each athlete is a byte and each sector can hold 512 athletes.

  

Hard drive (cylinder building):

Single disk simplex (track and field):

Knowing the head, cylinder, sector, you can calculate the hard drive capacity.

For example, the following hard disk information:

$ sudo fdisk/dev/mmcblk0-ldisk/dev/mmcblk0:31.9 GB, 31914983424 bytes4 heads, sectors/track, 973968 Cylinde RS, total 62333952 sectorsunits = sectors of 1 * all = bytessector size (logical/physical): Bytes/512
       
         BYTESI/O size (minimum/optimal): bytes/512
         bytesdisk identifier:0x00062524 Device Boot Start End Blocks I D SYSTEM/DEV/MMCBLK0P1 2048 43007 20480 6 fat16/dev/mmcblk0p2 43008 62332927 31144960 Linux  
       

The above information shows that the hard disk size is 31914983424 bytes, about 31.9 GB.

The drive has a total of 4 heads, 973,968 cylinders, 16 sectors, and 512 bytes per sector.

  HDD capacity = 4 headsx973968 cylindersx16 sectorsx512 bytes = 31914983424 bytes = 30.436 GB

The sector size is 512 bytes, but we actually store the smallest particles can be larger than 512 bytes, so in the format, we can choose the allocation unit size, that is, logical block block, for example, when we specify the format of the minimum data storage unit is 1024 bytes, then a Block is 1024 bytes, or 1 blocks equals 2 sectors.

How does the drive capacity grow?

(mechanical) Although the capacity of hard disk is increasing, the basic principle of construction has not changed much.

With the manufacturing process technology provided, the disk is becoming thinner and smaller, so a hard disk storage can be loaded with more and more magnetic film, due to the higher density of the magnetic surface, that is, the track and sector is more and more, the capacity of the natural more and more large.

There is also a technique called multi-zone recording, in which each track is divided by the same diameter, which means that there are as many sectors on each track, and that the peripheral sector is significantly wider than the inner sector, which wastes a lot of track lengths. After the introduction of the multi-zone recording technology, the peripheral tracks can be divided into more sectors, thus increasing capacity.

The above is the physical structure of the hard disk, the hard disk is just storage media, let us plan the storage of the data on the hard disk, this is the hard disk partition.

There are three hard disk partitioning concepts, namely primary partition (primary partition), extended partition (extended partition), logical partition (logical partition).

At the meaning level of the physical disk, only the primary and extended partitions, if all partitions are less than the disk capacity, the remainder is unallocated space (unallocated disk). The hard disk partition information is saved in the partition table (partition table), and the unallocated space is an unusable area outside the file system for the operating system.

For a hard disk, there is a maximum of four partitions, with at least one partition, which must contain a primary partition and at most one extended partition.

What is a partition? Why should I have a partition?

Partitioning is the partition of a hard disk into several contiguous storage areas, the partition table holds the index of the hard disk partition, and the partition information is saved in the partition table. If there is only one partition on a hard disk, the entire file system is in one partition, that is, the entire file system is stored in a contiguous region. If the storage area becomes corrupted, the file system will be compromised and the user may lose all data. For file systems, storing system data and user data separately in separate partitions prevents user data from growing to fill the entire hard drive, causing the system to crash or hang. If you use more than one partition, you can also choose to use the smallest storage unit of different capacity for partition formatting, depending on the file object being stored.

What are primary partitions and extended partitions?

The primary partition activated under the Windows platform is the boot partition of the hard disk, usually the C drive and the first partition of the hard disk. Both the primary and extended partitions of the Linux platform can be used to install the operating system core.

The primary partition is an atomic partition and can no longer be divided into different areas for use, and the data is stored directly on the storage unit of the primary partition. Extended partitions cannot be used directly to store data, and extended partitions must be partitioned into smaller storage units, logical partitions, where data is stored in logical partitions.

Primary and logical partitions are like files, and extended partitions are like directories, where hard disk space consists primarily of primary partitions, extended partitions (composed of logical partitions), unallocated space.

In general, the first partition, the rest is zoned extended partition, if not necessary, generally do not leave unallocated space to avoid wasting hard disk space.

Overall, a hard disk can only be divided into four partitions (primary and extended), one primary partition being a partition, and an extended partition can be divided into any number of logical partitions.

What is the primary boot sector?

The primary boot sector is the area of the disk's first save boot (loader) code, which is also known as the Master boot record (Mbr,main boot recording), which is intended to allow the disk operating system (DOS) to read and write to the disk, partition legitimacy judgment, The partition boot information is located, which is also generated by the disk operating system (DOS) when the disk is initialized.

The disk region is not part of the primary and extended partitions, so the master boot program is not part of any operating system installed on the hard disk. It exists as a very small special area on the disk and is not erased by the formatting commands in the partition space. The disk area can be divided into three main parts:

1. The Master Boot program (that is, the master boot Record MBR) with a space size of 446 bytes. It transfers system control to the operating system registered in the partition table after the hard drive is booted, allowing the operating system to operate the disk.

2. Partitioned Tables (dpt,disk Partition table), consisting of four partitioned tables (16 bytes each, which is why the hard disk has a maximum of four partitions).

3. End Identification (2 bytes) with a value of AA55 (hexadecimal).

In short, the role of the master bootloader is to boot the computer device into the operating system program installed on the hard disk after the hard drive is booted.

1. Sectors, tracks, sector of the hard disk

[Linux] Hard drive construction and partitioning

Related Article

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.