Archive for 9月 14th, 2008

IDE硬盘分区资料

星期日, 9月 14th, 2008

以下硬盘均指IDE硬盘。

硬盘中内容保存在一个个扇区之中,硬盘逻辑结构是C-H-S模式,所有的扇区通过这样一个三维的数据来定位。

在硬盘0柱面0磁道的第1扇区中保存着MBR(Main Boor Record)主启动记录和主分区信息,它们的位置关系:

MainBootRecord: 0×0000~0×01BD 446B

· Partition 1 0×01BE (446) 16B

· Partition 2 0×01CE (462) 16B

· Partition 3 0×01DE (478) 16B

· Partition 4 0×01EE (494) 16B

End Word 0×01FE (510) 2B (数值为55 AA)

可以看出,分区表中每一项都占十六个Bytes,其中的意义如下:

分区表项的内容描述:

Byte Offset

Field Length

Sample Value

Meaning

00 BYTE 0×80 Boot Indicator. Indicates whether the partition is the system partition. Legal values are:
00 = Do not use for booting.
80 = System partition.
0
01 BYTE 0×01 Starting Head.
02 6 bits 0×01 Starting Sector. Only bits 0-5 are used. Bits 6-7 are the upper two bits for the Starting Cylinder field.
03 10 bits 0×00 Starting Cylinder. This field contains the lower 8 bits of the cylinder value. Starting cylinder is thus a 10-bit number, with a maximum value of 1023.
04 BYTE 0×06 System ID. 1
05 BYTE 0×0F Ending Head.
06 6 bits 0×3F Ending Sector. Only bits 0-5 are used. Bits 6-7 are the upper two bits for the Ending Cylinder field.
07 10 bits 0×196 Ending Cylinder. This field contains the lower 8 bits of the cylinder value. Ending cylinder is thus a 10-bit number, with a maximum value of 1023.
08 DWORD 3F 00 00 00 Relative Sector.2
12 DWORD 51 42 06 00 Total Sectors. 3

0X86机器上只有一个分区项可以置为Active(0×80),其余都是InActive(0×00)

1System ID Field分区系统描述符,此项多为形形式式的操作系统所定义其专用之分区,一个不完全的统计表如下:

Operating System Indicators

0×00

Empty partition-table entry

0×01

DOS FAT12

0×02

XENIX  /root file system

0×03

XENIX  /usr file system

0×04

DOS FAT16 (up to 32 MB)

0×05

DOS 3.3+ extended partition

0×06

DOS 3.31+ FAT16 (over 32 MB)

0×07

OS/2 HPFS, Windows NT NTFS, Advanced Unix

0×08

OS/2 v1.0-1.3, AIX bootable partition, SplitDrive

0×09

AIX data partition

0×0A

OS/2 Boot Manager

0×0B

Windows 95+ FAT32

0×0C

Windows 95+ FAT32 (using LBA-mode INT 13 extensions)

0×0E

DOS FAT16 (over 32 MB, using INT 13 extensions)

0×0F

Extended partition (using INT 13 extensions)

0×11

Hidden FAT-12

0×12

COMPAQ configuration partition

0×14

Hidden FAT-16 (up to 32MB)

0×16

Hidden FAT-16, ‘BigDOS’ (over 32MB)

0×17

Hidden NTFS partition

0×18

AST Windows swapfile

0×1B

Hidden Windows 95 FAT32 partition

0×1C

Hidden Windows 95 FAT32 partition (using LBA-mode INT 13 extensions)

0×1E

Hidden LBA VFAT partition

0×24

NEC DOS 3.x

0×35

OS/2 JFS

0×38

THEOS ver.3 2gb partition

0×39

Plan 9; THEOS V4 spanned partition

0×3A

THEOS V4 4gb partition

0×3B

THEOS V4 extended partition

0×3C

PartitionMagic recovery partition

0×3D

Hidden Novell Netware

0×40

Venix 286

0×41

Linux/Minix (sharing disk with DRDOS); Power PC Reference platform boot; Personal RISC boot

0×42

LINUX swap (sharing disk with DRDOS); Secure File System

0×43

LINUX native (sharing disk with DRDOS)

0×45

Boot-US Boot Manager; Priam

0×4C

Oberon

0×4D

QNX 4.2 Primary

0×4E

QNX 4.2 Secondary

0×4F

QNX 4.2 Tertiary; Oberon

0×50

OnTrack Disk Manager; Lynx RTOS; Oberon, read-only partition

0×51

OnTrack Disk Manager; Novell Netware

0×52

CP/M; Microport SysV/AT

0×53

Disk Manager 6.0

0×54

Disk Manager 6.0 Dynamic Drive Overlay

0×55

EZ-Drive

0×56

Golden Bow VFeature

0×57

DrivePro

0×5C

Priam EDisk

0×61

SpeedStor

0×63

UNIX System V (SCO, ISC Unix, UnixWare, …); Mach; GNU Hurd

0×64

PC-ARMOUR; Novell Netware 2.xx

0×65

Novell Netware 3.xx or 4.xx

0×66

Novell Netware

0×67

Novell Netware

0×68

Novell Netware

0×69

Novell Netware

0×70

DiskSecure Multi-Boot

0×74

Scramdisk

0×75

PC/IX

0×78

XOSL multiboot loader

0×80

Minix 1.1 … 1.4a

0×81

Linux partition

0×82

Linux Swap partition, Solaris (Unix)

0×83

Linux native file system (ext2fs/xiafs)

0×84

OS/2 hidden partition; hibernation partition

0×85

Linux EXT

0×86

FAT16 volume/stripe set (Windows NT)

0×87

HPFS fault-tolerant mirrored partition, NTFS volume/stripe set

0×8B

NT FAT-32 (up to 2048GB) volume set

0×8C

NT FAT-32 (up to 2048GB) LBA volume set

0×8E

Linux Logical Volume Manager partition

0×93

Amoeba file system; hidden Linux file system

0×94

Amoeba bad block table

0×9F

BSD/OS

0xA0

Hibernation partition

0xA1

Hibernation partition

0xA5

BSD/386; FreeBSD/NetBSD/386BSD

0xA6

OpenBSD

0xA7

NextStep

0xA9

NetBSD

0xAA

Olivetti FAT-12 service partition

0xB7

BSDI BSD/386 file system

0xB8

BSDI BSD/386 swap

0xBE

Solaris boot partition

0xC0

DR-DOS/Novell DOS secured partition

0xC1

DRDOS/secured (FAT-12)

0xC6

Corrupted FAT16 volume/stripe set (Windows NT)

0xC7

Corrupted NTFS volume/stripe set

0xD8

CP/M-86

0xDB

CP/M; Concurrent CP/M; Concurrent DOS; CTOS

0xDF

BootIt

0xE1

SpeedStor FAT-12 extended

0xE3

SpeedStor

0xE4

SpeedStor FAT-16 extended

0xEB

BeOS

0xF1

SpeedStor

0xF2

DOS 3.3+ secondary partition

0xF4

SpeedStor large partition

0xFB

VMWare file system

0xFC

VMWare swap

0xFD

Linux RAID

0xFE

PS/2 IML partition; SpeedStor; LANstep

0xFF

BBT (Bad Blocks Table)

其中,0×00意味着空表项,0xFF是坏区表;

而对于表中红色的两项,0×050×0F,指向一个扩展的分区表,这是由于主分区表只有四项,无法满足需要>4的分区数的需要。

其余的分区项系统指示符,均指向一个实际存在的分区。

2:相对扇区数

16位的数字,高位在右。

假如系统指示符并不是0×00,也并非扩展分区表的0×050×0F,那么这个相对扇区数relative_sectors就是指此分区位于从此分区表的位置经过relative_sectors个扇区后的位置。

公式:

current_table_location + relative_sectors = partition_location

而假如该系统指示符是0×05或者0×0Frelative_sectors则是从硬盘中的第一个扩展分区表的位置到此分区表项所指的扩展分区表的距离扇区数。

公式:

first_extended_table_location + relative_sectors = extended_table_location

而如果这个分区项是主分区表中的扩展分区项,那么所指就是第一个扩展分区表:

0 + relative_sectors = first_extended_table_location

(MPT位置为0,根据LBA计算公式,0柱面0磁道1扇区的LBA号为0)

3Total Sectors

16位的数字,高位在右。

在确定的分区表项中,这指的是此逻辑分区中的扇区的总数目。

0×050×0F指示的扩展分区表项中,若为主分区表中的扩展分区表项,所指就是第一个扩展分区表以后的所有扇区数,若为其它的扩展分区表项,所指是当前扩展分区表到所指扩展分区表所经过的扇区数。

扩展分区表:

扩展分区表所在的扇区与主分区表所在扇区(0号扇区)结构比较:

主分区表

扩展分区表

0×0000 –0×01BD

MBR code

无意义字节,一般全为0

0×01BE–0×01FD

分区表项

分区表项,一般最多有两项:逻辑分区和扩展分区

0×01FE–0×01FF

55 AA

55 AA

硬盘中的分区表和分区结构示意图:

主分区

主分区表

主分区项

扩展分区项(指向扩展分区表1)

主分区所在

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

扩展分区表1

逻辑分区项

扩展分区项(指向扩展分区表2)

逻辑分区1

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

扩展分区表2

逻辑分区项

扩展分区项(指向扩展分区表3)

逻辑分区2

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

扩展分区表3

逻辑分区项

扩展分区项(NULL)

逻辑分区3

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

……