2023年11月25日发(作者:)

扇区、柱面、块

扇区

磁盘的每一面被分为很多条磁道,即表面上的一些同心圆,越接近中心,圆就越小。

每一个磁道又按512个字节为单位划分为等分,叫做扇区。

柱面

盘片表面上以盘片中心为圆心,不同半径的同心圆称为磁道。硬盘通常由重叠的一组盘

片构成,每个盘面都被划分为数目相等的磁道,并从外缘的“0”开始编号,具有相同编号

的磁道形成一个圆柱,(即柱面是一个立体概念,磁道是一个平面概念,同一个盘面上的,

柱面大小是所有盘面相同半径的磁道大小总和),称之为磁盘的柱面。

块是文件系统中的概念,操作系统读取硬盘的时候,不会一个个扇区地读取,这样效率

太低,而是一次性连续读取多个扇区,即一次性读取一个""block。这种由多个扇区组

成的"",是文件存取的最小单位。

引导扇区(Boot Sector)

通常指设备的第一个扇区,用于加载并转让处理器控制权给操作系统.

通常包括主引导记录(MBR+ 硬盘分区表(DPT+ 结束标志

MBR 446字节,DPT 64字节,结束标志2字节。

MBR通过检查DPT分区信息引导系统跳转至OBR

OBROS Boot Record)即操作系统引导扇区

由于硬盘的主引导记录中仅仅为分区表保留了64个字节的存储空间,而每个分区的参

数占据16个字节,故主引导扇区中总计只能存储4个分区的数据。也就是说,一块物理硬

盘只能划分为4个主分区磁盘,并且MBR最大仅支持2TB的硬盘.

总结

主分区至少有1个,最多4 4主或者3+1扩展)

扩展分区可以没有,最多1

且主分区+扩展分区总共不能超过4

磁盘分区的最小单位是磁柱(Cylinder

磁盘存储的最小单位是扇区(Sector

文件系统的最小单位是区块(Block

GPT

GPT,即Globally Unique Identifier Partition Table Format,全局唯一标识符的分

区表的格式这种分区模式相比MBR有着非常多的优势。

首先,它至少可以分出128个分区,完全不需要扩展分区和逻辑分区来帮忙就可以分

出任何想要的分区来。其次,GPT最大支持18EB的硬盘,几乎就相当于没有限制。

1KB=1024B=10^3

1MB=1024KB=10^6

1GB=1024MB=10^9

1TB=1024GB=10^12

1PB=1024TB=10^15

1EB=1024PB=10^18

1ZB= 1024 EB=10^21

1YB= 1024 ZB=10^24

1BB= 1024 YB=10^27

磁盘分区

新增磁盘

/dev/hd(x) # IDE SATA接口 had第一块,hdb第二块 .

/dev/sd(x) # SCSI 接口 (sda 第一块,sdb第二块

磁盘分区命令fdisk(类似命令parted,适用于GPT分区表)

fdisk /dev/sdb

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

u change display/entry units

v verify the partition table

w write table to disk and exit #保存并推出

x extra functionality (experts only) #附加额外功能

例:新建分区(选择1-100柱面)

Command (m for help): n #新建分区

Command action

e extended

p primary partition (1-4)

p #新建主分区

Partition number (1-4): 1 #选择分区号

First cylinder (1-2610, default 1): #选择起始柱面

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 100 #选择结束柱面

例:新建分区(指定大小,注意在结束柱面位置添加分区的大小值)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (101-2610, default 101):

Using default value 101

Last cylinder or +size or +sizeM or +sizeK (101-2610, default 2610): +2000M #填写大小

可能遇到的问题:

分区时要选择起始柱面 和结束柱面 ,起始柱面处不能添加大小(例如+100M

例:新建扩展分区

Command (m for help): n

Command action

e extended

p primary partition (1-4)

e #选择扩展分区

Partition number (1-4): 3

First cylinder (345-2610, default 345): 450

Last cylinder or +size or +sizeM or +sizeK (450-2610, default 2610): 1000

例:新建逻辑分区

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l

First cylinder (450-1000, default 450):

Using default value 450

Last cylinder or +size or +sizeM or +sizeK (450-1000, default 1000): 800

Command (m for help): p

sdb分区后/dev/ 下应该出现相应的sdb(*) ,为对应分区文件,

如未出现请执行partprobe或者partx a后再查看(对于rhel6以后的版本)。如果这两种

方式不能解决可能需要重启系统。

注意:扩展分区不能格式化文件系统,只能对逻辑分区格式化文件系统。

格式化文件系统

格式化文件系统

mkfs

-L 卷标名称 定义分区的卷标

-b 1024/2048/4096 定义块的大小

-N 定义i节点的数量(分区大小/i节点密度=i节点的数量)

-i 定义i节点密度

-m 数字指定保留区块的百分比(保留分区的5%空间给管理员,防止

管理员没有使用空间)

可格式化文件系统类型

[root@vfast ~]# ls /sbin/mkfs*

/sbin/mkfs /sbin/2 /sbin/

/sbin/ /sbin/3 /sbin/

格式化文件系统

[root@vfast /]# 3 /dev/sdb1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

100576 inodes, 200804 blocks

10040 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=209715200

7 block groups

32768 blocks per group, 32768 fragments per group

14368 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

挂载、开机自动挂载

mount /dev/sdb1 /mnt/

开机自动挂载

配置文件/etc/fstab

1 2 3 4 5 6

分区名称 挂载点 dump转储,

卷标 转存

LABEL=

UUID=

一般都配置0 致性检查

fsck