當前位置:首頁 » 操作系統 » linuxfdisk分區

linuxfdisk分區

發布時間: 2022-09-13 22:43:08

A. linux下的分區工具和Fdisk使用方法

現在發行版本的linux已經提供了圖形交互界面,很多的人還是感覺無從下手。原因主要是不清楚linux的分區規定,及linux分區工具—Fdisk的使用方法。下面從這兩個方面入手,來講解這個困擾大家的問題。
linux的分區規定
1.linux分區工具—Fdisk設備管理
在linux中,每一個硬體設備都映射到一個系統的文件,對於硬碟、光碟機等IDE或SCSI設備也不例外。
linux把各種IDE設備分配了一個由hd前綴組成的文件;而對於各種SCSI設備,則分配了一個由sd前綴組成的文件。例如,第一個IDE設備,linux就定義為hda;第二個IDE設備就定義為hdb;下面以此類推。而SCSI設備就應該是sda、sdb、sdc等。
2.linux分區工具—Fdisk分區數量
要進行分區就必須針對每一個硬體設備進行操作,這就有可能是一塊IDE硬碟或是一塊SCSI硬碟。對於每一個硬碟(IDE或SCSI)設備,linux分配了一個1到16的序列號碼,這就代表了這塊硬碟上面的分區號碼。例如,第一個IDE硬碟的第一個分區,在linux下面映射的就是hda1,第二個分區就稱作是hda2。對於SCSI硬碟則是sda1、sdb1等。
3.linux分區工具—Fdisk各分區的作用
在linux中規定,每一個硬碟設備最多能有4個主分區(其中包含擴展分區)構成,任何一個擴展分區都要佔用一個主分區號碼,也就是在一個硬碟中,主分區和擴展分區一共最多是4個。對於早期的DOS和Windows(Windows
2000以前的版本),系統只承認一個主分區,可以通過在擴展分區上增加邏輯盤符(邏輯分區)的方法,進一步地細化分區。
主分區的作用就是計算機用來進行啟動操作系統的,因此每一個操作系統的啟動,或者稱作是引導程序,都應該存放在主分區上。這就是主分區和擴展分區及邏輯分區的最大區別。我們在指定安裝引導linux的bootloader的時候,都要指定在主分區上,就是最好的例證。
linux規定了主分區(或者擴展分區)佔用1至16號碼中的前4個號碼。以第一個IDE硬碟為例說明,主分區(或者擴展分區)佔用了hda1、hda2、hda3、hda4,而邏輯分區佔用了hda5到hda16等12個號碼。因此,linux下面每一個硬碟總共最多有16個分區。
對於邏輯分區,linux規定它們必須建立在擴展分區上(在DOS和Windows系統上也是如此規定),而不是主分區上。
我們可以看到擴展分區能夠提供更加靈活的分區模式,但不能用來作為操作系統的引導。
除去上面這些各種分區的差別,我們就可以簡單地把它們一視同仁了。

B. linux 用fdisk 怎麼分區

在虛擬硬碟中使用Fdisk命令。

C. linux磁碟分區命令是什麼

Linux磁碟分區命令中有專門的分區命令fdisk和parted。其中fdisk命令較為常用,但不支持大於2TB的分區;如果需要支持大於2TB的分區,則需要使用parted命令,當然parted命令也能分配較小的分區。

D. 如何在Linux操作系統中新建磁碟分區

Linux下可以用fdisk命令新建分區,方法如下:
1、首先用fdisk -l命令查看硬碟信息,硬碟有剩餘空間就可以對其進行分區。
2、假設/dev/sdb 沒有使用,用 fdisk /dev/sdb [不會用請進入命令後根據提示鍵入m獲得幫助]
3、有擴展分區和主分區,邏輯分區在擴展分區中建立。注意到括弧中的1-4,最多隻能建四個主分區(包括擴展分區)。/dev/sdb沒有使用的話就先建一個主分區:
4、根據步驟3的說明建立擴展分區:
5、擴展分區建好就可以在擴展分區建立邏輯分區了
6、就會顯示已經建好一個主分區,一個邏輯分區,需要保存退出使分區設置生效。
7、如果fdisk命令不熟悉使用 fdisk -h 查看幫助,或者在命令使用中根據提示操作

E. Linux如何利用fdisk工具建立分區

fdisk磁碟分區工具

1.首先查看硬碟信息

fdisk -l 如果有硬碟有剩餘空間就可以對其進行分區

[root@bogon 桌面]# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4106 2048000 82 Linux swap / Solaris
/dev/sda4 4106 10444 50912256 5 Extended
/dev/sda5 4106 10444 50911232 83 Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
#從上面看出/dev/sda空間已經用完了,/dev/sdb沒有使用。

下面我們對/dev/sdb 進行分區

[root@bogon 桌面]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xfaa2aa49.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

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
x extra functionality (experts only)
fdisk選中/dev/sdb 輸入m所有基本選項都出現,輸入n新建分區

Command (m for help): n
Command action
e extended
p primary partition (1-4)
有擴展分區和主分區,邏輯分區在擴展分區中建立。注意到括弧中的1-4,最多隻能建四個主分區(包括擴展分區)。先建一個主分區:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p #建主分區
Partition number (1-4): 1 #分區號為1
First cylinder (1-2610, default 1): #直接回車默認從第一個柱面開始劃分
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G #加空間大小,這里有很多種選擇:+後面單位可以接M,G,K(記得要大寫)表示劃分你所加的空間,也可以是柱面數。不管怎樣都不能超過該磁碟剩餘的空間否則無效。

Command (m for help): p #分好後查看分區信息,剛所做的所有一目瞭然。

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux

同上所述建立擴展分區:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e #建立擴展分區
Partition number (1-4): 4
First cylinder (263-2610, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-2610, default 2610): +4G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended

擴展分區建好我們就可以在擴展分區建立邏輯分區了

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l #建邏輯分區
First cylinder (263-785, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-785, default 785): +2G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
/dev/sdb5 263 524 2104483+ 83 Linux
上面顯示已經建好一個主分區,一個邏輯分區,但是這些現在還沒有生效我們需要保存退出。

Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@bogon 桌面]# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4106 2048000 82 Linux swap / Solaris
/dev/sda4 4106 10444 50912256 5 Extended
/dev/sda5 4106 10444 50911232 83 Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
/dev/sdb5 263 524 2104483+ 83 Linux

再次查看就看到了/dev/sdb的分區信息,雖然現在我們看到進行分區了,但是內核kenel還沒有識別為了不要重啟將分區表寫入kenel我們要用到partprobe工具:使kenel重新讀取分區表。
[root@bogon 桌面]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (設備或資源忙). As a result, it may not reflect all of your changes until after reboot.

kenel識別分區表後,我們還不能使用它要對其進行格式化。mkfs.加文件系統格式,擴展分區是不能格式化的。

[root@bogon 桌面]# mkfs.ext4 /dev/sdb1 #格式化成ext4文件格式(要分區格式化,不能將整個硬碟格式化)
mke2fs 1.41.12 (17-May-2010)
文件系統標簽=
操作系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

正在寫入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon 桌面]# mkfs.ext4 /dev/sdb5 #格式化邏輯分區
mke2fs 1.41.12 (17-May-2010)
文件系統標簽=
操作系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

正在寫入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

格式化後就可以使用了

[root@bogon 桌面]# mkdir /bak
[root@bogon 桌面]# mount -o loop /dev/sdb1 /bak #掛載該分區到/bak
[root@bogon 桌面]# df -TH #查看當前硬碟掛載信息
文件系統 類型 容量 已用 可用 已用%% 掛載點
/dev/sda5 ext4 52G 3.9G 45G 8% /
tmpfs tmpfs 528M 279k 528M 1% /dev/shm
/dev/sda1 ext4 204M 28M 166M 15% /boot
/dev/sda2 ext4 31G 2.9G 27G 10% /usr
.host:/ vmhgfs 144G 41G 104G 29% /mnt/hgfs
/ios/RHEL6.3.iso
iso9660 3.2G 3.2G 0 100% /guazai
/dev/sdb1 ext4 2.2G 71M 2.0G 4% /bak

F. Linux中如何創建新分區啊

Linux中創建新分區步驟如下。

1、查看當前系統磁碟容量,以及已經分好的分區。

這就可以從其中一個分區上拿一點空間出來創建一個新的分區。

G. 如何使用Fdisk來管理Linux上的分區

fdisk命令參數介紹
p、列印分區表。
n、新建一個新分區。
d、刪除一個分區。
q、退出不保存。
w、把分區寫進分區表,保存並退出。
實例:
[root@localhost ~]# fdisk /dev/hdd

按"p"鍵列印分區表

這塊硬磁尚未分區
按"n"鍵新建一個分區。

出現兩個菜單e表示擴展分區,p表示主分區
按"p"鍵出現提示:"Partition number (1-4): "選擇主分區號
輸入"1"表示第一個主分區。

直接按回車表示1柱面開始分區。

提示最後一個柱面或大小。
輸入+5620M 按回車
表示第一個分區為5G空間。
按"p"查看一下分區

這樣一個主分區就分好了。
接下來分第二個主分區,把剩餘空間都給第二個主分區。
按"n"
鍵新增一個分區
按"p"鍵設為主分區
輸入"2"把主分區編號設為2
按兩下回車把剩餘空間分給第二個主分區。
按"p"鍵列印分區表

按"w"鍵保存退出。
讀者可根據自己的硬碟大小來劃分合適的分區。

4、使用分區
在使用硬碟之前必須對其分區進行格式化,並掛載。
[root@localhost ~]#mkfs.ext3 /dev/hdd1
[root@localhost ~]#mkfs.ext3 /dev/hdd2
創建掛載目錄
[root@localhost ~]#mkdir /hdd1 /hdd2
掛載/dev/hdd1 /dev/hdd2
[root@localhost ~]#mount /dev/hdd1 /hdd1
[root@localhost ~]#mount /dev/hdd2 /hdd2
查看
[root@localhost ~]#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 7.5G 2.8G 4.3G 40% /
/dev/hda1 99M 17M 78M 18% /boot
tmpfs 62M 0 62M 0% /dev/shm
/dev/hdd1 2.5G 68M 2.3G 3% /hdd1
/dev/hdd2 2.5G 68M 2.3G 3% /hdd2

H. linux系統格式化分區用哪個命令

linux系統格式化分區用fdisk命令。

Linux fdisk是一個創建和維護分區表的程序,它兼容DOS類型的分區表、BSD或者SUN類型的磁碟列表。

語法

fdisk [必要參數][選擇參數]
必要參數:

-l 列出素所有分區表

-u 與"-l"搭配使用,顯示分區數目

選擇參數:

-s<分區編號> 指定分區

-v 版本信息

菜單操作說明

m :顯示菜單和幫助信息

a :活動分區標記/引導分區

d :刪除分區

l :顯示分區類型

n :新建分區

p :顯示分區信息

q :退出不保存

t :設置分區號

v :進行分區檢查

w :保存修改

x :擴展應用,高級功能
常用:
fdisk -l 查看分區
fdisk -lu

當提示許可權不夠時,前面加上sudo

熱點內容
網吧u盤拒絕訪問 發布:2025-05-16 14:13:50 瀏覽:259
無線網檢查網路配置是怎麼回事 發布:2025-05-16 14:04:03 瀏覽:220
網路爬蟲python代碼 發布:2025-05-16 14:03:26 瀏覽:516
汽車小組件怎麼弄到安卓桌面 發布:2025-05-16 13:51:12 瀏覽:220
linuxg編譯器下載 發布:2025-05-16 13:50:58 瀏覽:776
centosc編譯器 發布:2025-05-16 13:50:17 瀏覽:948
安卓手機如何變換桌面 發布:2025-05-16 13:39:33 瀏覽:515
sql存儲過程命令 發布:2025-05-16 13:17:54 瀏覽:146
用紙做解壓小玩具西瓜 發布:2025-05-16 13:04:09 瀏覽:936
區域網xp無法訪問win7 發布:2025-05-16 13:03:58 瀏覽:943