導航:首頁 > 操作系統 > linux創建分區fdisk

linux創建分區fdisk

發布時間:2022-08-30 07:18:00

㈠ 如何在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 查看幫助,或者在命令使用中根據提示操作

㈡ Linux下怎樣用fdisk命令分區

body{
line-height:200%;
}
Linux下怎樣用fdisk命令分區
1、添加新硬碟
因為在現有的硬碟當中,所有的空間以及被分配完了;這個時候就需要拿一塊新的硬碟,然後在新硬碟進行分區。

虛擬機的好處是:只要你的真實機硬體空間足夠,那你想添加多少塊硬碟都可以;但是虛擬機必須先關閉,否則是不能添加新硬碟的
2、查看新硬碟
[root@localhost~]#
fdisk
-l
查詢新添加的硬碟是否被識別。
3、使用fdisk命令分區
[root@localhost~]#
fdisk
/dev/sbd
fdisk交互指令說明
a:設置可引導標記
b:編輯bsd磁碟標簽
c:設置DOS操作系統兼容標記
d:刪除一個分區
l:顯示已知的文件系統類型,82為Linux
swqp分區,83為Linux分區
m:顯示幫助帶單
n:新建分區
o:建立空白DOS分區表
p:顯示分區列表
q:不保存退出
t:改變一個分區的系統ID
w:保存退出
4、重新讀取分區表信息
[root@localhost~]#
partprobe
5、格式化分區
[root@localhost~]#
mkfs
-t
ext4
/dev/sdb1
6、建立掛載點並掛載
[root@localhost~]#
mkdir
/disk1
[root@localhost~]#
mount
/dev/sdb1/disk1/

㈢ 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

㈣ linux用fdisk怎麼分區

分區是將一個硬碟驅動器分成若干個邏輯驅動器,分區是把硬碟連續的區塊當做一個獨立的磁硬使用。分區表是一個硬碟分區的索引,分區的信息都會寫進分區表。

分區工具fdisk用法介紹:

p、列印分區表。

n、新建一個新分區。

d、刪除一個分區。

q、退出不保存。

w、把分區寫進分區表,保存並退出。

㈤ 如何在linux下使用fdisk創建一個10M的物理分區,並要求開機掛載在/my 目錄下

1、fdisk
2、輸入n
3、選primary處的1、2、3、4中的一個
4、first cylinder按回車預設
5、last cylinder處輸入:+10M
6、輸入:w寫入磁碟信息並退出
7、mkfs.ext3 /dev/xxx格式化新建的分區
8、每次通過命令掛載:mount /dev/xxx /my
或:編輯/etc/fstab加入:/dev/xxx /my ext3 defaults 1 2
保存後,重啟後系統自動載入分區

㈥ 如何使用Linux進行磁碟分區(步驟)

用fdisk這個工具,可以查看硬碟分區情況
fdisk
-l
/dev/sda(如果是scsi介面的話)
,會發現創建了幾個分區,分別用sda1,sda2,sda3,表示。如果,你上面顯示的是柱面數,和下面結束的柱面數相同的話,說明你沒有多餘的空間了。fdisk
/dev/sda
按m鍵,會出現提示,n是添加一個分區,p是列印現在的分區情況,d是刪除一個分區,q是退出,w是保存,你可以先刪除分區,然後再重新創建分區,然後w保存退出,執行#partprobe,會使分區立即生效,不必重啟。希望對你有幫助。

㈦ linux系統下fdisk命令怎麼用

磁碟分區管理命令:fdisk
root@local:~#fdisk
/dev/sdb
(進入磁碟管理,可使用U盤測試)
Command
(m
for
help):
p
(查看所有分區)
Command
(m
for
help):
a
(設置可引導分區,就是*標記)
Command
(m
for
help):
n
(創建一個新分區,給新分區分配空間時,起始卷值默認即可,可避免空間浪費,然後給出空間大小,如+10000M就表明要分配1G的空間,然後自動計算結束卷值)
Command
(m
for
help):
t
(給新分區設置分區類型,可以通過L顯示所有分區類型)
Command
(m
for
help):
w
(保存退出,但也需重啟才能生效)
Command
(m
for
help):
q
(不保存退出)
新分區還需被格式化成相應的文件系統類型才能使用,常用的有mkfs.ext3(格式化為ext3格式,是Linux分區常用的)、mkfs.msdos(格式化為Fat16格式)和mkfs.vfat(格式化為Fat32格式);如mkfs.vfat
/dev/sdb1

㈧ linux 用fdisk 怎麼分區 舉例分一個擴展分區

首先輸入fdisk
-l查看系統中的硬碟及分區信息
然後fdisk
/dev/sdb
(假設sdb是新添加的硬碟即還沒分區)
輸入m查看幫助,輸入n新添加一個分區,輸入e添加一個擴展分區,輸入擴展分區號*,其他的按照默認的就行了,然後輸入w保存並退出
接下來就是格式化了
假設新建的分區號為1,輸入mkfs
-t
ext3
/dev/sdb1,回車就可以了
這樣一個擴展分區就建立好了

㈨ linux 用fdisk 怎麼分區

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

㈩ linux_fdisk命令詳解

磁碟分區管理命令:fdisk
root@local:~#fdisk /dev/sdb (進入磁碟管理,可使用U盤測試)
Command (m for help): p (查看所有分區)
Command (m for help): a (設置可引導分區,就是*標記)
Command (m for help): n (創建一個新分區,給新分區分配空間時,起始卷值默認即可,可避免空間浪費,然後給出空間大小,如+10000M就表明要分配1G的空間,然後自動計算結束卷值)
Command (m for help): t (給新分區設置分區類型,可以通過L顯示所有分區類型)
Command (m for help): w (保存退出,但也需重啟才能生效)
Command (m for help): q (不保存退出)

新分區還需被格式化成相應的文件系統類型才能使用,常用的有mkfs.ext3(格式化為ext3格式,是Linux分區常用的)、mkfs.msdos(格式化為Fat16格式)和mkfs.vfat(格式化為Fat32格式);如mkfs.vfat /dev/sdb1

閱讀全文

與linux創建分區fdisk相關的資料

熱點內容
演算法創新就業方向 瀏覽:417
演算法最優解作者 瀏覽:863
通達信紅綠寶塔線指標源碼 瀏覽:656
app是什麼東西合法嗎 瀏覽:227
怎麼鎖app視頻教程 瀏覽:839
迅捷pdf注冊碼生成器 瀏覽:742
androidsdkosx 瀏覽:296
壓縮面膜紙熒光 瀏覽:839
app怎麼分身三個 瀏覽:744
電影bt下載源碼 瀏覽:421
iwatch屏幕加密晶元 瀏覽:570
公安主題網站源碼 瀏覽:986
天津市伺服器供應商雲伺服器 瀏覽:115
數控車床子程序編程 瀏覽:110
floydwarshall演算法 瀏覽:717
丟失微信app怎麼找 瀏覽:252
php能寫前端嗎 瀏覽:9
伺服器如何更改raid模式 瀏覽:92
方舟伺服器怎麼導出來 瀏覽:610
手機顯示伺服器異常什麼鬼 瀏覽:381