Introduction to Linux hard disk partitioning

Source: Internet
Author: User
Article Title: Linux hard disk partition Knowledge Overview. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In Linux, disks of different interface types can be mounted, and each disk can be divided into several partitions ), each partition can have its own file system type ). Linux has its own set of marking methods for disks and partitions.

Distinction between hard disk and partition

The first SCSI (Small Computer System Interface) disk is/dev/sda, the second SCSI disk is/dev/sdb, and the first SATA disk is/dev/hda, the second is/dev/hdb, and so on. In Linux, each partition number of each disk starts from 1. For example, the first partition of the first SCSI disk is/dev/sda1, and the second partition is/dev/sda2.

Partition Structure

A raw disk that has not been partitioned is like a land with no meaningful data. The hard disks in different zones have certain structural characteristics. Partitioning refers to dividing a hard disk into a certain area for ease of use. A hard disk can be divided into up to four partitions (primary partition ). No matter how many zones the hard disk is divided into, there is a boot sector (Master Boot Record MBR) at the beginning of the hard disk ).

The primary Boot Record consists of three parts: the Operating System Boot Code starting with 446B, followed by the 64-byte primary partition table. The primary Partition Table records the partition information of a maximum of four primary partitions, including the START/end cylinder, size, and type of the partition. Each partition record occupies 16 B. Partition is to modify the Partition Table, which does not affect the data stored on the hard disk. The end sign of 2 bytes is 0 x 55AA (01010101 10101010 ).

Extended technology: because a partition table can only contain up to four partition records, if you need to divide a hard disk into more than five partitions, you need to change one of the four primary partitions to an extended partition, and then create a logical partition in the extended partition. Partition information of a logical partition is stored in an extended partition, which is called an extended partition table. Theoretically, there is no limit on the number of logical partitions. Extended partitions cannot be used directly. They must be divided into several logical partitions. Information about the starting position of a logical partition is written in the extended partition table. The Partition Number of the logical partition starts from 5. For example,/dev/sda5 is the first logical partition of the first hard disk.

Format

In fact, formatting is to create a certain type of file system for a partition. Partitions without a file system cannot be used by the operating system, and meaningful data cannot be written. The existence of a file system is to enable the operating system to write and store data in an organized and disciplined partition of a hard disk. Of course, the data must be read as is.

When a file system is created for a partition, the original data of the partition will be erased, and it is difficult to restore the data. In particular, when formatted partitions are re-written into data, it is impossible to restore the previous data.

Use of partition tools

In Linux, there are two main named partition management tools fdisk and parted. I often use fdisk. As for parted, it may be more flexible and supports non-interactive mode. You can view the corresponding man. The following is a brief introduction to fdisk. For more information, see Manual.

Fdisk usage example

List the structure and partition table information of each disk:

Ivan @ ivan-desktop :~ $ Sudo fdisk-l

[Sudo] password for ivan:

Disk/dev/sda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Disk identifier: 0x0003ce53

Device Boot Start End Blocks Id System

/Dev/sda1*1 3825 30720000 7 HPFS/NTFS

/Dev/sda2 3825 7650 30720000 7 HPFS/NTFS

/Dev/sda3 7650 11474 30720000 7 HPFS/NTFS

/Dev/sda4 11475 19457 64123447 + 5 Extended

/Dev/sda5 11475 14444 23856472 + 7 HPFS/NTFS

/Dev/sda6 19247 19457 1694826 82 Linux swap/Solaris

/Dev/sda7 14445 15660 9767488 + 83 Linux

/Dev/sda8 15661 19246 28804513 + 83 Linux

Partition table entries are not in disk order

Disk/dev/sdb: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Disk identifier: 0x3571e2ec

Device Boot Start End Blocks Id System

/Dev/sdb1*1 9729 78148161 7 HPFS/NTFS

Ivan @ ivan-desktop :~ $

[1] [2] Next page

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.