實驗01磁盤分區
實驗目標
爲虛擬機添加一塊80GB、SCSI接口的硬盤
劃分2個20GB的主分區剩餘作爲擴展分區
新建2個邏輯分區分別爲2GB、10GB
將第1個邏輯分區的類型改爲SWAPID 82
將第2個邏輯分區的類型改爲VFATID b
確認分區無誤後保存退出
使用partprobe識別新的分區表 【最好是重啓一次】
實驗環境
在虛擬機Linux系統下
實驗步驟
一、環境準備
1.在虛擬關機狀態下添加一塊80G、SCSI硬盤
2. 使用“fdisk”命令查看新添加硬盤的屬性
[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 85.8 GB, 85899345920bytes
255 heads, 63 sectors/track, 10443cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Disk /dev/sdb doesn't contain a validpartition table
3.劃分分區利用“fdisk”命令進入分區劃分模式
[root@localhost~]# fdisk /dev/sdb
4.劃分2個20G的主分區剩餘的爲擴展分區可以通過m查看幫助信息
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOSpartition 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 (expertsonly)
Command (m for help): n //n爲創建新分區的命令
Command action
e extended //e代表擴展分區
p primary partition (1-4) // p代表主分區
p
Partition number (1-4): 1 //數字代表分區號
First cylinder (1-10443, default 1): //默認柱面起始編碼
Using default value 1
Last cylinder or +size or +sizeM or+sizeK (1-10443, default 10443): +20G //設置分區大小“+”必須帶
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (2434-10443, default2434):
Using default value 2434
Value out of range.
Last cylinder or +size or +sizeM or+sizeK (2434-10443, default 10443): +20G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (4867-10443, default4867):
Using default value 4867
Last cylinder or +size or +sizeM or+sizeK (4867-10443, default 10443): //若不設置大小默認剩餘空間全部分給此分區
Using default value 10443
4. 在擴展分區中創建第1個2G邏輯分區並且修改分區類型爲SWAPID 82
Command (m for help): n
Command action
l logical (5 or over) //l代表邏輯分區
p primary partition (1-4) //由於只是3個主分區這裏還是會顯示你是否建立主分區若是4個則不顯示
l
First cylinder (4867-10443, default4867):
Using default value 4867
Last cylinder or +size or +sizeM or+sizeK (4867-10443, default 10443): +2G
Command (m for help): t //t表示修改分區類型的命令
Partition number (1-5): 5
Hex code (type L to list codes): 82 //爲swap的ID號
Changed system type of partition 5 to82 (Linux swap / Solaris)
5.在擴展分區中創建第2個10G邏輯分區並且修改分區類型爲VFATID b
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (5111-10443, default5111):
Using default value 5111
Last cylinder or +size or +sizeM or+sizeK (5111-10443, default 10443): +10G
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): b //b爲vfat的ID號
Changed system type of partition 6 to b(W95 FAT32)
6.確認劃分正確後保存退出
Command (m for help): w //w爲保存退出 q代表退出不保存
The partition table has been altered!
Calling ioctl() to re-read partitiontable.
WARNING: If you have created or modifiedany DOS 6.x
partitions, please see the fdisk manualpage for additional
information.
Syncing disks.
結果驗證
可以使用partprobe識別新的分區若還是無法顯示重啓
[root@localhost~]# fdisk -l /dev/sdb
Disk /dev/sdb: 85.8 GB, 85899345920bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2433 19543041 83 Linux
/dev/sdb2 2434 4866 19543072+ 83 Linux
/dev/sdb3 4867 10443 44797252+ 5 Extended
/dev/sdb5 4867 5110 1959898+ 82 Linux swap / Solaris
/dev/sdb6 5111 6327 9775521 b W95 FAT32