Home >Operation and Maintenance >Safety >Detailed explanation of MBR and GPT partitions, have you learned it?

Detailed explanation of MBR and GPT partitions, have you learned it?

PHPz
PHPzforward
2023-06-09 11:02:2811283browse

Detailed explanation of MBR and GPT partitions, have you learned it?

1. MBR partition

MBR is the abbreviation of Master Boot Record, which is an old partition table format used to identify and manage partitions on the hard disk. The MBR partition table can identify up to 4 primary partitions or 3 primary partitions and 1 extended partition.

The 2TB limit means that a hard disk using MBR partition table format can only be partitioned to a maximum of 2TB, because MBR uses 32-bit LBA (Logical Block Addressing) addressing mode, and the maximum address can only represent 2^32 sectors, each sector size is 512 bytes, so the maximum supported hard disk size is 2TB.

In order to support larger hard disk capacity, hard disk manufacturers and operating system developers introduced the GPT (GUID Partition Table) partition table format. GPT uses 64-bit LBA addressing and can support hard disks with a maximum capacity of 9.4ZB (1 ZB = 1024^7 bytes). Therefore, if you need to partition a hard drive larger than 2TB, it is recommended to use the GPT partition table format.

2. GPT Partition

GPT (GUID Partition Table) partition table is a new partition table format used to identify and manage partitions on the hard disk. Different from the old MBR partition table, GPT uses GUID (Globally Unique Identifier) ​​to identify partitions and supports larger hard disk capacity and more partitions.

GPT partition table generally consists of the following parts:

  • Protective MBR: Protective MBR partition table, used to be compatible with old BIOS systems and prevent old systems from mistaking them for hard drives. There are no partitions.
  • Primary GPT Header: Header information of the GPT partition table, including partition table size, partition table location, partition entry size, number of partition entries, etc.
  • Partition Entries: Partition entries. Each partition entry contains information such as the GUID of the partition, the starting and ending LBA, and the partition type.
  • Backup GPT Header: Backup GPT partition table header information.
  • Unused Space: Unused space.

Each partition entry in the GPT partition table has a unique GUID. This GUID can be used to identify the partition, unlike MBR which uses a fixed partition type to identify the partition. GPT supports up to 128 partitions, and some partition types are reserved, such as EFI system partition, Microsoft basic data partition, etc.

3. How to create a partition larger than 2TB

MBR and GPT are both partition formats. The maximum partition of MBR is less than or equal to 2TB, while the GPT partition has no 2TB limit, and the theoretical maximum partition is 18 EB!

Now we know that if we want to create a partition larger than 2TB, we cannot use the MBR format partition table. If we want to use the GPT format partition table, our most commonly used fdisk partition tool cannot help. We need to use Parted partition tool under linux!

The following demonstrates the process of creating a 4TB partition.

1. Before using the parted partition, we first use fdisk -l to check the hard disk information!

Detailed explanation of MBR and GPT partitions, have you learned it?

#2. Now use the parted command to partition /dev/sdb 4.6TB, as shown in the figure below.

Detailed explanation of MBR and GPT partitions, have you learned it?

3. After entering parted, execute steps 2,3,4,5,6,7,8,9,10,10,11, below the instructions There is an explanation!

Detailed explanation of MBR and GPT partitions, have you learned it?

4. After the partition is completed, use print to see the information about the partition just now! Size 4684GB

Detailed explanation of MBR and GPT partitions, have you learned it?

##5. Quit is used to exit the parted environment, and the message prompts to update /etx/fstab!

Detailed explanation of MBR and GPT partitions, have you learned it?

6、

Use fdisk -l to check the sdb hard disk. Now there is sdb1 partition

Detailed explanation of MBR and GPT partitions, have you learned it?

7,

parted This is it!

8. Format the /dev/sdb1 file system to EXT4.

mkfs.ext4 /dev/sdb1

9. Edit /etc/fstab and set automatic mounting at boot.

Detailed explanation of MBR and GPT partitions, have you learned it?

4. How to convert MBR TO GPT in Linux environment

In Linux environment, you can use the gdisk command to convert MBR partition to GPT partition. The following are the steps to convert MBR partition to GPT partition:

Please note that before performing the following steps, please back up your data first, because converting the partition table format may cause data loss.

1. Open the terminal: In the Linux operating system, open the terminal.

2. Install gdisk: If your system does not have gdisk installed, please use the following command to install it:

yuminstall gdisk

3. Open the disk: Use the following command to open the disk you want to convert:

sudo gdisk /dev/sdX

Please replace /dev/sdX with the name of the disk you want to convert.

4. Convert partition table format: In the gdisk command line, enter "r" to enter the recovery and conversion menu, and then enter "g" to convert the partition table to GPT format. Enter "w" to save changes and exit gdisk.

5. Create new partitions: After the conversion is completed, you can use fdisk or other disk management tools to create new GPT partitions and restore data to these partitions.

Please note that converting the partition table format will delete all existing partitions and data, so be sure to back up all data before performing this operation. In addition, converting MBR partition table to GPT partition table may affect system startup, so please make sure you are familiar with the basics of system startup before doing this operation.

The above is the detailed content of Detailed explanation of MBR and GPT partitions, have you learned it?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete