fdisk 命令 linux磁盤分區管理
用途:觀察硬盤之實體使用情形與分割硬盤用。
使用方法:
一、在 console 上輸入 fdisk -l /dev/sda ,觀察硬盤之實體使用情形。
二、在 console 上輸入 fdisk /dev/sda,可進入分割硬盤模式。
1. 輸入 m 顯示所有命令列示。
2. 輸入 p 顯示硬盤分割情形。
3. 輸入 a 設定硬盤啟動區。
4. 輸入 n 設定新的硬盤分割區。
4.1. 輸入 e 硬盤為[延伸]分割區(extend)。
4.2. 輸入 p 硬盤為[主要]分割區(primary)。
5. 輸入 t 改變硬盤分割區屬性。(制作交換分區時會用到)
6. 輸入 d 刪除硬盤分割區屬性。
7. 輸入 q 結束不存入硬盤分割區屬性。
8. 輸入 w 結束並寫入硬盤分割區屬性
擴展資料:linuxidc.com總結的添加分區的流程
fdisk /dev/sda
p 列出當前分區表
n 添加新分區
回車 選擇開始的塊地址,直接回車默認就可以了
+2G 輸入要添加分區的大小+200M,+1G這樣的都能識別
回車 確定
w 寫入並退出
partprobe 更新當前分區表給內核 這一步非常重要, 否則你的分區重啟才能看到.
mkfs.ext3 /dev/sda6 格式化新建分區
mount /dev/sda6 /data 掛載
另外t 參數可以對分區格式做轉換,fd是raid類型,e8是做LVM時用到的pv類型。
前幾天在學RHCE的分區練習..所以這些。。已經相當熟悉了,呵呵.
Linux下fdisk命令操作磁盤詳解--添加、刪除、轉換分區等
linux下fdisk命令操作磁盤詳解--添加、刪除、轉換分區等
fdisk 操作硬盤的命令格式如下:
[root@localhost beinan]# fdisk 設備
比如我們通過 fdisk -l 得知 /dev/hda 或者 /dev/sda 設備;我們如果想再添加或者刪除
一些分區,可以用
[root@localhost beinan]# fdisk /dev/hda
或
[root@localhost beinan]# fdisk /dev/sda
注 在以后的例子中,我們要以 /dev/sda 設備為例,來講解如何用 fdisk 來操作添加、刪
除分區等動作;
1、fdisk 的說明;
當我們通過 fdisk 設備,進入相應設備的操作時,會發現有如下的提示;以 fdisk /dev/sda
設備為例,以下同;
[root@localhost beinan]# fdisk /dev/sda
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 注:l 是列出分區類型,以供我們設置相應分區的類型;
m print this menu 注:m 是列出幫助信息;
n add a new partition 注:添加一個分區;
o create a new empty DOS partition table
p print the partition table 注:p 列出分區表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改變分區類型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分區表寫入硬盤並退出;
x extra functionality (experts only) 注:擴展應用,專家功能;
其實我們常用的只有注有中文的,其它的功能我們不常用(呵,主要是我不會用,否則早會
賣弄一下了);x 擴展功能,也不是常用的;一般的情況下只要懂得 d l m p q t w 就行
了;
下面以實例操作來詳述,沒有例子沒有辦法就,新手也看不懂;
2、列出當前操作硬盤的分區情況,用 p;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
3、通過 fdisk 的 d 指令來刪除一個分區;
Command (m for help): p 注:列出分區情況;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:執行刪除分區指定;
Partition number (1-6): 6 注:我想刪除 sda6 ,就在這里輸入 6 ;
Command (m for help): p 注:再查看一下硬盤分區情況,看是否刪除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):
警告:刪除分區時要小心,請看好分區的序號,如果您刪除了擴展分區,擴展分區之下的邏
輯分區都會刪除;所以操作時一定要小心;如果知道自己操作錯了,請不要驚慌,用 q 不保
存退出;切記切記!!!!在分區操作錯了之時,千萬不要輸入 w 保存退出!!!
4、通過 fdisk 的 n 指令增加一個分區;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help): n 注:增加一個分區;