USB File System

 

USB File System

Data in USB could be divided into 5 parts according to different features and functions: MBR area, DBR area, FAT area, FDT area and DATA area.
Main boot record (MBR)
 
Absolute sector number is: MBR_LBA = 0x00000000 is that the master boot record, equivalent to the hard drive is located in cylinder 0 track 0, sector 1.
In a total of 512 bytes of main boot sector, MBR which only takes up 446 bytes (ofs: 0 - ofs: 1BDH),
Another 64-byte (ofs: 1BEH - ofs: 1FDH) to the DPT (Disk Partition Table disk partition table),
The last two bytes "55 AA" (ofs: 1FEH - ofs: 1FFH) mark the end of the partition.
MBR is defined as follows:
typedef struct {
uchar bootcode[446];
PartitionTable PT [4];
uint EndingFlag;
}MBR_tag;
 
 
Bootcode [446] boot code are generally fixed for guiding x86, not control.
Define the partition table is as follows:
typedef struct {
uchar BootFlag; / / start flag
CHS StartCHS; / / partition begins cylinder, head, sector
uchar SystemID; / / partition type
CHS EndCHS; / / partition end of the cylinder, head, sector
ulong RelativeSectors; / / partition starting sector number, refers to the partition with respect to the recording of the partition of a partitioned table fan
Difference between the position of the area (the partition table: LBA = 0x0).
ulong TotalSectors;//Total number of sectors partition
}PartitionTable;
Where CHS is a cylinder, head, sector structure, is defined as follows:
struct CHS {
uchar Head; //head
unsigned Sector : 6; //sector
unsigned CyH2: 2; / / cylinder (high two).
uchar CyL8; / / cylinder (low eight). 
ulong Cylinder () {return (uint (CyH2) * 256 + CyL8);} / / returns the column nominal value
void SetCylinder (uint Cylinder) / / Set column nominal value {
CyH2 = (Cylinder >> 8) &0x3; CyL8 = (Cylinder & 0xff);
}
};
Example: 80 01 01 00 0B FC FE BF 3f 00 00 00 7 86 00 BB
Here we can see:
z "80" is activated sign a partition, which means that the system can boot;
z "01 01 00" indicates the partition start head No. 01, Sector No. 01 beginning, the beginning of the cylinder number is 00;
z "0B" means the system type of partition is FAT32, other more commonly used 04 (FAT16), 06 (bigFAT16),
01 (FAT12), 07 (NTFS);
z "FE BF FC" indicates the end of the partition head number is 254, the partition end sector number is 63, the end of the cylindrical partition
No. 764;
z "3F 00 00 00" indicates the relative sector number of the first sector 63;
z "7E 86 BB 00" represents the total number of sectors is 12289622.
System Boot Record (DBR)
 
Absolute sector number is: DBR_LBA = MBR.PT [0] RelativeSectors is that DBR, equivalent hard disk 0 track 1 is located.
Cylinder 1 sector (512 bytes), was the first sector of the operating system can be accessed directly, which includes a boot program and a
One is called BPB (Bios Parameter Block) of the partition table parameter records. The main task of the program is when the MBR boot
When the system control to it, to determine the first two files with the directory partition is not the operating system boot files (in DOS
For example, that is Io.sys and Msdos.sys). If it is determined exist, put it into memory and transfers control to the text
Pieces. BPB parameter block records the starting sector of the partition end sector, file storage format, hard disk media descriptor, root
Important parameters directory size, number of FAT, allocation unit size.
 DBR defined as follows:
typedef struct {
uchar bJmpBoot[3];
char bOEMName[8];
uint BPB_wBytesPerSec;
uchar BPB_bSecPerClus;
uint BPB_wReservedSec;
uchar BPB_bNumFATs;
uint BPB_wRootEntry;
uint BPB_wTotalSec;
uchar BPB_bMedia;
uint BPB_wSecPerFAT;
uint BPB_wSecPerTrk;
uint BPB_wHeads;
ulong BPB_dHiddSec;
ulong BPB_dBigTotalSec;
uchar bDrvNum;
uchar bReserved1;
uchar bBootSig;
uchar bVolID[4];
char bVolLab[11];
char FileSysType[8];
/ / Ofs: 0 typical as:. 0xEB, 0x3E, 0x90.
/ / Ofs: 3 typical as:. "MSWIN4.1".
. Bytes per sector 11: / / ofs.
/ / Ofs:. 13 the number of sectors per cluster.
/ / Ofs:. 14 reserved sectors, the number of sectors from the DBR to the FAT.
/ / Ofs: 16.FAT number.
/ / Ofs:. 17 the number of root directory entries.
/ / Ofs:. 19 partitions of the total number of sectors (<32M when used).
/ / Ofs:. 21 identifies the partition media, USB flash drives for general use 0xF8.
/ / Ofs:. 22 the number of sectors per FAT share.
/ / Ofs:. 24 sectors per track.
/ / Ofs:. 26 the number of heads.
/ / Ofs:. 28 hidden sectors, from MBR to DBR number of sectors.
/ / Ofs:. 32 partitions of the total number of sectors (> = 32M when used).
/ / Ofs:. 36 floppy disks using 0x00, hard disk using 0x80.
/ / Ofs:. 37 reserved.
/ / Ofs:. 38 extended boot mark: 0x29.
/ / Ofs:. 39 disk serial number.
//ofs:43."Msdos
/ / Ofs: 54. "FAT16
 
uchar ExecutableCode [448]; / / ofs: 62 boot code.
uint EndingFlag;
}DBR_tag;
/ / Ofs: 510 end logo:. 0xAA55.

 
//ofs:43."Msdos
//ofs:54."FAT16
 
uchar ExecutableCode [448]; / / ofs: 62 boot code.
uint EndingFlag;
}DBR_tag;
/ / Ofs: 510 end logo:. 0xAA55.

 

 

 
Domain name: www.mrtlab.com | | Telephone: +86-27-82621261 | Terms of use
MRT data recovery website,provides professional HDD firmware repair and data recovery technical resources!
Copyright 2003-2019 Powered By MrtLab