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.www58058.com/74039

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

相關推薦

  • 馬哥教育網絡班20期+第2周課程練習

    1、Linux上的文件管理類命令都有哪些,其常用的使用方法及其相關示例演示 文件管理命令:ls、cd、pwd、mkdir、rmdir、cp、rm.、mv、touch、cat、more、less、head、tail 1)ls命令:顯示目錄文件   -a 顯示所有文件,包括隱藏文件  ~]# ls -a /etc.  &n…

    Linux干貨 2016-06-23
  • Selinux

    Selinux:強制訪問控制的安全模塊,linux內核2.6版本后集成在內核中。     selinux的四種工作類型:             strict:centos5中,每隔進程都受到seli…

    Linux干貨 2016-09-18
  • OpenSSH的應用和利用OpenSSL創建私有CA簽證給httpd服務器開起https

    一、OpenSSH     OpenSSH與SSH協議是遠程登錄的首選連接工具。它加密所有流量,以消除竊聽,連接劫持和其它攻擊。OpenSSH常常被誤認以為與OpenSSL有關系,但實際上這兩個項目的有不同的目的,不同的發展團隊,名稱相近只是因為兩者有同樣的軟件發展目標──提供開放源代碼的加密通訊軟件。  &…

    Linux干貨 2016-04-24
  • Mysql備份II

    Mysql備份II V.II.I單臺或共用機器,數據量和訪問量小50G< 1 Mysqldump(全導出,導庫,導表) 鎖表 如果這時有些入會鎖住或者超時 2 至少停止寫入 防止innodb配置還沒刷到磁盤里 先flash tables /usr/local/mysql/bin/mysqladmin -S /tmp/mysql.so…

    Linux干貨 2016-06-09
  • Nginx

        Nginx(發音同engine x)是一個 Web服務器,也可以用作反向代理,負載平衡器和 HTTP緩存。Nginx 可以部署在網絡上使用 FastCGI,腳本,SCGI 處理程序,WSGI 應用服務器或 Phusion 乘客模塊的動態 HTTP 內容,并可作為軟件負載均衡器。Nginx 使…

    Linux干貨 2017-08-29
  • Linux磁盤管理(一)之分區、格式化、掛載使用

    磁盤管理(一)   本章節內容: 磁盤結構 分區類型   管理分區   管理文件系統   掛載設備   一、磁盤結構: 1、設備號碼:  主設備號:major number, 標識設備類型 次設備號:minor number, 標識同一類型下的不同設備  &n…

    Linux干貨 2016-08-26

評論列表(2條)

  • renjin
    renjin 2017-04-28 09:58

    主要對gdisk分區工具展開了介紹,內容總結的很詳細,排版也很好,加油!

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

    干貨滿滿!

欧美性久久久久