home products tech support contact us

 Linux 技術支援    ⇒   基礎篇    進階篇    補腦篇    指令索引    中⇒ENG
版權所有, 引用請註明出處
 

fdisk 分割硬碟

fdisk 是傳統分割硬碟工具,但因太古老了只能支援 MBR 分割表, MBR 所分割的硬碟不能超過 2TB,所以建議改使用另一分割硬碟工具 parted 就可支援大於 2TB 的 GPT 分割,且 parted 還支援先進格式化硬碟
fdisk有分命令模式和互動模式,要分割硬碟 partition 只能用互動模式,命令模式只能顯示硬碟資訊,大多數的發行版只允許 superuser 才能操作 fdisk

例:
# fdisk -l ←列出硬碟資訊
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

# fdisk /dev/sda ←分割硬碟〝/dev/sda〞(進入互動模式,如不知有那有那些命令可用,可按 <m>)

例:(進入fdisk 後按 <m> 後的操作)
Command (m for help): m
Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
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 ←寫入 partition 並退出
x   extra functionality (experts only)

上例畫面中,任何的改變如刪除/新增 partition 等動作都只是在 RAM 中操作,就算操作錯誤也不會誤刪硬碟資料,覺得操作有誤隨時都可按 <q>退出來後悔不會危及硬碟,除非按 <w>寫入硬碟,所以按<w>時建議按<p>印出所規劃的 partition 再確認 。

 
fdisk 進階的互動模式和用法請參考連結