關閉→
當前位置:知科普>IT科技>linux刪除分區命令

linux刪除分區命令

知科普 人氣:1.92W

linux系統下刪除分區命令是:fdisk命令。

1、fdisk命令簡介:

fdisk - Partition table manipulator for Linux ,譯成中文的意思是磁盤分區表操作工具,其實就是分區工具。fdsik 能劃分磁盤成為若干個區,同時也能為每個分區指定分區的文件系統,比如linux 、fat32、 linux 、linux swap 、fat16 以及其實類Unix類操作系統的文件系統等;當然我們用fdisk 對磁盤操作分區時,並不是一個終點,我們還要對分區進行格式化所需要的文件系統;這樣一個分區才能使用;這和DOS中的fdisk 是類似的。

2、fdisk 操作硬盤的命令格式:

[root@localhost beinan]# fdisk 設備

通過 fdisk -l 得知 /dev/hda 或者 /dev/sda 設備;如果想再添加或者刪除

一些分區,可以用

[root@localhost beinan]# fdisk /dev/hda

[root@localhost beinan]# fdisk /dev/sda

3、fdisk 的説明:

通過 fdisk 設備,進入相應設備的操作時,會有如下的提示。

[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) 注:擴展應用,專家功能;12345678910111213141516171819

舉例:

列出當前操作硬盤的分區情況,用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 Linux123456789

通過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):1234567891011121314151617181920

注意:刪除分區時要小心,請看好分區的序號,如果您刪除了擴展分區,擴展分區之下的邏輯分區都會刪除;所以操作時一定要小心;如果知道自己操作錯了,用q不保存退出;在分區操作錯了時,千萬不要輸入w保存退出。

linux刪除分區命令

TAG標籤:#linux #分區 #命令 #