|
A Bit more about Disk Structures
You may already know that a computer works with zeros and ones. It can only discriminate 2 states: Something is on or something is off, something is either true or false etc.. The two states, 0 and 1 are referred to as Bits. By grouping several bits together the PC can 'grasp' more complex matters, like characters in our alphabet or decimal numbers. Eight zeros/ones 'grouped' together in one unit are referred to as a Byte. The byte is a very important 'unit'; values regarding memory or disk sizes are expressed in Kilo-Bytes, Mega-Bytes etc. Using 8 bits we can define 256 different combinations of zeros and ones (for example 00001111, 11110000 etc.). Rather than describing a state using a string of 8 zeros and ones, we like to be able to use a more compact notation: the Hexadecimal notation. Decimal notation we all know; we group numbers in units of
10 and we have 10
characters available for writing down values: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
If you understand the following calculations, you understand decimal notations:
If you do not understand this table, then either don't worry about it, or do some 'Googling' to find more information on the subject. Note: the most common way to denote a value as Hex is : 0xA1B1, where 0x defines the value A1B1 as being noted in Hex. Another well-known notation is 02h, where h denotes the value as 02 in Hex. Throughout this chapter both notations are used. Certain standards and agreements exist about what a particular order of bytes represents. For example the ASCII standard allows us to represent characters in our alphabet by a specific sequences of bits. When software reads information from the hard disk, it therefore needs to know if it should interpret a given sequence of bytes as values to be used in calculations, or as ASCII characters (a text string). In the end, all information on your hard disk can be displayed as an apparent chaos: Your MP3 files, your drawings, in the end it's noting else but a bunch of zeros and ones. Sectors A hard disk is capable of storing billions of bytes, so to address an individual byte (to know where something is stored), huge numbers would be required. To simplify addressing and finding information on a hard disk, bytes are grouped into units called 'sectors'. A sector is a group of 512 Bytes. We start counting sectors from zero, so in order to read what's in the 513th byte on a disk, we would need to address sector 1. Even if we're only interested in the value of one particular byte, we need to read an entire sector into memory. A sector is the smallest addressable unit on a disk (you can read more than one sector at the time, but you can't read less than one sector). As mentioned before, a byte may represent a value, or for example an ASCII character. In the ByteBack D.R.I.S.TM disk editor main window three columns are shown. The first column shows the sequencenumber of the bytes in the sector (also known as the offset), the second column displays the values (in hexadecimal notation) of the individual bytes, and in the 3rd column this same information is shown, however now interpreted by using the ASCII table. All the information on a harddisk is organized in some way, which is defined by one (or more) of hundreds of protocols, specifications, conventions or standards that different organizations or software and operating system manufacturers have come up with over the years. And much of the information isn't defined by any of those and may only have meaning to specific software or operating systems, for example executable code or proprietary file formats.
There is one important convention you need to be aware of when editing raw
sectors; Intel Byte ordering (little endian): whenever a value exceeds 255 (and
thus more than one byte is required to store the value), bytes are stored in reverse
order! So if we would need to store a decimal number > 255, we'd first
convert it to hex, and then write the bytes to the disk in reverse order. So the
decimal value of 41393, which equals A1B1 in hex is written to the disk as B1A1 (which is
how the bytes will appear in a disk editor as well).
A long time ago, in a galaxy far, far away, sectors were addressed using the cylinder-head-sector notation, or 'CHS addressing' for short. This manual will not get into details, but try to visualize a hard disk being several platters on a spindle. Disk read/write heads float above the platter surface, one above and one below each platter. The individual platters are divided into tracks and the tracks are divided into sectors. The outer tracks form one cylinder, all next tracks form the next cylinder etc.. By describing a specific cylinder, head and sector, one specific sector can be addressed.
Modern operating systems and software no longer use CHS addressing. As a
result of the limitations of several standards and specifications (the Int13h
and IDE specifications) disks larger than approximately 8 Gb could not be addressed
beyond the first 8 Gb. So when using CHS addressing on a 12 Gb hard disk, only the
first 8 Gb could be addressed and used. Although CHS addressing is now obsolete, the partition table
specification (see below) still reserves room for cylinder, head and sector
values and partitions tend to start and end at cylinder boundaries. For ByteBack D.R.I.S.TM to be able to calculate the cylinder boundaries, it needs the correct disk geometry (heads per cylinder and sectors per track) information. ByteBack D.R.I.S.TM requires the disk to be configured (in the BIOS) using the same geometry information that was used at the time the disk was partitioned. If the geometry settings can not be adjusted by using the BIOS you need to make ByteBack D.R.I.S.TM aware of the disk geometry, as it was at the time that the partitions were created.
Specifications Entry
1, starts at offset 446 (01BE in Hex) Note: in Windows 2000/2003/XP only basic disks make use of the partition table. Dynamic disks use the LDM database (located at the end of the disk) for disk configuration information; the partition table is not updated when volumes are deleted or extended after a dynamic disk upgrade, or when new dynamic volumes are created. On a dynamic disk only the first entry of the 'legacy' partition table is used: it describes a type 42 partition occupying the entire disk (the entire disk minus 1 cylinder to be exact). One
Partition Table entry (the first of the four) up close and personal :
The example below is taken from a MBR. The entire underlined area (64 bytes in size) is reserved for defining partitions. Each partition table sector ends with a 55 AA signature! If this signature is missing, the operating system or disk partitioning tools will regard the partition table to be absent.
The 'blue' bytes (in the example "0B"
and "0F") describe the
partition types, in this example a FAT32 partition (0B) and an extended
partition (0F). Only one extended partition can be defined in the MBR. An extended
partition allocates an area in which logical partitions are located. The
first sector of the extended partition contains a partition table that
defines the first logical partition (in entry 1) and, if multiple logical
partitions are present, a pointer to the next partition table (in entry 2).
This first sector of the extended partition is called the EPBR (Extended
Partition Boot Record).
In
the first entry a "0B" type partition is defined. The LBA
Relative offset is relative to the partition table it is defined in. The
"05" type entry is the pointer to the next partition table, the
LBA offset is relative to the start of the extended partition.
Like all partition table sectors, the last 2 bytes of the sector contain
the 55 AA signature.
Legend:
= Partition Table sector (the MBR or EPBR) /
= the extended region that contains the logical partitions. Partition Table Sector 1 describes:
- The primary FAT32 partition The first sector of the extended partition 2 contains a Partition Table Sector. It defines:
- The logical NTFS partition Partition Table Sector 3 describes:
- the logical FAT32 partition Partition Table Sector 4 describes: - the logical FAT partition end there the chain ends.
Partition tables form a 'chain'. If the chain is broken at
some point, all logical partitions defined later in the chain past the
'breakpoint' can not be accessed. The boot sector in the FAT partition The general layout for a FAT partition is as follows:
The central structure in the FAT file system is the File Allocation Table (FAT). The FAT's position and size can be determined from (are defined by) the boot sector. The data area is divided into clusters. A cluster consists of one or more sectors. For each cluster an entry is kept in the FAT. A cluster can be free, occupied or bad. The startlocation of a file or folder is defined in a directory entry. The directory entry for a file/folder contains a filename, attributes (hidden, archive etc.), the start cluster (n) and the size of the file. To access a file, cluster (n) will be looked up in the FAT. If the file size > 1 cluster, the value in the FAT entry points to the next cluster that was allocated to this file. Locations of the FAT and the data area are described in the boot sector. Values as they are described in the boot sector are relative to the start of the partition. For example, the position of the first FAT can be derived from the value for 'Reserved Sectors'. Then, once the sectors per FAT and the number of FATs was determined, the start of the Root area follows as: Reserved Sectors + 2*(Sectors Per FAT). FAT Boot Sector layout: The data contained in the boot sector after the OEM name string is referred to as the BIOS parameter block or BPB
The Extended BIOS parameter block
The boot sector in the FAT32 partition
The central structure in the FAT32 file system is the File Allocation Table (FAT). The FAT's position and size can be determined from (are defined by) the boot sector. The data area is divided into clusters. A cluster consists of one or more sectors. For each cluster an entry is kept in the FAT. A cluster can be free, occupied or bad. A FAT entry in the FAT32 file system allows for 32 bits (although currently only 28 bits are used). The startlocation of a file or folder is defined in a directory entry. The directory entry for a file/folder contains a filename, attributes (hidden, archive etc.), the start cluster (n) and the size of the file. To access a file, cluster (n) will be looked up in the FAT. If the file size > 1 cluster, the value in the FAT entry points to the next cluster that was allocated to this file. Locations of the FAT and the data area are described in the boot sector. Values as they are described in the boot sector are relative to the start of the partition. For example, the position of the first FAT can be derived from the value for 'Reserved Sectors'. Then, once the sectors per FAT and the number of FATs was determined, the start of the Data area follows as: Reserved Sectors + 2*(Sectors Per FAT). FAT32 Boot Sector layout: The data contained in the boot sector after the OEM name string is referred to as the BIOS parameter block or BPB
The boot sector in the NTFS partition
The central administrative structure in NTFS is the Master File Table (MFT). The NTFS partition is divided into clusters (the entire partition!) and clusters consist of one or more sectors. Cluster sizes can be read from the boot sector. Everything in the NTFS file system is a file, even for example the boot sector ($Boot). All files are described in the MFT, even the the '$MFT' itself. One or more MFT entries or File record Segments can be assigned to a file. An MFT entry typically describes the filename and the clusters assigned to the file. Assigned clusters are defined in so called 'run-lists': rather than describing each cluster individually, a start cluster value and a number of clusters value is described. For fragmented files multiple run lists are maintained. NTFS Boot Sector
layout:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||