磁盤分區-gdisk用法

gdisk用法linux

 

gdisk - InteractiveGUIDpartitiontable (GPT) manipulatorxcode

GPTfdisk (akagdisk) isatext-modemenu-drivenprogramforcreationandmanipulationbash

ofpartitiontables. ide

1 使用gdisk的緣由ui

1)因爲fdisk命令不能很好的支持GPT分區this

[root@local ~]# fdisk /dev/sdb
WARNING: fdiskGPTsupportiscurrentlynew, andthereforeinanexperimentalphase. Useatyourowndiscretion.
Welcometofdisk (util-linux 2.23.2).


Changeswillremaininmemoryonly, untilyoudecidetowritethem.
Becarefulbeforeusingthewritecommand.
Command (mforhelp):

MBR分區不支持大於2T的分區,全部對於如今打的硬盤分區來講只能使用GPT分區,因此就要使用gdisk命令spa

2gdisk也能夠處理MBR分區的硬盤,無論你硬盤多大,都不在話下。code

2 gdisk對硬盤就行分區,這裏以vmware虛擬機爲例orm

1)查看爲分區以前的磁盤信息,這裏以/dev/sdc爲例blog

[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
GPTfdisk (gdisk) version 0.8.6

Partitiontablescan:
MBR: notpresent
BSD: notpresent
APM: notpresent
GPT: notpresent

CreatingnewGPTentries.

Command (? forhelp):

3)根據提示,輸入?得到幫助

Command (? forhelp): ?
b    backupGPTdatatoafile
c    changeapartition'sname
d    deleteapartition                    #刪除分區
i    showdetailedinformationonapartition
l    listknownpartitiontypes            #列出分區類型
n    addanewpartition                    #添加新分區
o    createanewemptyGUIDpartitiontable (GPT)
p    printthepartitiontable                #打印分區列表
q    quitwithoutsavingchanges            #不保存退出
r    recoveryandtransformationoptions (expertsonly)
s    sortpartitions
t    changeapartition'stypecode        #修改分區類型
v    verifydisk
w    writetabletodiskandexit            #保存退出
x    extrafunctionality (expertsonly)
?    printthismenu 

4)添加一個新分區

Command (? forhelp): n

Partitionnumber (1-128, default 1): 1         #輸入分區編號,默認爲1,由於是/dev/sdc硬盤的第一塊分區。
Firstsector (34-10485726, default = 2048) or {+-}size{KMGTP}:         #輸入扇區的開始位置,選擇默認便可,也可手動指定。
Lastsector (2048-10485726, default = 10485726) or {+-}size{KMGTP}:+2G     #輸入扇區的結束位置,固然通常都是指定磁盤大小,這裏輸入+2G表示新分區大小爲2G。
Currenttypeis 'Linuxfilesystem'
HexcodeorGUID (Ltoshowcodes, Enter = 8300):        #指定文件系統,默認便可,分區完成後能夠修改。

Changedtypeofpartitionto 'Linuxfilesystem' 

5)查看分區後的分區列表

Command (? forhelp): p    #查看分區列表
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Logicalsectorsize: 512 bytes
Diskidentifier (GUID): 428D4D72-0C16-4AD6-80A3-7BCACED6F40C
Partitiontableholdsupto 128 entries
Firstusablesectoris 34, lastusablesectoris 10485726
Partitionswillbealignedon 2048-sectorboundaries
Totalfreespaceis 6291389 sectors (3.0 GiB)
NumberStart (sector) End (sector) SizeCodeName
1 2048 4196351 2.0 GiB 8300 Linuxfilesystem    #看到分區已經添加成功 

6)保存分區並退出

Command (? forhelp):w

Finalcheckscomplete. AbouttowriteGPTdata. THISWILLOVERWRITEEXISTING
PARTITIONS!!

Doyouwanttoproceed? (Y/N):    y
OK; writingnewGUIDpartitiontable (GPT) to /dev/sdc.
Theoperationhascompletedsuccessfully. 

能夠看到分區以添加成功

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

到此分區、文件系統建立成功,經過掛載就可使用磁盤了

相關文章
相關標籤/搜索