HDD Partition Memo (primary partition, extended partition and logical partition) and Linux hard disk partitioning tool parted introduction

Source: Internet
Author: User
Tags uuid dell r710

Scene: Recently in the basic knowledge of Linux, the inevitable design to the Linux disk partition, before the summary, but the kind of summary is to copy someone else's article, summed up do not want to see the second time, so it is easy to forget! Clearly understand the partition, I will be able to operate on their own computer!

1 Primary partition

We know that the first sector of the hard disk, which is the No. 0 sector, is used to hold the master boot record (MBR) , so it is also called an MBR sector.

A sector is 512 bytes, so the MBR size is also 512 bytes, the specific data structure is: 446-byte boot code, 64-byte partition table and 2-byte signature value "55AA".

Because the MBR partition table has only 64 bytes, and each partition information requires 16 bytes, this determines that it can store only 4 partition records. This is why a hard drive can have up to 4 "primary partitions".

Remember,"primary partition" refers to the partition that is recorded in the MBR partition table of the master boot record, except that the primary partition is not special, but some old operating systems in the past often cannot be installed on partitions outside the primary partition, so the primary partition is labeled "Specifically for installing the operating system".


We already know that the sub-table area in the MBR can only hold 4 partitions (that is, 4 primary partitions), how the system divides more than 4 partitions?

A straightforward and simple idea is to subdivide one of the main partitions and derive a two-level partition table . Yes, the primary partition that is used for two partitions is the "extended partition", and the two-level partition below It is the "logical Partition".

PS: The relationship between the primary partition, the extended partition, and the logical partition.

about how to use the parted tool in Linux under the partition, here reprinted an article, explained very clearly. Original source: http://dngood.blog.51cto.com/446195/647702/

2 Keywords 2.1 MBR and 2TB Limitations

When using fdisk to create a partition, we can only create a partition of 2TB size, if your disk (array) is larger than 2TB, only by dividing multiple partitions to make full use of the disk capacity, which is less than the 2TB partition of the friend has no effect,

But for the use of more than 2TB partition (such as 5TB Partition) will encounter problems, to break through this limit; let's first understand the next MBR (Master Boot Record) and GPT (GUID Partition Table).

2.2 MBR

The Master boot record (master boot record, abbreviation: MBR), also known as the Primary boot sector , is the first sector that must be read when the computer accesses the hard disk, and its three-dimensional address on the hard disk is (cylinder, head, sector) = (0, 0,1).

MBR is produced by a partitioner (such as fdisk,parted), which does not depend on any operating system, and the hard drive boot program can also be changed to enable multi-system booting.

The structure of the master boot record lets you know that it contains only a 64-byte hard disk partition table. Because each partition information requires 16 bytes, it is possible to identify up to 4 primary partitions for a hard disk with MBR-type partition structure (the Disk volume label type is MS-DOS).

It is not possible to get more than 4 primary partitions for a hard disk with this type of partitioning structure.

Here we need to draw out the extended partition:

An extended partition is also a primary partition (Primary partition), but it differs from the primary partition in that it can theoretically be divided into countless logical partitions, each with an extended boot record (EBR) similar to the MBR structure.
In the MBR partition table, up to 4 primary partitions or 3 primary partitions + one extended partition, which means that the extended partition can only have one, and then subdivided into multiple logical partitions.
On a Linux system, the hard disk partition is named SDA1-SDA4 or HDA1-HDA4 (where a means that the hard disk number may be a, B, C, and so on). On an MBR hard disk, partition number 1-4 is the primary partition (or extended partition), and the logical partition number can only start at 5 .
In the MBR partition table, the maximum capacity of a partition is 2T, and the starting cylinder for each partition must be within the first 2T of the disk (the starting cylinder cannot exceed 2T).

If you have a 3T hard drive, you should at least divide it into 2 partitions, and the starting sector of the last partition will be in the first 2T space of the hard disk. If the hard disk is too large, you must use GPT instead.

2.3 GPT

The globally unique identity partition table (GUID Partition table, abbreviation: GPT) is the partition structure of an entity hard disk. It is part of the EFI (Extensible Firmware Interface standard) to replace the master boot Record partition table in the BIOS.

However, because the MBR partition table does not support partitions larger than 2.2TB (2.2x1012 bytes), there are some BIOS systems that replace MBR partitioned tables with GPT partitioned tables in order to support large-capacity hard disks.

In the MBR hard disk, the partition information is stored directly in the master boot Record (MBR) (the master boot record also stores the system's boot program). However, in the GPT hard disk, the location information of the partition table is stored in the GPT header, for compatibility reasons, the first sector of the hard disk is still used as the MBR, then the GPT header .

Compared to the style of MBR disk partitioning that supports a maximum volume of 2 TB (terabytes) and a maximum of 4 primary partitions per disk (or 3 primary partitions, one extended partition and unlimited logical drives),

The GPT disk partitioning style supports up to a maximum volume of EB (exabytes) and there is no upper limit on the number of partitions per disk, only limited by the operating system (because the partition table itself takes up a certain amount of space, when you initially plan your hard disk partition, the space left for the partitioned table determines the maximum number of partitions that can be The IA-64 version of Windows limits a maximum of 128 partitions, which is the minimum size of the partition table as specified by the EFI standard. Unlike MBR partitioned disks, critical platform operational data is located in partitions, not in non-partitioned or hidden sectors. In addition, GPT partitioned disks use Backup partition tables to improve the integrity of partitioned data structures .


Efi
The Extensible Firmware Interface (English name extensible Firmware Interface or EFI) is a personal computer system specification used to define the software interface between the operating system and the system firmware, as an alternative to the BIOS upgrade scheme. The Extensible Firmware Interface is responsible for the power-on self-test (POST), the connection operating system, and the interface that connects the operating system to the hardware.
EFI was originally developed by Intel and is now being promoted and developed by the UEFI Forum.

UEFI
is developed by EFI1.10, its owner is no longer intel, but an international organization called Unified EFI form, contributors have Intel,microsoft,ami, and several manufacturers, belonging to open source, the current version is 2.1.

3 Creating a partition with Fdisk (less than 2TB)

If we're going to create a partition that doesn't exceed 2TB, we can use the traditional partitioning tool, Fdisk, and let's take a machine as an example to illustrate its usage:

1. Use

Fdisk-l

command to view the hard drive information installed on the machine

The above information tells us that this machine has 3 hard drives, only the first hard disk is partitioned, the remaining two blocks are not yet partitioned. (/dev/xvdb and/DEV/XVDC)

2. Use Fdisk to partition a hard disk

Here we show the partition operation of the hard disk/DEV/XVDC, first type "FDISK/DEV/XVDC" into the Partition Wizard mode :

1. Enter N to establish a new partition 2. Enter p to indicate that we want to create a primary partition 3. Direct carriage return, using the default starting cylinder, i.e. cylinder 14. Direct carriage return, using the default cut-off cylinder, That is, cylinder 4894, that is, for this hard disk, we create a partition, the size of the entire disk. 5. Enter W, save the partition table and exit

3. Formatting the newly created partition

Yes, the last step is the same, the new partition is formatted, here we choose the ext4 file system .

/dev/xvdc1

Note: formatting specifies "Partition" instead of hard disk! The XVDC1 here is obviously the first partition of the hard disk XVDC, if it is written in xvdc it means to format the entire hard drive

4 Creating a partition larger than 2TB

MBR and GPT, are partitioned in the format, where the MBR maximum partition is less than or equal to 2TB, and the GPT partition does not have 2TB limit, the theoretical maximum partition of the EB!

Now we know that to create a partition larger than 2TB, you cannot use the MBR format partition table, and to use the GPT-formatted partition table, our most commonly used Fdisk partitioning tool will not be able to use the parted partition tool under Linux !

The test environment is:

Dell R710 2u Server

CPU 5606 XEON

Mem 16G

Disk 6*1TB SAS 7200rpm

RAID Level 5 PERC 6i Card

Rhel 6 64bit, creating a 4TB size partition

4.1 Formally start parted partition

1, before using parted partition, we first use fdisk-l to view the hard drive information!

2, the above information we know/dev/sdb 4.6TB, now use the parted command, such as.

3, after entering the parted, the execution 2,3,4,5,6,7,8,9,10,10,11 step, the instruction below has the explanation!

4, the partition after the completion of the use of print can see the information just partition! Size 4684GB

5, quit for exit parted environment, information prompt update/etx/fstab!

6, then use Fdisk-l to view the next SDB hard disk, now has SDB1 partition, note system gpt!

7, parted here to complete!

4.2 format/dev/sdb1 file system for EXT4

Execute MKFS.EXT4/DEV/SDB1 all the way to enter!

4.3 update/etc/fstab

1. Use blkid to view the uuID of the partition, such as, to copy the UUID of the new partition/DEV/SDB1

2. Add/dev/sdb1 UUID to/etc/fstab,/dev/sdb1 mount in/data directory!

3, so that all completed, the following check!

Mount-a re-mount the records in the/etc/fstab file!

Mount can discover that/DEV/SDB1 is already mounted to the/data directory!

Df-h found/data 4.2TB

5 Detailed introduction to the next parted command

[Email protected] ~]# parted--help
Usage: parted [options] ... [Device [command [parameters] ...] ...]
Apply the command with "parameters" to "Device". If the command is not given, it runs in interactive mode.

Options:
-H,--help displays this help message
-I,--interactive prompts the user when necessary
-S,--script never prompt the user
-V,--version display version

Command:
Check the MINOR for a simple check of the file system
CP [From-device] From-minor to-minor Copying the file system to another partition
Help [command] print general assistance information, or information about the command
MklabelLabel type create a new disk label(partition Table)
MKFS MINOR file system type in MINOR creates a file system of type "file system type"
MkpartPartition type [file system type] Start point termination pointCreate a partition
MKPARTFS partition type file system type start point end point Create a partition with a file system
Move MINOR start point moving the partition numbered MINOR
Name MINOR names the partition with number MINOR named "Name"
Print[MINOR]Print partition table, or partition
Quit quitting the program
Rescue start point end point saves missing partitions near "start point", "End point"
Resize MINOR Start point change the size of the file system in the partition numbered MINOR
RMMINORto delete a partition numbered MINOR
Select Device Choose the device to edit
Set MINOR Flag Status change flag for partition numbered MINOR

Attention

Mklabel Label-type must be a bit of these types:

* BSD

* Loop (Raw disk access)

* GPT

* Mac

* Msdos

* PC98

* Sun

Example: (parted) Mklabel GTP or (parted) Mklabel Msdos

Mkpart (Create new partition)

Format: Mkpart part-type fs-type start end

To create a new partition

Part-type is one of the following types of primary (primary partition), extended (extended partition), logical (logical partition).

Fs-type to specify the file system, such as EXT4.

Start and end are specific locations where the new partition starts and ends. 0 means start and end, 1 means ending, or in megabytes or GB!

(go) hard disk partition memo (primary partition, extended partition and logical partition) and Linux hard disk partitioning tool parted introduction

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.