gdisk用法

gdisk用法

 

gdisk  – Interactive GUID partition table (GPT) manipulator

GPT  fdisk (aka gdisk) is a textmode menudriven program for creation and manipulation

       of partition tables.

1 使用gdisk 的原因

1)由于fdisk 命令不能很好的支持GPT分区

[root@local ~]# fdisk /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. 
Command (m for help):

MBR分区不支持大于2T的分区,所有对于现在打的硬盘分区来说只能使用GPT分区,所以就要使用gdisk 命令

2gdisk 也可以处理MBR分区的硬盘,不管你硬盘多大,都不在话下。

2 gdisk 对硬盘就行分区,这里以vmware虚拟机为例

1)查看为分区之前的磁盘信息,这里以/dev/sdc为例

[root@local ~]# gdisk -l /dev/sdd
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present 
Creating new GPT entries.
Disk /dev/sdd: 10485760 sectors, 5.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5ECA06B5-A105-4DCB-B6DD-96A13D0C1A93
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 10485693 sectors (5.0 GiB)
 Number  Start (sector)    End (sector)  Size       Code  Name 

当然也可用fdis命令查看

[root@local ~]# fdisk -l /dev/sdc

Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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

2gdisk 命令对磁盘进行操作

 [root@local ~]# gdisk  /dev/sdc

GPT fdisk (gdisk) version 0.8.6
Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present 
Creating new GPT entries. 
Command (? for help):

3)根据提示,输入? 获得帮助

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

4)添加一个新分区

Command (? for help): n
Partition number (1-128, default 1): 1             #输入分区编号,默认为1,因为是/dev/sdc硬盘的第一块分区。
First sector (34-10485726, default = 2048) or {+-}size{KMGTP}:  #输入扇区的开始位置,选择默认即可,也可手动指定。 
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}:+2G  #输入扇区的结束位置,当然一般都是指定磁盘大小,这里输入+2G 表示新分区大小为2G。
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):         #指定文件系统,默认即可,分区完成后可以修改。
Changed type of partition to 'Linux filesystem'

5)查看分区后的分区列表

Command (? for help):  p     #查看分区列表
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 428D4D72-0C16-4AD6-80A3-7BCACED6F40C
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 6291389 sectors (3.0 GiB) 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         4196351   2.0 GiB     8300  Linux filesystem      #看到分区已经添加成功

6)保存分区并退出

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
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.

可以看到分区以添加成功

3 创建文件系统

 [root@local ~]# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1              isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

到此分区、文件系统创建成功,通过挂载就可以使用磁盘了

原创文章,作者:linux is not unix,如若转载,请注明出处:http://www.178linux.com/74039

(6)
linux is not unixlinux is not unix
上一篇 2017-04-23
下一篇 2017-04-24

相关推荐

  • linux学习的环境构建

    俗话说磨刀不误砍柴工,所以在加入马哥linux培训班后第一件事情就是构建学习环境。在这里把一些心得分享给大家。 1:通过测试比较服务器选择运行ESXI6.0的虚拟机。刚开始准备采用微软的Hyper-v的,但是管理Hyper-v需要域环境(工作组环境下虽然也可以管理,但是配置复杂和安全性很低),额外的增加了系统开销所以果断放弃。 2:通过网络获得Esxi6.0…

    Linux干货 2016-02-28
  • CentOS计划任务详解

    一、计划任务应用场景:        需要每天对服务器上的数据进行备份,但是白天服务器的访问量较大,服务器承受着较大的压力,备份任务只能在夜晚服务器较空闲时才能进行。或者需要临时在某时间点执行一个任务等,都需要用到计划任务的功能。 二、计划任务分类:    &…

    Linux干货 2016-09-09
  • N25-第二周作业

    1、linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示 linux上处理目录的常用命令:     ls :列出目录     cd :切换目录     pwd:显示当前工作路径    &nbs…

    Linux干货 2016-12-13
  • 文件查找(Find和Locate)常用用法及摩根定律趣解(重要)

    文件查找(Find和Locate)常用用法及摩根定律趣解(重要) 摩根定律: 非(A 且 B)=(非 A)或(非 B) 非(A 或 B)=(非 A)且(非 B) 这样看起来不是很好理解下面通过一些列图片给大家展示; 图(1)  图(2)  图二中的黑色就A且B,A且B的反面三种情况(如图1)即为(非A)或(非B)。因此…

    Linux干货 2016-08-21
  • linux文本处理工具

    linux文本处理工具 1.Linux 文件系统上的特殊权限: SUID     SGID   Sticky       进程的安全上下文:(1)任何一个可执行程序文件能不能启动为进程,取决发起者对程序文件是否拥有执行去权限       &…

    Linux干货 2017-02-25
  • shell编程之函数

    函数:函数function是由若干条shell命令组成的语句块,实现代码 重用和模块化编程      1)函数的定义: 可在 命令行,脚本的一部分,只有函数的单独文件 中定义        两部分组成:函数名和函数体;函…

    Linux干货 2016-08-21

评论列表(2条)

  • renjin
    renjin 2017-04-28 09:58

    主要对gdisk分区工具展开了介绍,内容总结的很详细,排版也很好,加油!

  • 逆神阳
    逆神阳 2018-02-13 23:04

    干货满满!