導航:首頁 > 程序命令 > linux建立主分區和邏輯分區的命令

linux建立主分區和邏輯分區的命令

發布時間:2022-04-27 12:17:31

① 虛擬機里的linux 硬碟分區問題,在線等

1.
fdisk /dev/sdb
說明: 硬碟分區的表示:在Linux 是通過hd*x 或 sd*x 表示的,其中 * 表示的是a、b、c ... ... x表示的數字 1、2、3 ... ... hd大多是IDE硬碟;sd大多是SCSI或移動存儲;
n :增加分區的命令
p :主分區
1 :因為你還沒有第一個
直接回車 :1開始
+10240M :10G
n :增加分區的命令
e :擴展分區 由擴展分區內包含邏輯分區
2
直接回車:因為一共40g 後面的30G就全給擴展分區了
n :增加分區的命令
l :會提示由幾開始,看你linux系統的設定了 你設分區可以有4個 那就從5開始
如:Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
5 :
直接回車:
+10240M:
6 :
直接回車:
直接回車:剩下的20G
wq :保存退出
mkfs.ext3 /dev/sdb2 : 格式化擴展分區
reboot :重啟
mkfs.ext3 /dev/sdb1
mkfs.ext3 /dev/sdb5
mkfs.ext3 /dev/sdb6
mkdir -p /mnt/sdb1
mkdir -p /mnt/sdb2
mkdir -p /mnt/sdb5
mkdir -p /mnt/sdb6
mount /dev/sdb1 /mnt/sdb1
mount /dev/sdb2 /mnt/sdb2
mount /dev/sdb5 /mnt/sdb5
mount /dev/sdb6 /mnt/sdb6
df :查看
umount /dev/sdb6 :卸載
我只是把前面人說的一步一步寫出來,你這是考試題?

② 怎樣給linux操作系統分區

1、磁碟分區格式說明

linux分區不同於windows,linux下硬碟設備名為(IDE硬碟為hdx(x為從a—d)因為IDE硬碟最多四個,SCSI,SATA,USB硬碟為sdx(x為a—z)),硬碟主分區最多為4個,不用說大家也知道…..所以主分區從sdb1開始到sdb4,邏輯
分區從sdb5開始,(邏輯分區永遠從sdb5開始…)設備名可以使用fdisk–l查看。

2、分區詳解

使用ssh遠程連接工具登錄到系統,使用fdisk-l命令查看磁碟狀態。

劃分的空間與我們計劃劃分相同,最後輸入w回車,進行保存退出。

再次使用fdisk-l命令就可以查看到磁碟hdb已經分區成功。

磁碟劃分成功,下面就要對分區進行格式化了

使用命令mkfs-text3/dev/hdb1

mkfs-text3/dev/hdb5

mkfs-text3/dev/hdb6

mkfs-text3/dev/hdb7

分別對磁碟進行格式化處理,格式化為ext3文件類型。

③ 闡述linux中主分區和邏輯分區的產生

sudo fdisk /dev/sda

命令(輸入 m 獲取幫助): n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p):
選p就是新建主分區
選l就是新建邏輯分區

④ linux怎麼在磁碟里的主分區創建邏輯分區

主分區里就不能建啥邏輯分區了,是佔用一個主分區記錄的位置建擴展分區,在擴展分區里建若干個邏輯分區。
以前mbr盤只能建立四個主分區或擴展分區,多個擴展分區windows不認,linux也不認,但是可以用。
後來改變了,有gpt盤,這個是沒限制了,都是主分區,windows給留了127個位置……

⑤ linux如何創建邏輯分區(LVM邏輯卷管理)

不同發行版的安裝程序採用的分區工具不盡相同,不知道你安裝的哪個發行版?
而且看你的問題好像與LVM不是一回事。如果只是需要建立一個普通的邏輯分區,在新建分區時默認是主分區,你可以在主分區這個選項旁邊下拉菜單,改變為邏輯分區就OK了,只要建立了邏輯分區,擴展分區就自動產生了。
LVM則需要用一個或將幾個分區(PV)建立卷組(VG),然後在VG上建立邏輯卷(LV)。如果安裝程序的分區軟體不支持LVM,這個操作過程是無法完成的。

⑥ Linux當中怎麼用parted分區請寫明步驟

Linux中進行磁碟分區一般是用fdisk這個命令,但是fdisk命令無法支持大於2TB以上的分區,而parted命令就是用於2TB以上大小的磁碟分區的工具。parted命令的用法:
1. 列出磁碟分區的信息(這個可以看到接下來新建分區的起始點):
形式:parted 磁碟設備名稱 print
例如:parted /dev/hdc print
2. 新建一個分區:
形式:parted 磁碟設備名稱 mkpart logical 文件系統類型 新建分區起始位置 新建分區結束位置
例子:parted /dev/hdc mkpart logical ext3 20.3G 80.3G
說明:/dev/hdc是磁碟設備名稱,mkpart是新建分區,logical表示是一個邏輯分區,ext3是文件系統類型,20.3G是分區起始位置,這個是查看分區信息的時候,顯示的最末尾的那個分區End這一欄的,80.3G是結束位置,也就是說這個新建的分區有60G大小。
3. 刪除一個分區:
形式:parted 磁碟設備名稱 rm 設備Number
例子:parted /dev/hdc rm 7
說明:設備Number的那個數字是用parted列出的分區信息裡面,有一列是Number號碼,需要刪除那個分區就對應那個數字。

⑦ Linux怎麼創建邏輯分區

用linux系統提供的終端創建分區的時候 使用L那個參數,表示是logical邏輯分區。此外,還可以用第三方的分區軟體創建分區。

⑧ 在LINUX系統中,分區與格式化硬碟的命令是什麼

Linux下常用的分區工具:
fdisk/sfdisk:命令行工具,各種版本和環境都能使用,包含在軟體包util-linux中
diskdruid:圖形化分區工具,只能在安裝REDHAT系統時使用。

第一步:fdisk
[root@novice ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

[root@novice ~]# fdisk /dev/sdb

Command (m for help): #在輸入上面的命令後會出現左邊的提示,輸入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
x extra functionality (experts only)
#help雖然是英文的,可都很簡單,在這里不再解釋。

#現在,我們正式開始分區的操作:
Command (m for help): n #新建分區
Command action
e extended
p primary partition (1-4)
#e/p分別對應擴展分區 /主分區;我們先分四個主分區,每個50M;然後再來增加主分區或擴展分區,看會出現怎樣的狀況,嘿嘿。
p #分區類型為主分區
Partition number (1-4, default 1): 1 #分區號,在這里我們依次選擇1、2、3、4
First sector (2048-496127, default 2048): #指定分區的起始扇區,一般默認,按enter鍵即可。
Last sector, +sectors or +size{K,M,G} (2048-496127, default 496127): +50M #指定分區的終止扇區,根據前面的提示我們可以做出相應的選擇+sectors 或 +size{K,M,G}
Command (m for help): p #用p列印出已建好的分區列表

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux

#剩下的三個分區的建立操作同上
#分好四個主分區後的情況如下
Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 309298 25+ 83 Linux
#已經建好四個主分區啦,現在我們來看看如果再建主分區或是擴展分區的話會出現怎樣的情況:
Command (m for help): n
You must delete some partition and add an extended partition first
#看到了吧,不能再建分區啦!要再建分區的話必須刪除some分區,再新建一個擴展分區才行。
#現在,我們刪掉一個主分區,來新建擴展分區
Command (m for help): d #刪除分區
Partition number (1-4): 4 #選擇要刪除分區的分區號,我們選第四個

Command (m for help): p #列印,如下,四個分區變成了三個!

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux

#新建一個擴展分區
#如果在沒有建滿三個主分的區的情況下建立擴展分區,相關選項會有些不同。
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First sector (309248-496127, default 309248): #enter,默認
Using default value 309248
Last sector, +sectors or +size{K,M,G} (309248-496127, default 496127): #enter,默認,使用剩餘空間
Using default value 496127

Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended

#接下來,我們在新建的擴展分區里再新建兩個邏輯分區,因為已經有了三個主分區,這里不會再顯示是建立邏輯分區還是主分區的提示!
Command (m for help): n
First sector (311296-496127, default 311296): #enter
Using default value 311296
Last sector, +sectors or +size{K,M,G} (311296-496127, default 496127): +50M

Command (m for help): n
First sector (415744-496127, default 415744): #enter
Using default value 415744
Last sector, +sectors or +size{K,M,G} (415744-496127, default 496127): #enter
Using default value 496127

Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#上面的列表,就是我們今天分區的成果啦!接下來保存退出,重啟計算機,就可以進行下一步的mkfs操作啦!如果忘記了相關的操作命令,記得按m!!!
Command (m for help): w #保存
The partition table has been altered!

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

另:在建好分區後,我們還可以更改相關分區的文件系統類型
#如,我們要把第二個主分區改成Linux下的交換分區,操作如下
Command (m for help): t #更改文件系統類型
Partition number (1-6): 2 #選擇第二個分區
Hex code (type L to list codes): L #選擇要更改的文件系統編碼,可以按L來查看相關編碼信息。
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
............
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 82 #查找到linux swap的編碼為82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p
..............
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 82 Linux swap / Solaris
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#最後別忘了保存!如果你須要的話!
#擴展分區不能直接使用,邏輯分區只能建立在擴展分區上!

第二步:mkfs(mkfs時分區的格式最好與fdisk設定的分區格式一致,不然.......)
mkfs支持ext2 ext3 vfa msdos jfs reiserfs等文件系統。
用法1:mkfs -t
例: mkfs -t ext3 /dev/sdb2

用法2:mkfs.
例:mkfs,vfat /dev/sdb3

mke2fs支持ext2/ext3文件系統
用法:mke2fs [-j]
例:mke2fs -j /dev/sdb5
# 更多更具體的用法請參照相關命令的man手冊

下面,接著實驗:
例一
[root@novice ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
12824 inodes, 51200 blocks
2560 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=52428800
7 block groups
8192 blocks per group, 8192 fragments per group
1832 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

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

第三部:掛載
掛載:mount
例:mount /dev/sdb1 /mnt /sdb1

卸載:umonut
例:umount /dev/sdb1

⑨ Linux中如何創建新分區啊

Linux下可以用fdisk命令新建分區,方法如下:
1、首先查看硬碟信息,用fdisk -l命令,如果有硬碟有剩餘空間就可以對其進行分區。
2、下面對/dev/sdb 進行分區
3、有擴展分區和主分區,邏輯分區在擴展分區中建立。注意到括弧中的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
4、同上所述建立擴展分區:
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
5、擴展分區建好就可以在擴展分區建立邏輯分區了
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
6、上面顯示已經建好一個主分區,一個邏輯分區,但是這些現在還沒有生效,需要保存退出。
Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks. 《Linux就該這么學》這本書上有詳細的介紹

⑩ LINUX如何分區

fdisk /dev/sdb
輸入m查看幫助:
下面列出常用命令。
n new 新建分區,會讓選主分區還是擴展分區,
p print 列印當前分區表
w write 將修改寫入硬碟並退出,慎重操作
d delete 刪除分區
t type 修改分區類型,例如創建swap分區
l list 列出分區類型代碼

閱讀全文

與linux建立主分區和邏輯分區的命令相關的資料

熱點內容
解壓機壓什麼不爛 瀏覽:370
大牛盒子插件文件夾 瀏覽:12
用友t3如何遠程連接伺服器 瀏覽:741
保時捷行車記錄儀需要什麼app 瀏覽:715
文件伺服器中的DFS全名是什麼 瀏覽:460
365小說app現在叫什麼 瀏覽:54
海貝音樂app的獨佔usb輸出是什麼 瀏覽:400
宏觀經濟學高鴻業pdf 瀏覽:296
我的榮耀9x有方舟編譯器嗎 瀏覽:974
linux父子進程通信 瀏覽:889
程序員為什麼總是用手機 瀏覽:309
安卓9程序怎麼用 瀏覽:846
如何恢復編譯 瀏覽:851
mybatispdf 瀏覽:880
plc使用的是單片機嗎 瀏覽:814
如何讓安卓平板音量上限 瀏覽:236
代理伺服器請求超時如何設置 瀏覽:117
pdf批量蓋章 瀏覽:780
珠江寬頻網關伺服器地址 瀏覽:711
程序員練打字網站 瀏覽:578