linux中mbr最大多少分区,Linux中磁盘mbr分区——实践篇(示例代码)

Linux中磁盘mbr分区——实践篇

fdisk命令

语法

fdisk(选项)(参数)

选项

-b 指定每个分区的大小

-l 列出分区表信息

-v 显示版本信息

参数

设备文件:例如/dev/sda

实例

选择要操作的磁盘:

[root@vathe ~]#fdisk /dev/sdb

输入m可列出可以执行的命令:

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition # 删除分区

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 # 该表分区的系统id

u change display/entry units

v verify the partition table

w write table to disk and exit # 保存分区并退出

x extra functionality (experts only)

查看分区表:

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x48283ee0

Device Boot Start End Blocks Id System

新建分区表:

Command action #选择新增分区类型

e extended #扩展分区

p primary partition (1-4) #主分区

p // 键入p

Partition number (1-4): 1 // 键入1

First cylinder (1-1305, default 1): # 选择分区起点柱面

Using default value 1 //选择默认1

Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +1G #设置分区大小1G,+表示往起点后添加,-表示往起点前添加分区

查看确认分区创建成功:

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes # 磁盘总大小 10.7GB

255 heads, 63 sectors/track, 1305 cylinders # 255个磁头,每个磁道63个扇区,1305个圆柱面

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x48283ee0

Device Boot Start End Blocks Id System

/dev/sdb1 1 132 1060258+ 83 Linux

再建立一个扩展分区

Command (m for help): n

Command action e extended p primary partition (1-4) e Partition number (1-4): 4 # 分区号 First cylinder (133-1305, default 133): 900

Last cylinder, +cylinders or +size{K,M,G} (900-1305, default 1305): +500M # 扩展分区500M

在扩展分区中创建逻辑分区

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4) l

First cylinder (900-964, default 900):

Using default value 900 Last cylinder, +cylinders or +size{K,M,G} (900-964, default 964): +100M  # 逻辑分区100M

查看分区列表

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x48283ee0

Device Boot Start End Blocks Id System

/dev/sdb1 1 132 1060258+ 83 Linux

/dev/sdb4 900 964 522112+ 5 Extended

/dev/sdb5 900 913 112423+ 83 Linux

保存退出

Command (m for help): w # 保存退出

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

查看

[[email protected] ~]#lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sr0 11:0 1 3.7G 0 rom

sda 8:0 0 200G 0 disk

├─sda1 8:1 0 200M 0 part /boot

├─sda2 8:2 0 20G 0 part /data

├─sda3 8:3 0 10G 0 part /home

├─sda4 8:4 0 1K 0 part

├─sda5 8:5 0 2G 0 part [SWAP]

└─sda6 8:6 0 167.8G 0 part /

sdb 8:16 0 10G 0 disk # 显示分区成功

├─sdb1 8:17 0 1G 0 part

├─sdb4 8:20 0 1K 0 part

└─sdb5 8:21 0 109.8M 0 part

分区成功,当然,要使用磁盘,还需要进行两部操作,才能使用磁盘——将磁盘挂载在具体目录(或文件),和对个分区进行格式化。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值