硬盘初识
CHS,LBA, MBR,GPT
机械硬盘和固态硬盘
机械硬盘(HDD):
Hard Disk Drive,即是传统普通硬盘,主要由:盘片,磁头,盘片转轴及控制电机,磁头控制器,数据转换器,接口,缓存等几个部分组成。机械硬盘中所有的盘片都装在一个旋转轴上,每张盘片之间是平行的,在每个盘片的存储面上有一个磁头,磁头与盘片之间的距离比头发丝的直径还小,所有的磁头联在一个磁头控制器上,由磁头控制器负责各个磁头的运动。磁头可沿盘片的半径方向运动,加上盘片每分钟几千转的高速旋转,磁头就可以定位在盘片的指定位置上进行数据的读写操作。数据通过磁头由电磁流来改变极性方式被电磁流写到磁盘上,也可以通过相反方式读取。硬盘为精密设备,进入硬盘的空气必须过滤
固态硬盘(SSD):
Solid State Drive,用固态电子存储芯片阵列而制成的硬盘,由控制单元和存储单元(FLASH芯片、 DRAM芯片)组成。固态硬盘在接口的规范和定义、功能及使用方法上与普通硬盘的完全相同,在产品外形和尺寸上也与普通硬盘一致设备文件
相较于HDD, SSD在防震抗摔、传输速率、功耗、重量、噪音上有明显优势, SSD传输速率性能是HDD的2倍。相较于SSD, HDD在价格、容量、使用寿命上占有绝对优势
硬盘有价,数据无价,目前SSD不能完全取代HHD
硬盘接口类型
并行:
IDE: 133MB/s
SCSI: 640MB/s
串口:
SATA: 6Gbps
SAS: 6Gbps
USB: 480MB/s
rpm: rotations
per minute
硬盘存储术语
head:磁头
track:磁道
cylinder: 柱面
sector: 扇区, 512bytes(mbr)
在linux设备上,磁盘是有设备编号的
设备号码:
主设备号: major number, 标识设备类型
次设备号: minor number, 标识同一类型下的不同设备
磁盘设备的设备文件命名: /dev/DEV_FILE
SCSI, SATA, SAS, IDE,USB: /dev/sd
虚拟磁盘: /dev/vd
不同磁盘标识: a-z,aa,ab…
/dev/sda, /dev/sdb, …
同一设备上的不同分区: 1,2, …
/dev/sda1, /dev/sda5
机械硬盘结构
CHS/LBA寻址
CHS
C:cylinder
H:head
S:sector
采用24bit位寻址
其中前10位表示cylinder,中间8位表示head,后面6位表示sector。
一个柱面大小:
512bytes(sector) * 2^6(sector/track) * 2^8(head)
=8388608bytes=8192Kb=8Mb
最大寻址空间8GB
LBA(logical block addressing)
LBA是一个整数,通过转换成CHS格式完成磁盘具体寻址
LBA采用48个bit位寻址
最大寻址空间128PB
由于CHS寻址方式的寻址空间在大概8GB以内,所以在磁盘容量小于大概8GB时,可以使用CHS寻址方式或是LBA寻址方式;在磁盘容量大于大概8GB时,则只能使用LBA寻址方式
CHS与LBA转换
#c、#h、#s分别是磁柱、磁头、扇区的编号
#lba是逻辑区块编号
H=heads per cylinder,每个磁柱的磁头数
S=sectors per track,每磁道的扇区数
#lba=(#c*H+#h)*S+#s-1
LBA可用以下公式对应到CHS:
#c=#lba/(S*H)
#h=(#lba/S)%H
#s=(#lba%S)+1
例如:
CHS总数=[600, 10, 84],求#lba=1234所对应的CHS编号:
#c=1234/(84*10)=1
#h=(1234/84)%10=4
#s=(1234%84)+1=59
所以:
#chs=(1, 4, 59)
磁盘分区
为什么分区
优化I/O性能
实现磁盘空间配额限制
提高修复速度
隔离系统和程序
安装多个OS
采用不同文件系统
分区方式
两种分区方式: MBR, GPT
MBR分区格式
MBR: Master Boot Record, 1982年, 使用32位表示扇区数, 分区不超过2T
如何分区:按柱面
0磁道0扇区: 512bytes
446bytes: boot loader
64bytes:分区表
16bytes: 标识一个分区
2bytes: 55AA
4个主分区; 3主分区+1扩展(N个逻辑分区)
标准的MBR结构
位址 |
功能 |
描述 |
0000-0088 |
主引导程序 |
主引导程序 |
0089-01BD |
出错信息数据区 |
出错区 |
01BE-01CD |
分区1(16字节) |
分区表 |
01CE-01DD |
分区2(16字节) |
|
01DE-01ED |
分区3(16字节) |
|
01EE-01FD |
分区4(16字节) |
|
01FE |
55 |
结束标志 |
01FF |
aa |
硬盘分区结构信息
存储字节数 |
内容及含义 |
第1字节 |
引导标志,值为80H表示活动分区,00H表示非活动分区 |
第2,3,4字节 |
本分区的起始磁头号,扇区号,柱面号。其中: 磁头号–第2字节 扇区号–第3字节的低六位 柱面号–第3字节高2位,第4字节8位 |
第5字节 |
分区类型符: 00H-表示该分区未使用 06H-FAT16基本分区 0BH-FAT32基本分区 05H-扩展分区 07H-NTFS分区 0FH-(LBA模式)扩展分区(83H为linux分区) |
第6,7,8字节 |
本分区的结束磁头号,扇区号,柱面号。其中: 磁头号–第6字节 扇区号–第7字节的低六位 柱面号–第7字节高2位,第8字节8位 |
第9,10,11,12字节 |
分区起始相对扇区号 |
第13,14,15,16字节 |
分区总的扇区数 |
GPT分区格式
GPT:GUID(Globals Unique Identifiers)
partitiontable 支持128个分区,使用64位,支持8Z(512Byte/block ) 64Z (4096Byte/block)使用128位UUID(Universally Unique Identifier) 表示磁盘和分区 GPT分区表自动备份在头和尾两份,并有CRC校验位UEFI (统一扩展固件接口)硬件支持GPT,使操作系统启动
GPT的分区信息是在分区中,而不象MBR一样在主引导扇区,为保护GPT不受MBR类磁盘管理软件的危害,GPT在主引导扇区建立了一个保护分区(Protective MBR)的MBR分区表(此分区并不必要),这种分区的类型标识为0xEE,这个保护分区的大小在Windows下为128MB,Mac OS X下为200MB,在Window磁盘管理器里名为GPT保护分区,可让MBR类磁盘管理软件把GPT看成一个未知格式的分区,而不是错误地当成一个未分区的磁盘。
另外,为了保护分区表,GPT的分区信息在每个分区的头部和尾部各保存了一份,以便分区表丢失以后进行恢复。
@font-face { font-family: 宋体 }
@font-face { font-family: 宋体 }
@font-face { font-family: Consolas }
@font-face { font-family: “等线 Light” }
@font-face { font-family: “@宋体” }
@font-face { font-family: “@等线 Light” }
p.MsoNormal, li.MsoNormal, div.MsoNormal { mso-style-unhide: no; mso-style-qformat: yes; mso-style-parent: “”; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: none; font-size: 12pt; mso-bidi-font-size: 11.0pt; font-family: Consolas; mso-fareast-font-family: 宋体; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
h1 { mso-style-priority: 9; mso-style-unhide: no; mso-style-qformat: yes; mso-style-link: “标题 1 Char”; mso-style-next: 正文; margin: 17pt 0 16.5pt; text-align: justify; text-justify: inter-ideograph; line-height: 240%; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 1; font-size: 22pt; font-family: Consolas; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 22.0pt }
h2 { mso-style-priority: 9; mso-style-qformat: yes; mso-style-link: “标题 2 Char”; mso-style-next: 正文; margin: 13pt 0; text-align: justify; text-justify: inter-ideograph; line-height: 173%; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 2; font-size: 16pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: 宋体; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; mso-font-kerning: 1.0pt }
h3 { mso-style-priority: 9; mso-style-qformat: yes; mso-style-link: “标题 3 Char”; mso-style-next: 正文; margin: 13pt 0; text-align: justify; text-justify: inter-ideograph; line-height: 173%; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 3; font-size: 16pt; font-family: Consolas; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
h4 { mso-style-priority: 9; mso-style-qformat: yes; mso-style-link: “标题 4 Char”; mso-style-next: 正文; margin: 14pt 0 14.5pt; text-align: justify; text-justify: inter-ideograph; line-height: 156%; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 4; font-size: 14pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; mso-font-kerning: 1.0pt }
pre { mso-style-noshow: yes; mso-style-priority: 99; mso-style-link: “HTML 预设格式 Char”; margin: 0 0 0.0001pt; mso-pagination: widow-orphan; font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体 }
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate { mso-style-noshow: yes; mso-style-priority: 99; mso-style-link: “批注框文本 Char”; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: none; font-size: 9pt; font-family: Consolas; mso-fareast-font-family: 宋体; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
{ mso-style-name: “标题 2 Char”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 2”; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 16.0pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; font-weight: bold }
{ mso-style-name: “标题 1 Char”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 1”; mso-ansi-font-size: 22.0pt; mso-bidi-font-size: 22.0pt; mso-font-kerning: 22.0pt; font-weight: bold }
span.Char { mso-style-name: “批注框文本 Char”; mso-style-noshow: yes; mso-style-priority: 99; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: 批注框文本; mso-ansi-font-size: 9.0pt; mso-bidi-font-size: 9.0pt }
{ mso-style-name: “标题 3 Char”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 3”; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 16.0pt; font-weight: bold }
span.HTMLChar { mso-style-name: “HTML 预设格式 Char”; mso-style-noshow: yes; mso-style-priority: 99; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “HTML 预设格式”; mso-bidi-font-size: 12.0pt; font-family: 宋体; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt }
{ mso-style-name: “标题 4 Char”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 4”; mso-ansi-font-size: 14.0pt; mso-bidi-font-size: 14.0pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; font-weight: bold }
.MsoChpDefault { mso-style-type: export-only; mso-default-props: yes; font-size: 12pt; mso-ansi-font-size: 12.0pt; font-family: Consolas; mso-ascii-font-family: Consolas; mso-fareast-font-family: 宋体; mso-hansi-font-family: Consolas; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi }
@page { mso-page-border-surround-header: no mso-page-border-surround-footer: no }
@page WordSection1 { size: 595.3pt 841.9pt margin-top: 72pt margin-right: 90pt margin-bottom: 72pt margin-left: 90pt mso-header-margin: 42.55pt mso-footer-margin: 49.6pt mso-paper-source: 0 layout-grid: 15.6pt }
div.WordSection1 { page: WordSection1 }