Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to manage GPT Partition with parted Command under Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use parted commands to manage GPT partitions under the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Let's review the concept of GPT:

The GUID partition table (GUID Partition Table, abbreviation: GPT), which means "global unique identification disk partition table", is the standard for the structural layout of the partition table of a physical hard disk. It is part of the Extensible firmware Interface (EFI) standard (used by Intel to replace the BIOS of personal computers) and is used to replace a 32bits in the BIOS system to store the master boot record (MBR) partition table of logical block address and size information.

The GUID partition table (GUIDPartition Table, abbreviation: GPT) is the standard for the structural layout of the partition table of a physical hard disk. It is part of the Extensible firmware Interface (EFI) standard (used by Intel to replace the BIOS of personal computers) and is used to replace a 32bits in the BIOS system to store the master boot record (MBR) partition table of logical block address and size information. For disks with 512-byte sectors, the MBR partition table does not support partitions larger than 2.2TB (2.2 × 10 ^ 12 bytes). However, some hard drive manufacturers, such as Seagate and Western Digital, have noticed this limitation and upgraded their larger disks to 4KB sectors, which means that the effective capacity limit for MBR has been raised to 16 TB. This seemingly "correct" solution not only temporarily reduces the need for improved disk allocation tables, but also brings confusion to the market about how best to partition disks when booting from BIOS on devices with larger block. GPT assigns 64bits to logical block addresses, thus making it possible for the maximum partition size to be 2 ^ 64-1 sectors. For each disk with a sector size of 512 bytes, that means there can be 9.4ZB (9.4 x 10 ^ 21 bytes) or 18 E 512 bytes (9444732965739290426880 bytes or 1844674407709551615 (2 ^ 64-1) sectors x 512 (= 2 ^ 9) bytes per sector).

The parted command can divide a single partition larger than 2T in GPT format, or it can divide ordinary MBR. The fdisk command cannot divide the partition larger than 2T, so you can not see the GPT format partition divided by parted with fdisk.

Parted commands are divided into two modes: command line mode and interactive mode.

1. Command line mode: parted [option] device [command]. This mode can partition the disk directly under the command line, which is more suitable for programming applications.

2. Interactive mode: parted [option] device is similar to using fdisk / dev/xxx

The MBR:MBR partition table (that is, the master boot record) is familiar. Maximum supported volume: 2T, with limited partitions: up to 4 primary partitions or 3 primary partitions plus one extended partition

GPT: GPT (that is, GUID partition table). Is a newer disk partition table structure standard derived from the EFI standard, and is the main form of disk partitioning in the future. Compared with the MBR partition method, it has the following advantages. The limit of 4 primary partitions in MBR is broken, and a maximum of 128 partitions are supported per disk. Partitions larger than 2T are supported, and the maximum volume can reach 18EB.

Parted is a tool that can partition and adjust partitions. It can create, destroy, move, copy, adjust ext2 linux-swap fat fat32 reiserfs type partitions, create, adjust, move HFS partitions of Macintosh, and detect jfs,ntfs,ufs,xfs partitions.

How to use: parted [options] [device [command [options...]...]]

Options

-h displays help information

-l displays partitions on all block devices

Device

Which block device to operate on, and if not specified, the first block device is used

Command [options...]

The code is as follows:

Check partition

Do a simple detection of the partition

The code is as follows:

Cp [source-device] source dest

Copy the source partition on the source-device device to the dest partition of the current device

The code is as follows:

Mklabel label-type

Create a new partition table type, label-type can be: "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun" general PC format is msdos format, if the partition is greater than 2T, you need to choose gpt format partition table.

The code is as follows:

Mkfs partition fs-type

Create a fs-type file system on the partition partition. The fs-type can be: "fat16", "fat32", "ext2", "linux-swap", "reiserfs". Note that the file system in ext3 format is not supported and can only be partitioned and then formatted with proprietary commands.

The code is as follows:

Mkpart part-type [fs-type] start end

Create a partition of type part-type. The part-type can be: "primary", "logical", or "extended". If fs-type is specified, the partition is formatted at the same time. Start and end refer to the starting position of the partition, and the unit defaults to M.

Eg:mkpart primary 0-1 0 indicates the beginning of the partition-1 means that the end of the partition means to partition the entire hard disk space as the primary partition

The code is as follows:

Mkpartfs part-type fs-type start end

Create a part-type partition of type fs-type, which is not recommended. It is best to use mke2fs after the mkpart partition is finished.

The code is as follows:

Name partition name

Set a name for the partition. This setting can only be used in partition tables of type Mac, PC98, and and GPT. The name is enclosed in quotation marks.

The code is as follows:

Select device

When there are multiple hard drives on the machine, choose which hard drive to operate.

The code is as follows:

Resize partition start end

Resize the partition

The code is as follows:

Rm partition

Delete a partition

The code is as follows:

Rescue start end

Save a partition between stat and end

The code is as follows:

Unit unit

In the previous partition, the default partition value is M, and this parameter Kaj changes the default unit, "kB", "MB", "GB", "TB".

The code is as follows:

Move partition start end

Move partition Partition

The code is as follows:

Print

Display partition table information

The code is as follows:

Quit

Exit parted

Actual combat:

1 initial information

Note that the green box shows that fdisk does not support partitions in GPT format, and then enter the command p (abbreviation for print) to see all the current partitions of the system

(2) the partition is divided into three main partitions with a size of 10G in succession. The file system type of the partition is not specified. Parted takes effect directly after partition, and there is no similar w command in fdisk.

You can see that the new partition 3 4 5 is the primary partition size 10G

3 you can also view the partition status in non-interactive mode

4 prepare to format a file system with a new partition of type ext3

It was strange to find that this partition could not be found.

5 View existing partition names

Use blkid to see what the existing partition is name

6 Mount the new partition after formatting

This is the end of the content of "how to use parted commands to manage GPT partitions under the Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report