分区管理工具-gdisk命令实战案例

简介: 关于如何使用gdisk工具进行GPT分区管理的实战案例教程。

作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。

  gdisk工具擅长管理GPT分区。接下来我们就简单介绍一下该工具的使用。

一.分区表概述

  博主推荐阅读:
    https://developer.aliyun.com/article/1604391

二.安装gdisk

  gdisk工具和fdisk很类似,都是对磁盘进行分区管理的开源工具。如下图所示,fdisk对于GPT分区方式目前只是实验性的,因此生成环境建议大家谨慎使用。

  我们的gdisk工具很擅长处理GPT分区方式,不仅如此还支持MBR以及APM和BSD分区方式(虽说后两者分区方式使用相对较少,感兴趣的同学可以自行查阅相关资料)。

  综上所述,如果生产环境您使用GPT分区推荐使用gdisk工具,最小化安装的系统需要手动安装哟~

[root@yinzhengjie.com ~]# yum -y install gdisk
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.bit.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirror.bit.edu.cn
base                                                                                                                                                 | 3.6 kB  00:00:00     
extras                                                                                                                                               | 2.9 kB  00:00:00     
updates                                                                                                                                              | 2.9 kB  00:00:00     
(1/4): updates/7/x86_64/primary_db                                                                                                                   | 168 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                                                    | 190 kB  00:00:00     
(3/4): base/7/x86_64/group_gz                                                                                                                        | 153 kB  00:00:01     
(4/4): base/7/x86_64/primary_db                                                                                                                      | 6.1 MB  00:00:03     
Resolving Dependencies
--> Running transaction check
---> Package gdisk.x86_64 0:0.8.10-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================
 Package                                Arch                                    Version                                         Repository                             Size
============================================================================================================================================================================
Installing:
 gdisk                                  x86_64                                  0.8.10-3.el7                                    base                                  190 k

Transaction Summary
============================================================================================================================================================================
Install  1 Package

Total download size: 190 k
Installed size: 660 k
Downloading packages:
gdisk-0.8.10-3.el7.x86_64.rpm                                                                                                                        | 190 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gdisk-0.8.10-3.el7.x86_64                                                                                                                                1/1 
  Verifying  : gdisk-0.8.10-3.el7.x86_64                                                                                                                                1/1 

Installed:
  gdisk.x86_64 0:0.8.10-3.el7                                                                                                                                               

Complete!
[root@yinzhengjie.com ~]#

[root@yinzhengjie.com ~]# yum -y install gdisk          #安装gdisk工具

三.gdisk工具使用案例

[root@yinzhengjie.com ~]# gdisk /dev/sdc         #进入到gdisk工具的管理界面
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help):

1>.查看帮助信息

Command (? for help): ?
b    back up GPT data to a file
c    change a partition's name
d    delete a partition
i    show detailed information on a partition
l    list known partition types
n    add a new partition
o    create a new empty GUID partition table (GPT)
p    print the partition table
q    quit without saving changes
r    recovery and transformation options (experts only)
s    sort partitions
t    change a partition's type code
v    verify disk
w    write table to disk and exit
x    extra functionality (experts only)
?    print this menu

Command (? for help):

2>.新建分区

Command (? for help): n                #执行新建分区的指令
Partition number (1-128, default 1): 
First sector (34-838860766, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-838860766, default = 838860766) or {+-}size{KMGTP}: +100G        #这里的结束位置我这里写+100G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):       #我们可以自定义创建分区的代码(默认是8300),输入字母"l"可以查看所有的代码标签哟~通常情况下我们直接回车即可。
Changed type of partition to 'Linux filesystem'

Command (? for help):

3>.查看分区信息

Command (? for help): p
Disk /dev/sdc: 838860800 sectors, 400.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 37B1331C-C436-48CA-B5A6-B157D0BB9AD0
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 838860766
Partitions will be aligned on 2048-sector boundaries
Total free space is 629145533 sectors (300.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       209717247   100.0 GiB   8300  Linux filesystem

Command (? for help):

4>.保存分区信息并退出

Command (? for help): w            #保存分区信息到磁盘(默认所有的修改都放在内存中,直到执行当前的写入指令才会写入到磁盘。)

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y        #注意哈,这里得输入字母"Y"才能保存成功哟~
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
[root@yinzhengjie.com ~]#

5>.命令行中查看gpt的分区信息

[root@yinzhengjie.com ~]# gdisk -l /dev/sdc
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdc: 838860800 sectors, 400.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C4A5426E-BE89-46EE-B842-3CAC96156388
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 838860766
Partitions will be aligned on 2048-sector boundaries
Total free space is 629145533 sectors (300.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       209717247   100.0 GiB   8300  Linux filesystem
[root@yinzhengjie.com ~]#

[root@yinzhengjie.com ~]# fdisk -l /dev/sdc
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdc: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: C4A5426E-BE89-46EE-B842-3CAC96156388


#         Start          End    Size  Type            Name
 1         2048    209717247    100G  Linux filesyste Linux filesystem
[root@yinzhengjie.com ~]# 
[root@yinzhengjie.com ~]#

[root@yinzhengjie.com ~]# fdisk -l /dev/sdc          #对于GPT分区的磁盘虽然也可以使用fdisk工具查看,但还是推荐大家使用gdisk去管理GPT分区。

目录
相关文章
|
存储 文件存储 对象存储
块存储、文件存储和对象存储特点对比
块存储、文件存储和对象存储特点对比
961 2
|
存储 NoSQL Unix
【Core dump】关于core的相关配置:关于核心转储文件core dump的显示和设置位置
【Core dump】关于core的相关配置:关于核心转储文件core dump的显示和设置位置
1172 11
|
Linux Windows
分区表概述
关于磁盘分区表的概述,主要介绍了分区的原因、分区方式(MBR和GPT)、分区空间的使用步骤、以及Windows和Linux默认使用的分区方式,同时详细解释了MBR和GPT分区方式的结构和特点。
318 0
分区表概述
|
Oracle 关系型数据库 数据库
手把手教你Oracle DataGuard主备切换(switchover)
手把手教你Oracle DataGuard主备切换(switchover)
1450 4
|
Linux
挂载文件系统
文章详细介绍了Linux系统中使用mount命令挂载文件系统的方法和技巧,包括临时挂载、配置文件挂载、使用loop设备、挂载移动介质以及迁移"/home"目录到新分区的案例。
244 1
挂载文件系统
磁盘的分区、格式化、检验与挂载 ---- fdisk,mkfs,mount
该文章介绍了如何在Linux系统中进行磁盘的分区、格式化、检验与挂载操作。
磁盘的分区、格式化、检验与挂载 ---- fdisk,mkfs,mount
使用npm,快速构建第一个vue项目
本文介绍了如何使用npm快速构建第一个Vue项目。步骤包括确保安装了Node.js并且配置了正确的环境变量,创建一个空文件夹并使用VSCode打开,通过VSCode的终端执行`npm init vue@latest`命令以初始化项目,选择默认配置即可。接着安装项目依赖并启动开发服务器,最后通过浏览器访问开发服务器提供的本地地址查看项目运行结果。文章还提供了相关代码和操作截图。
高端响应式网络科技公司网站源码pbootcms模板
这是一款高端响应式网络科技公司网站源码pbootcms模板,适合所有类型的网络公司展示,整站源码下载,为您简化开发过程,可自适应手机端。
326 3
|
Kubernetes 网络安全 数据安全/隐私保护
K8S二进制部署详解,一文教会你部署高可用K8S集群(一)
K8S二进制部署详解,一文教会你部署高可用K8S集群(一)
3780 0
|
存储 Oracle 关系型数据库
RAC创建ASM磁盘组时配置多路径和UDEV
RAC创建ASM磁盘组时配置多路径和UDEV
2874 7