Linux的MBR分区

一 相关背景
硬件设备都是有Linux系统自动识别的 。
必须对硬盘进行分区、格式化、和挂载后才能使用。
 
二 实战
[root@localhost ~]# LANG=zh_CN.UTF-8
[root@localhost ~]# fdisk
用法:
fdisk [选项] <磁盘> 更改分区表
fdisk [选项] -l <磁盘> 列出分区表
fdisk -s <分区> 给出分区大小(块数)
 
选项:
-b <大小> 扇区大小(512、1024、2048或4096)
-c[=<模式>] 兼容模式:“dos”或“nondos”(默认)
-h 打印此帮助文本
-u[=<单位>] 显示单位:“cylinders”(柱面)或“sectors”(扇区,默认)
-v 打印程序版本
-C <数字> 指定柱面数
-H <数字> 指定磁头数
-S <数字> 指定每个磁道的扇区数
[root@localhost ~]# fdisk -l
 
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0004476d
 
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 63940607 31457280 83 Linux
/dev/sda3 63940608 105883647 20971520 83 Linux
/dev/sda4 105883648 209715199 51915776 5 Extended
/dev/sda5 105885696 126857215 10485760 83 Linux
/dev/sda6 126859264 135247871 4194304 82 Linux swap / Solaris
/dev/sda7 135249920 209715199 37232640 83 Linux
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
 
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
 
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
 
Device does not contain a recognized partition table
使用磁盘标识符 0x406d79b0 创建新的 DOS 磁盘标签。
 
命令(输入 m 获取帮助):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 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-16777215,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-16777215,默认为 16777215):+3000M
分区 1 已设置为 Linux 类型,大小设为 3 GiB
 
命令(输入 m 获取帮助):p
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x406d79b0
 
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 6146047 3072000 83 Linux
 
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
分区号 (2-4,默认 2):
起始 扇区 (6146048-16777215,默认为 6146048):
将使用默认值 6146048
Last 扇区, +扇区 or +size{K,M,G} (6146048-16777215,默认为 16777215):
将使用默认值 16777215
分区 2 已设置为 Extended 类型,大小设为 5.1 GiB
 
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
添加逻辑分区 5
起始 扇区 (6148096-16777215,默认为 6148096):
将使用默认值 6148096
Last 扇区, +扇区 or +size{K,M,G} (6148096-16777215,默认为 16777215):+2000M
分区 5 已设置为 Linux 类型,大小设为 2 GiB
 
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
添加逻辑分区 6
起始 扇区 (10246144-16777215,默认为 10246144):
将使用默认值 10246144
Last 扇区, +扇区 or +size{K,M,G} (10246144-16777215,默认为 16777215):
将使用默认值 16777215
分区 6 已设置为 Linux 类型,大小设为 3.1 GiB
 
命令(输入 m 获取帮助):p
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x406d79b0
 
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 6146047 3072000 83 Linux
/dev/sdb2 6146048 16777215 5315584 5 Extended
/dev/sdb5 6148096 10244095 2048000 83 Linux
/dev/sdb6 10246144 16777215 3265536 83 Linux
 
命令(输入 m 获取帮助):d
分区号 (1,2,5,6,默认 6):2
分区 2 已删除
 
命令(输入 m 获取帮助):p
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x406d79b0
 
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 6146047 3072000 83 Linux
 
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
分区号 (2-4,默认 2):
起始 扇区 (6146048-16777215,默认为 6146048):
将使用默认值 6146048
Last 扇区, +扇区 or +size{K,M,G} (6146048-16777215,默认为 16777215):+3G
分区 2 已设置为 Linux 类型,大小设为 3 GiB
 
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): e
分区号 (3,4,默认 3):
起始 扇区 (12437504-16777215,默认为 12437504):
将使用默认值 12437504
Last 扇区, +扇区 or +size{K,M,G} (12437504-16777215,默认为 16777215):
将使用默认值 16777215
分区 3 已设置为 Extended 类型,大小设为 2.1 GiB
 
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
添加逻辑分区 5
起始 扇区 (12439552-16777215,默认为 12439552):
将使用默认值 12439552
Last 扇区, +扇区 or +size{K,M,G} (12439552-16777215,默认为 16777215):+1G
分区 5 已设置为 Linux 类型,大小设为 1 GiB
 
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
添加逻辑分区 6
起始 扇区 (14538752-16777215,默认为 14538752):
将使用默认值 14538752
Last 扇区, +扇区 or +size{K,M,G} (14538752-16777215,默认为 16777215):
将使用默认值 16777215
分区 6 已设置为 Linux 类型,大小设为 1.1 GiB
 
命令(输入 m 获取帮助):p
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x406d79b0
 
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 6146047 3072000 83 Linux
/dev/sdb2 6146048 12437503 3145728 83 Linux
/dev/sdb3 12437504 16777215 2169856 5 Extended
/dev/sdb5 12439552 14536703 1048576 83 Linux
/dev/sdb6 14538752 16777215 1119232 83 Linux
 
命令(输入 m 获取帮助):w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk -l
 
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0004476d
 
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 63940607 31457280 83 Linux
/dev/sda3 63940608 105883647 20971520 83 Linux
/dev/sda4 105883648 209715199 51915776 5 Extended
/dev/sda5 105885696 126857215 10485760 83 Linux
/dev/sda6 126859264 135247871 4194304 82 Linux swap / Solaris
/dev/sda7 135249920 209715199 37232640 83 Linux
 
磁盘 /dev/sdb:8589 MB, 8589934592 字节,16777216 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x406d79b0
 
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 6146047 3072000 83 Linux
/dev/sdb2 6146048 12437503 3145728 83 Linux
/dev/sdb3 12437504 16777215 2169856 5 Extended
/dev/sdb5 12439552 14536703 1048576 83 Linux
/dev/sdb6 14538752 16777215 1119232 83 Linux

猜你喜欢

转载自cakin24.iteye.com/blog/2392144