Fdisk && Gdisk 指令

MBR 分割表請使用 fdisk 分割, GPT 分割表請使用 gdisk 分割!

Fdisk 磁區列表


fdisk -l /dev/sda

Fdisk 指令模式


fdisk /dev/sda

WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).

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.


命令 (m 以獲得說明):m

命令動作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition						<==刪除一個partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition						<==新增一個partition
   o   create a new empty DOS partition table
   p   print the partition table				<==在螢幕上顯示分割表
   q   quit without saving changes				<==不儲存離開fdisk程式
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit				<==將剛剛的動作寫入分割表
   x   extra functionality (experts only)

Fdisk 刪除分割區


fdisk /dev/sda

WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).

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.


命令 (m 以獲得說明):d
partition number 選擇要刪除分割代號

如已刪除完分割,按下 w 寫入硬碟

Gdisk


[[email protected] ~]# gdisk 裝置名稱

範例:由前一小節的 lsblk 輸出,我們知道系統有個 /dev/vda,請觀察該磁碟的分割與相關資料
[[email protected] ~]# gdisk /dev/vda  <==仔細看,不要加上數字喔!
GPT fdisk (gdisk) version 0.8.6

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

Found valid GPT with protective MBR; using GPT.  <==找到了 GPT 的分割表!

Command (? for help):     <==這裡可以讓你輸入指令動作,可以按問號 (?) 來查看可用指令
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  # 不儲存分割就直接離開 gdisk
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 # 儲存分割操作後離開 gdisk
x       extra functionality (experts only)
?       print this menu
Command (? for help):  



參考相關網頁