GPT分区表格式的两种创建方式

MBR和GPT分区表的信息

MBR(Master Boot Record)

  • 分区表类型fdisk 默认使用 MBR 分区表。
  • 最大分区数量:MBR 支持最多 4 个主分区,或者 3 个主分区加 1 个扩展分区(可以包含多个逻辑分区)。
  • 最大磁盘大小:MBR 支持的最大磁盘大小为 2TB。
  • 启动信息:MBR 在磁盘的第一个扇区中存储引导加载程序和分区表信息。

GPT(GUID Partition Table)

  • 分区表类型parted 默认创建 GPT 分区表。 。
  • 最大分区数量: GPT 最多支持 128 个分区 。
  • 最大磁盘大小: GPT 最大支持 9.4 ZB 。
  • 启动信息:使用 UEFI 进行引导,具有冗余的分区表存储。

两种方式创建GPT分区

使用fdisk 创建GPT分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# root @ debian in ~ [17:51:36] 
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400G 0 disk
└─sda1 8:1 0 400G 0 part /
sdb 8:16 0 100G 0 disk
sdc 8:32 0 100G 0 disk
sdd 8:48 0 100G 0 disk
sr0 11:0 1 445.7M 0 rom
# root @ debian in ~ [17:56:34] C:130
$ fdisk /dev/sdb

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x829a598b.

Command (m for help): m

Help:

DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag

Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
u change display/entry units
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit
q quit without saving changes

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table


Command (m for help): g #默认是mbr,按g才会使用gpt
Created a new GPT disklabel (GUID: 9324FD1A-EAE8-7E49-B548-C613E8D4D282).

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-209715166, default 2048): # 起始扇区
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-209715166, default 209715166): 109715666 # 结束扇区

Created a new partition 1 of type 'Linux filesystem' and of size 52.3 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


# root @ debian in ~ [17:57:45]
$ fdisk -l /dev/sdb # 查看磁盘的分区信息,包括分区表
Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt # 分区表是gpt
Disk identifier: 9324FD1A-EAE8-7E49-B548-C613E8D4D282

Device Start End Sectors Size Type
/dev/sdb1 2048 109715666 109713619 52.3G Linux filesystem

# root @ debian in ~ [17:58:10]
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
└─sda1 ext4 1.0 f34f1c4a-fb45-4145-b526-1a9985598ea4 305.5G 17% /
sdb
└─sdb1
sdc
sdd
sr0 iso9660 Joliet Extension CDROM 2023-04-19-20-36-49-00

# root @ debian in ~ [17:58:20]
$ mkfs.ext4 /dev/sdb1
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 13714202 4k blocks and 3432448 inodes
Filesystem UUID: 571028b4-f5db-4f0d-86f0-7faca53b9af9
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information:
done

# root @ debian in ~ [17:58:41]
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400G 0 disk
└─sda1 8:1 0 400G 0 part /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 52.3G 0 part
sdc 8:32 0 100G 0 disk
sdd 8:48 0 100G 0 disk
sr0 11:0 1 445.7M 0 rom

使用parted 创建GPT分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# root @ debian in ~ [19:01:58] 
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400G 0 disk
└─sda1 8:1 0 400G 0 part /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 52.3G 0 part /sdb1_gpt
sdc 8:32 0 100G 0 disk
sdd 8:48 0 100G 0 disk
sr0 11:0 1 445.7M 0 rom

# root @ debian in ~ [19:02:42]
$ parted /dev/sdc # 进入 parted 交互模式
GNU Parted 3.4
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt # 创建 GPT 分区表
(parted) mkpart primary ext4 1MiB 100% # 创建一个新分区 primary:主分区 ext4:文件系统类型(可选,后续格式化时可以更改) 1MiB:起始位置(跳过前 1MB 以对齐) 100%:使用整个磁盘空间
(parted) print
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
resizepart NUMBER END resize partition NUMBER
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted) quit
Information: You may need to update /etc/fstab.


# root @ debian in ~ [19:09:36]
$ partprobe /dev/sdb # 重新加载分区表

# root @ debian in ~ [19:09:48]
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400G 0 disk
└─sda1 8:1 0 400G 0 part /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 52.3G 0 part /sdb1_gpt
sdc 8:32 0 100G 0 disk
└─sdc1 8:33 0 100G 0 part
sdd 8:48 0 100G 0 disk
sr0 11:0 1 445.7M 0 rom

# root @ debian in ~ [19:09:51]
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
└─sda1 ext4 1.0 f34f1c4a-fb45-4145-b526-1a9985598ea4 305.5G 17% /
sdb
└─sdb1 ext4 1.0 571028b4-f5db-4f0d-86f0-7faca53b9af9 48.6G 0% /sdb1_gpt
sdc
└─sdc1
sdd
sr0 iso9660 Joliet Extension CDROM 2023-04-19-20-36-49-00
# root @ debian in ~ [19:10:29]
$ parted /dev/sdc print # 查看磁盘的分区信息
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 107GB 107GB primary

删除分区

使用fdisk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# root @ debian in ~ [19:19:10] 
$ fdisk /dev/sdb

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

GPT
M enter protective/hybrid MBR

Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit
q quit without saving changes

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


# root @ debian in ~ [19:19:47]
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
└─sda1 ext4 1.0 f34f1c4a-fb45-4145-b526-1a9985598ea4 305.5G 17% /
sdb
sdc
sdd
sr0 iso9660 Joliet Extension CDROM 2023-04-19-20-36-49-00

使用parted

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# root @ debian in ~ [19:15:48] 
$ parted /dev/sdc
GNU Parted 3.4
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 107GB 107GB primary

(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
resizepart NUMBER END resize partition NUMBER
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted) rm 1
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

(parted) quit
Information: You may need to update /etc/fstab.


# root @ debian in ~ [19:17:23]
$ parted /dev/sdc print
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags


# root @ debian in ~ [19:17:29]
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
└─sda1 ext4 1.0 f34f1c4a-fb45-4145-b526-1a9985598ea4 305.5G 17% /
sdb
└─sdb1 ext4 1.0 571028b4-f5db-4f0d-86f0-7faca53b9af9 48.6G 0% /sdb1_gpt
sdc
sdd
sr0 iso9660 Joliet Extension CDROM 2023-04-19-20-36-49-00

GPT分区表格式的两种创建方式
https://luffy997.github.io/2025/03/28/GPT分区表格式的两种创建方式/
作者
Luffy997
发布于
2025年3月28日
许可协议