第2章命令工具
/dev/sdal * 2048 1026047 512000 83 Linux /dev/sda2 1026048 46086143 22530048 8e Linux LVM #第一块磁盘有两个分区:/dev/sdal与/dev/sda2 Disk /dev/sdb: 8589 MB, 8589934592 bytes #第二块磁盘容量约8GB …中间部分省略… Device Boot Start End Blocks Id System #第二块磁盘的分区表为空,暂时没有分区
[root@centos6 Desktop]# fdisk -cu /dev/sdb #这里为第二块磁盘进行分区
Command (m for help):尋 #在此输入指令m获得帮助
Command action
a toggle a bootable flag #切换分区启动标记
b edit bsd disklabel #编辑bsd磁盘标签
c toggle the dos compatibility flag #切换dos兼容模式
d delete a partition #删除分区
1 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 #创建新的Sun磁盘标签
亡 change a partition9s system id #修改分区id,可以通过1查看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): n
Command action
e extended #输入e创建扩展分区
P primary partition (1-4) #输入P创建主分区
r Partition number (1-4): £ #输入分区编号为1
First sector (2048-16777215f default 2048): #回车从默认的2048扇区开始分区
Using default value 2048
Last sectorf .sectors or +size{K,M,G} (2048-16777215, default 16777215): +2G
#创建2GB的分区
Command (m for help) : p #显示是否创建成功
…中间部分省略…
• 57 •
Device Boot Start End Blocks Id System
/dev/sdbl 2048 4196351 2097152 83 Linux
#可以看到/dev/sdbl分区已经被创建,容量为2GB
Command (m for heJpJ ••囂 #创建新分区
Command action
e extended
p primary partition (1-4)
• #选择创建扩展分区
Partition number (1-4): 2
First sector (4196352-16777215, default 4196352):
#回车从默认的4196352磁柱开始分区
Using default value 4196352
Last sectorf 十sectors or +size{K,M,G} (4196352-16777215, default 16777215):
#回车将剩余的所有空间划分为扩展分区
Using default value 16777215
Command (m for help) : zi #仓1|建新分区
Command action
1 logical (5 or over)
p primary partition (1-4)
i #选择创建逻辑分区
First sector (4198400-16777215, default 4198400):
#回车从默认的W9S4⑼扇区幵始
Using default value 4198400
Last sectorf .sectors or +size{K,M,G} (4198400-16777215f default 16777215) : +2G
#创建2GB的分区
Command (m for help) : p #查看分区情况
…中间部分省略…
Device Boot Start End Blocks Id System
/dev/sdbl 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 16777215 6290432 5 Extended
/dev/sdb5 4198400 8392703 2097152 S3 Linux
Command (m for help): d
Partition number (1 -5) : 5
#删除分区
#输入需要删除的分区编号
Command (m for help): p
…中间部分省略…
Device Boot Start
/dev/sdbl 2048
/dev/sdb2 4196352
End
4196351
16777215
#查看分区情况
Blocks Id System
2097152 83 Linux
6290432 5 Extended
Command (m for help) : w
#保存并退出