Linux磁盘管理1
實驗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
轉載于:https://blog.51cto.com/suixinerwei/1534314
總結
以上是生活随笔為你收集整理的Linux磁盘管理1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到成堆的苍蝇是怎么回事
- 下一篇: 查看Linux上程序或进程用到的库