您的位置:首页 > 运维架构 > Linux

Linux运维系统工程师系列---20

2015-07-01 08:25 531 查看
磁盘管理---分区---fdisk命令
查看分区信息:

[root@server254 ~]# fdisk -l /dev/sda
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x00015b22
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 2637 20971520 83 Linux
/dev/sda3 2637 2898 2097152 82 Linux swap / Solaris

heads——磁头数量

sector——扇区数量

track——磁道

cylinder——柱面的数量

Device :设备名

Boot:是否是/boot分区

Start:开始柱面

End:结束柱面

Blocks:有多少数据块

Id:文件系统类型的标签 83:Linux类型(ext3,ext4) 82:swap

System:表示系统类型

进入分区环境:

[root@server254 ~]# fdisk /dev/sdb
Command (m for help): m

Command action
a toggle a bootable flag 启动标志

b edit bsd disklabel 编辑磁盘标签(label)

d delete a partition 删除分区

l list known partition types 列出已知的分区类型

m print this menu 打印菜单

n add a new partition 添加分区

p print the partition table 打印分区表

q quit without saving changes 不保存退出

t change a partition's system id 改变分区类型

w write table to disk and exit 保存退出
Command (m for help): n
Command action

e extended 扩展分区

p primary partition (1-4) 主分区

分区表在0磁道0扇区,这512字节中包含三个部分,446字节是bootloader,64字节分区表,2字节结束标志。一个分区占16字节,64/16最多4个分区。但是想创建超过4个分区,于是出现了扩展分区。

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5221, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): +200M
Command (m for help): p
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0xc383cb90
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

通知内核重新读取分区表:
[root@server254 ~]# partx /dev/sdb
# 1: 63- 417689 ( 417627 sectors, 213 MB)
# 2: 0- -1 ( 0 sectors, 0 MB)
# 3: 0- -1 ( 0 sectors, 0 MB)
# 4: 0- -1 ( 0 sectors, 0 MB)

[root@server254 ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0xc383cb90
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux

[root@server254 devices]# partx -a /dev/sdb 有时候不加-a可能不好用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息