本文标识 : L00020
本文编辑 : 灭霸 编程工具 : redhat7 阅读时长 : 6分钟
首先选择要分区的磁盘,主要操作的时候要两外加一个磁盘哦,sda为系统盘,千万不要随意操作。
[root@localhost /]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xf9172280 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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)
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xf9172280
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (2048-20971519,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):2G
值超出范围。
Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):5
值超出范围。
Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):+2G
分区 1 已设置为 Linux 类型,大小设为 2 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
分区号 (2-4,默认 2):4
起始 扇区 (4196352-20971519,默认为 4196352):
将使用默认值 4196352
Last 扇区, +扇区 or +size{K,M,G} (4196352-20971519,默认为 20971519):+6G
分区 4 已设置为 Extended 类型,大小设为 6 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xf9172280
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb4 4196352 16779263 6291456 5 Extended
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
添加逻辑分区 5
起始 扇区 (4198400-16779263,默认为 4198400):+1G
值超出范围。
起始 扇区 (4198400-16779263,默认为 4198400):
将使用默认值 4198400
Last 扇区, +扇区 or +size{K,M,G} (4198400-16779263,默认为 16779263):+1G
分区 5 已设置为 Linux 类型,大小设为 1 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xf9172280
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb4 4196352 16779263 6291456 5 Extended
/dev/sdb5 4198400 6295551 1048576 83 Linux
命令(输入 m 获取帮助):w
这里w为保存上面操作,然后直接Enter,对磁盘进行分区就完成了,是不是很简单。
保存以后用fdisk -l查看分区的具体情况。