实验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