Centos 7下如何删除GPT分区

本文介绍如何在CentOS 7上使用parted工具删除硬盘上的GPT分区,并转换为MSDOS分区表,以便通过fdisk进行分区操作。
部署运行你感兴趣的模型镜像

操作环境

Centos 7

操作步骤

最近在linux测试机上面,通过fdisk 查看硬盘,发现几块1TB的硬盘都变成了GPT分区,无法通过fdisk进行分区操作,所以要通过parted 删除其GPT分区

[root@docker-server-1 ~]# fdisk -l

Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dac36

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00048d6c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1306    10485760   83  Linux
/dev/sda2            1306        3346    16384000   82  Linux swap / Solaris
/dev/sda3            3346      121535   949353472   83  Linux

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

WARNING: GPT (GUID Partition Table) detected on '/dev/sdf'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdf: 999.7 GB, 999653638144 bytes
256 heads, 63 sectors/track, 121059 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1      121060   976224255+  ee  GPT

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdd: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

WARNING: GPT (GUID Partition Table) detected on '/dev/sde'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sde: 999.7 GB, 999653638144 bytes
256 heads, 63 sectors/track, 121059 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      121060   976224255+  ee  GPT

1.选择sdc进行删除GPT分区操作

[root@docker-server-1 ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)                                                     

2.通过mklabel建立msdos分区

(parted) mklabel
New disk label type? msdos                                                
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes                                                               
Warning: /dev/sdc contains GPT signatures, indicating that it has a GPT table.  However, it does not have a valid fake msdos partition table, as it should.  Perhaps it was corrupted -- possibly by a program that doesn't understand
GPT partition tables.  Or perhaps you deleted the GPT table, and are now using an msdos partition table.  Is this a GPT partition table?
Yes/No? Yes              

3.再次通过fdisk 查看sdc,就不会提示GPT分区了

您可能感兴趣的与本文相关的镜像

GPT-oss:20b

GPT-oss:20b

图文对话
Gpt-oss

GPT OSS 是OpenAI 推出的重量级开放模型,面向强推理、智能体任务以及多样化开发场景

<think>嗯,用户现在问的是在创建CentOS时如何创建GPT分区。首先,我需要确定用户的需求是什么。可能他们是在安装CentOS系统时遇到了分区的问题,或者他们希望使用GPT分区表而不是传统的MBR。GPT分区相比MBR有什么优势呢?比如支持更大的磁盘(超过2TB)、更多的主分区等等。所以用户可能有较大的硬盘需要管理,或者需要更多的分区。 接下来,我需要回忆一下CentOS安装过程中分区的步骤。通常,在安装CentOS时,会进入磁盘分区界面,用户可以选择自动分区或手动分区。用户可能需要手动分区的指导,特别是如何选择GPT分区表。 可能需要注意几点:首先,CentOS的安装程序(Anaconda)是否默认使用GPT?通常,当磁盘大于2TB时,安装程序会自动选择GPT,否则可能使用MBR。但用户可能想强制使用GPT,即使磁盘较小。这时候可能需要手动干预。 另外,用户可能对命令行工具parted或gdisk比较熟悉,或者在安装界面中使用图形化工具。需要提供两种方法的步骤吗?或者用户可能更倾向于在安装过程中直接设置,而不是预先使用命令行? 还需要考虑用户可能遇到的问题,比如如何从MBR转换为GPT,但这可能会涉及数据丢失,所以需要警告用户备份数据。不过用户的问题是关于创建时的分区,所以可能是在新安装系统的情况下。 另外,需要解释GPT分区的优势,比如兼容性、备份分区表等,但用户可能已经知道这些,所以可能需要简洁说明。 可能还需要提到UEFI和GPT的关系,因为通常UEFI系统会要求使用GPT分区表。所以用户是否在使用UEFI模式安装CentOS?如果是的话,可能需要确保引导分区是EFI系统分区(ESP),格式化为FAT32,并挂载到/boot/efi。 可能的步骤是:在安装过程中,进入安装界面,选择安装位置,进入磁盘分区界面,选择自定义分区,然后创建新的分区表类型为GPT,然后添加所需的分区,如/boot/efi、/、swap等。 如果用户需要在已有MBR的磁盘上转换为GPT,可能需要使用工具如gdisk或parted,但这样会破坏数据,所以必须提前备份。但根据用户的问题,可能是在安装时创建新的GPT分区,所以重点放在安装过程中的操作。 此外,可能需要提到在安装界面中如何选择高级存储配置,确保磁盘分区表类型为GPT,以及如何创建各个分区的大小和挂载点。 总结一下,回答的结构可能包括以下几个部分: 1. GPT分区的优势 2. 在CentOS安装过程中创建GPT分区的步骤(图形界面) 3. 使用命令行工具(如parted)预先创建GPT分区表的方法 4. 注意事项,如UEFI模式下的ESP分区 5. 常见问题或错误处理,比如磁盘已有数据需要清除等 需要确保步骤清晰,用户能够跟随操作,同时强调重要步骤,如选择正确的分区表类型,创建必要的引导分区等。另外,可能需要提醒用户在进行分区操作前备份数据,避免数据丢失。</think>--- ### CentOS 系统安装时创建 GPT 分区指南 GPT(GUID 分区表)是新一代磁盘分区方案,支持超过 2TB 的硬盘和最多 128 个主分区。以下是在 CentOS 安装过程中创建 GPT 分区的详细操作步骤: --- #### 一、GPT 与 MBR 的核心区别 | 特性 | GPT | MBR | |--------------------|---------------------------------|-----------------------| | **最大磁盘容量** | 9.4 ZB(理论值) | 2 TB | | **主分区数量** | 128(实际可扩展) | 4 | | **分区表备份** | 自带备份副本 | 无 | | **兼容性** | 需 UEFI 固件支持 | 兼容传统 BIOS | --- #### 二、图形化安装界面操作 **1. 启动安装程序** 通过 CentOS 安装镜像启动后,选择「Install CentOS」进入图形界面。 **2. 进入磁盘配置** 在「Installation Destination」界面: - 选择目标磁盘 - 点击「Storage Configuration」选择 **_Custom_**(手动配置) **3. 创建 GPT 分区表** ```bash # 操作路径 点击磁盘 → 下方「+」创建新分区表 → 选择「gpt」类型 → 确认 ``` ![分区表类型选择](https://via.placeholder.com/600x400?text=Select+GPT+Partition+Table) **4. 添加必需分区(以 UEFI 为例)** | 挂载点 | 文件系统 | 建议大小 | 特殊标记 | |------------|----------|-------------|-------------------| | /boot/efi | EFI | 300 MB | EFI System Partition | | /boot | xfs | 1 GB | - | | swap | swap | ≥ 物理内存 | - | | / | xfs | 剩余空间 | - | **操作示例**: ```bash 点击「+」→ 设置挂载点 /boot/efi → 大小 300M → 文件系统选「EFI System Partition」→ 确认 ``` --- #### 三、命令行预配置(适用于高级用户) **1. 启动救援模式** 通过安装镜像进入「Troubleshooting」→ 「Rescue a CentOS system」 **2. 使用 parted 创建 GPT** ```bash # 列出所有磁盘 lsblk # 进入目标磁盘(示例为 /dev/sda) parted /dev/sda # 创建新 GPT 分区表 (parted) mklabel gpt # 退出 quit ``` **3. 返回图形界面继续安装** 此时磁盘已包含 GPT 分区表,可继续完成分区配置。 --- #### 四、关键注意事项 1. **UEFI 模式强制要求** - 必须创建 `/boot/efi` 分区并标记为 EFI 系统分区 - BIOS 引导模式无法使用 GPT + MBR 混合方案 2. **数据清除警告** ```bash # 创建新分区表会擦除磁盘所有数据! # 操作前务必确认磁盘无重要数据 ``` 3. **分区对齐优化** 使用 `parted` 时建议启用对齐优化: ```bash (parted) mkpart primary 1MiB 513MiB # 1MiB 偏移对齐 ``` --- #### 五、验证分区类型 安装完成后通过以下命令检查: ```bash # 查看分区表类型 sudo parted -l | grep 'Partition Table' # 预期输出 Partition Table: gpt # 确认 EFI 分区 lsblk -f | grep efi ``` --- #### 六、故障排查 | 问题现象 | 解决方案 | |-------------------------|--------------------------------| | **无法选择 GPT** | 检查固件是否为 UEFI 模式 | | **/boot/efi 未被识别** | 确认分区标记为「EFI System」 | | **安装程序报分区错误** | 尝试在 parted 中执行 `align-check optimal 1` | --- **扩展建议**: - 对关键服务器建议配置 LVM,便于后期扩容 - 使用 `sgdisk -p /dev/sda` 查看详细 GPT 分区结构 - 参考 Red Hat 官方文档: [RHEL 8 Disk Partitioning Guide](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_storage_devices/index)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值