如何将硬盘分区成GPT格式

举报
rivers 发表于 2021/12/22 23:18:52 2021/12/22
【摘要】 基于GPT格式的磁盘分区 MBR分区标准决定了MBR的硬盘,为了支持能使用大于2T硬盘空间,需使用GPT格式进行分区。创建大于2TB的分区,需使用parted工具。 MBR是Master Boot Re...

基于GPT格式的磁盘分区

  • MBR分区标准决定了MBR的硬盘,为了支持能使用大于2T硬盘空间,需使用GPT格式进行分区。创建大于2TB的分区,需使用parted工具。
    MBR是Master Boot Record的简称,也就是主引导记录,是位于磁盘最前边的一段引 导(Loader)代码,主要用来引导操作系统的加载与启动

特点:

  1. MBR支持最大2TB磁盘,它无法处理大于2TB容量的磁盘
  2. 只支持最多4个主分区。若想要更多分区,需要创建扩展分区,并在其中创建逻辑分区

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

特点:

  1. GPT对磁盘大小没有限制
  2. 最多可以创建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
    • 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

总结

文章来源: rivers.blog.csdn.net,作者:宝山的博客,版权归原作者所有,如需转载,请联系作者。

原文链接:rivers.blog.csdn.net/article/details/115374745

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200