> For the complete documentation index, see [llms.txt](https://hezhiqiang.gitbook.io/about-the-author/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang.gitbook.io/about-the-author/yun-wei-ri-chang-ji-lu/linux-xia-yong-ming-ling-zen-me-pan-duan-fen-qu-shi-gpt-hai-shi-mbr.md).

# Linux 命令行判断GPT和MBR分区

#### 博客作者：联系请[点击](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)，搬运不易，希望请作者喝咖啡，可以点击[联系博客作者](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)

## 前言

&#x20;            常用的磁盘分区形式有主启动记录分区（Main Boot Record，MBR）和全局分区表（Guid Partition Table，GPT），磁盘投入使用后再切换磁盘分区形式，磁盘上的原有数据将会清除，因此请根据实际需求合理选择分区形式。

#### &#x20;两种分区形式的简介如下表所示：

| 分区形式 | 支持最大磁盘容量                         | 支持分区数量                          | 分区工具                                                                                |
| ---- | -------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------- |
| MBR  | 2TB                              | <p>4个主分区</p><p>3个主分区和1个扩展分区</p> | <p>Windows 操作系统：磁盘管理<br>Linux 操作系统：</p><ul><li>fdisk 工具</li><li>parted 工具</li></ul> |
| GPT  | <p>18EB<br>目前云硬盘支持的最大容量为32TB</p> | 不限制分区数量                         | <p>Windows 操作系统：磁盘管理<br>Linux 操作系统：parted 工具</p>                                    |

## 一、Linux下用命令判断分区是GPT还是MBR

### 方法一:

```
fdisk -l
```

![](/files/-MRzXAY4kcexDYEmwtjh)

### 方法二：

```
parted -l
```

![](/files/-MRzXaCschg9RtYrC1SL)

## 二，用parted命令更改磁盘分区格式

```
[root@hezhiqiang ~]# parted /dev/sdb
(parted)mktable
New disk label type? msdos
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
```

使用免交互加上 -s

```
parted /dev/sdb mklabel msdos -s  #转换成mbr格式
```

```
parted /dev/sdb mklabel gpt -s    #转化成gpt格式
```
