如何将硬盘分区成GPT格式

网友投稿 1329 2022-05-28

基于GPT格式的磁盘分区

MBR分区标准决定了MBR的硬盘,为了支持能使用大于2T硬盘空间,需使用GPT格式进行分区。创建大于2TB的分区,需使用parted工具。

MBR是Master Boot Record的简称,也就是主引导记录,是位于磁盘最前边的一段引 导(Loader)代码,主要用来引导操作系统的加载与启动

特点:

MBR支持最大2TB磁盘,它无法处理大于2TB容量的磁盘

只支持最多4个主分区。若想要更多分区,需要创建扩展分区,并在其中创建逻辑分区

GPT磁盘是指使用GUID分区表的磁盘,GUID磁盘分区表(GUID Partition Table,缩写:GPT)其含义为“全局唯一标识磁盘分区表”,是一个实体硬盘的分区表的结构布局的标准

特点:

GPT对磁盘大小没有限制

最多可以创建128个分区

在企业真实环境中,通常一台服务器有多块硬盘,整个硬盘容量为10T,需要基于GTP格式对10T硬盘进行分区,操作步骤如下:

确认是否有parted命令

[root@localhost ~]# which parted /usr/sbin/parted 这里安装的有,我们直接使用 [root@localhost ~]# [root@localhost ~]# yum -y install parted 如果没有,需要安装parted 命令

1

2

3

4

Parted 命令分为两种模式:命令行模式和交互模式。

命令模式:

parted -s /dev/sdb mklabel gpt 设置分区类型为gpt格式; mkfs.ext3 /dev/sdb 基于Ext3文件系统类型格式化; mount /dev/sdb /data/ 挂载/dev/sdb设备至/data/目录。

1

2

3

4

交互模式:

parted 直接进入 select /dev/sdb 选择/dev/sdb磁盘 mklabel gpt 格式类型为gpt mkpart primary 0 -1 将整块磁盘分一个分区 print 打印刚分区的磁盘信息 quit 退出 mkfs.ext3 /dev/sdb1 格式化磁盘 moun /dev/sdb1 /data/ 挂在

1

2

3

4

5

6

7

8

9

10

详细操作情况

[root@localhost ~]# parted GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p #打印磁盘信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 211MB 210MB primary xfs boot 2 211MB 751MB 540MB primary lvm 3 751MB 32.2GB 31.5GB primary xfs (parted) select /dev/sdb #选择空的磁盘 Using /dev/sdb (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) mklabel gpt #用GPT分区,支持2T以上的硬盘 Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes 输入yes (parted) mkpart primary 0 -1 -1 #将整块磁盘分为1个分区 1表示从最开始分区,也可以用百分比表示 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore/Cancel? ignore (parted) print #打印刚分好的分区 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 21.5GB 21.5GB primary (parted) quit

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

将磁盘分成多个分区

(parted) mkpart primary File system type? [ext2]? ext4 #选择文件系统类型 Start? 1024 #分区开始位置 End? 2048 #分区结束位置 Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1024MB 2048MB 1023MB primary (parted) mkpart primary File system type? [ext2]? ext3 Start? 0 End? 1023 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? ignore Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 17.4kB 1023MB 1023MB primary 1 1024MB 2048MB 1023MB primary (parted) mkpart exclude File system type? [ext2]? ext3 Start? 2049 End? 4096 Error: Partition(s) 1, 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? ignore (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 17.4kB 1023MB 1023MB primary 1 1024MB 2048MB 1023MB primary 3 2049MB 4096MB 2047MB exclude (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

如何将硬盘分区成GPT格式

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

如果创建错误,需要删除错误分区

(parted) select /dev/sdb Using /dev/sdb (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 21.5GB 21.5GB primary (parted) rm 1 (parted) p

1

2

3

4

5

6

7

8

9

10

11

12

13

14

总结

磁盘格式化、挂载 参考上期文章 linux 磁盘分区管理

linux磁盘分区管理

Linux

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:【玩转云硬盘EVS】搭建MSCS集群(一)
下一篇:《网络攻防技术(第2版)》 —3.4.2 键盘记录
相关文章