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

相关推荐

  • 基于ssl的mysql的主从复制

    实验环境: system:CentOS Linux release 7.2.1511 (Core) mariadb server:mariadb-server-5.5.44-2.el7.centos.x86_64 master server:10.1.51.20/16 slave serv…

    2016-11-22
  • 简述硬盘参数和ext2文件系统

    硬盘类型: HDD机械硬盘和SSD固态硬盘: HDD是现在最普通的硬盘,容量大,稳定,是存储数据的首选。SSD是现在新兴的硬盘,相比HDD,它的并发i/o高,传输速度可达HDD的几倍以上,无噪音低功耗,而且轻便防震,随着各大厂商发力,性价比也越来越高,要求性能高或者数据轻度使用者可以优先考虑SSD。   容量:存储数据的空间大小,一般来说HDD每G…

    Linux干货 2016-04-19
  • 提问的智慧

    译文 译文: 捷克语 丹麦语 爱沙尼 亚语 法语 德语 希伯来语 匈牙利语 意大利语 日语 波 兰语 俄语 西班牙语 瑞典语 土 耳其语. 如果你想复制、镜像、翻译或引用本文,请参阅我的 复制须知. 弃权申明 …

    Linux干货 2015-03-20
  • 一起学DNS系列(十三)图文详说A、CNAME、MX和NS记录

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://jeffyyko.blog.51cto.com/28563/226194    前面用了12个小节对DNS的基础、以及Windows的DNS系统作了较详细的描述,下面的几节主要是说一些有关DNS应用方面…

    2015-03-18
  • rsyslog配置详解,结合mysql+loganalyzer展现

        环境:Centos7.2 前言:系统日日夜夜不停地运行着,有这么一个守护进程,兢兢业业地不断记录它运行产生的日志,有不起眼的闲言碎语,值得管理员撇一眼的系统报错,也默默地接收来自进程的严厉警告,甚至在内核崩溃前夕,同样不遗余力记录着当时发生的情形。他是无言的记录者,没有特别的修辞,但他的记录的文字却掷地有声。本…

    系统运维 2016-10-25
  • 内核编译安装

    编译内核前期准备工作 (1)准备好开发环境 (2)获取目标主机航硬件设备的相关信息 (3)获取目标主机系统功能的相关信息 (4)获取内核源代码包     可以从www.kernel.com上下载 (5)安装好需要使用的包组     Server Platform&nbs…

    Linux干货 2016-09-13

评论列表(2条)

  • renjin
    renjin 2017-04-28 09:58

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

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

    干货满满!