@echo off rem FAT32 HARD DISK rem =============== rem Hard Disk Structures: Backup and Repair rem ======================================= rem Routines to Save & Restore - rem rem 1. Track 0: MBR sector (BPB, IPL & Partition Table) rem 2. Primary Partition: Boot sector, FS Info sector, FAT 1 & 2, Root Directory rem 3. Extended Partition: EMBR (Partition Table) rem 4. Logical Partitions: Boot sector, FS Info sector, FAT 1 & 2, Root Directory rem rem This set of Data Recovery routines is for a FAT32 WinME system rem booted from a WinME Emergency Boot Disk, but should also work rem for a Win98SE system booted from a Win98SE Boot Disk rem *** Set Path *** SET DOSpath=%path% PATH ; SET PATH=F:\SAVED\RECOVERY;F:\SAVED\RECOVERY\DOS\COMMAND SET PATH=%path%;F:\SAVED\RECOVERY\DOS\UTILS;F:\SAVED\RECOVERY\DOS\HDD_FIX rem *** Disk Cache for MS-DOS Mode *** rem * To make the routines run faster * SMARTDRV 8192 16>nul rem * Alternate file locations * :: C:\WINDOWS\SMARTDRV.EXE 8192 16>nul :: F:\SAVED\RECOVERY\CONFIG\SMARTDRV.EXE 8192 16>nul rem *** To backup the Rescue Utils *** :: XXCOPY "F:\SAVED\RECOVERY\" "E:\SAVED\RECOVERY\" /H/KS/E/TTA0/TCA/TCC/TCW/ZE :: // :: rem -------------------------- rem SECTION A: DISK STRUCTURES rem -------------------------- rem DISK STRUCTURE NOTES rem ==================== rem FAT32 rem ===== rem rem The FAT32 file system is a method for storing files on the rem magnetic hard disk in a computer. The disk may contain a rem single partition, or may be divided into several partitions. rem rem A partition larger than 8GB *must* use the FAT32 file system, rem in order to provide enough addresses for file storeage on that rem partition; and a partition smaller than that *may* use it. rem rem FAT32 uses 32 bits for each entry in the File Allocation Table rem (i.e. 4 bytes, as there are 8 bits in a byte: 4 x 8 = 32), so rem providing more addresses than FAT16 (which uses only 16 bits). rem rem NB: In some disk utility programs, FAT32 is called "BigFAT" rem and FAT16 is called "FAT". rem rem NB: The notes in this file are for the FAT32 file system only, rem on a computer running Windows ME or Windows 98/98SE. rem rem Those Windows versions can not access an NTFS partition. rem rem This section does NOT describe a system that dual-boots rem (shares a partition with more than one Operating System), rem nor does it describe a disk that is larger than 127.53GB. rem CHS ADDRESSING rem ============== rem rem CHS = Cylinder : Head : Sector rem rem Each sector (consisting of 512 bytes) has a CHS address. rem rem A FAT32 disk starts at Cylinder 0, Head 0, Sector 1 rem (CHS 0-0-1), and is typically structured as follows - rem rem Sector : There are 63 sectors per head rem (counted from 1 to 63) rem rem Head : There are 255 heads per cylinder rem (counted from 0 to 254) rem rem Cylinder : The maximum number of Cylinders is 1024 rem (counted from 0 to 1023; i.e. 1023 is rem the largest value in a Partition Table) rem rem NB: The maximum number will be *less* than rem 1023 if the disk is smaller than 8GB rem rem NB: If the disk is larger than 8GB, the rem number 1024 is used: meaning use LBA rem values (sectors only) instead of CHS rem rem Where the disk is larger than 8GB, Logical Block Addressing rem (LBA) is used for all critical disk functions instead of CHS, rem but some key disk structures nonetheless contain CHS values rem LOGICAL BLOCK ADDRESSING (LBA) rem ============================== rem rem An LBA sector is the same as a CHS sector: a 512 byte block rem of data. rem rem CHS cannot provide sufficient addresses for a disk exceeding rem 8GB, so LBA addressing must be used instead. LBA uses sectors rem only, treating the disk as a single unbroken chain of them. rem rem NB: LBA is an *alternative* to C-H-S addressing, giving only rem a sector number (instead of the traditional three numbers: rem Cylinder, Head and Sector). rem rem NB: In LBA the sectors begin with sector 0, whereas CHS values rem begin with sector 1; thus their sector numbering is always rem out-of-step with each other by 1. rem rem rem Formula to convert a CHS value into an LBA value: rem rem (Cylinders x Heads per Cylinder x Sectors per Head) rem + (Heads x Sectors per Head) + (Sectors - 1) rem rem This formula, in practice, is usually: rem rem (Cylinders x 255 x 63) + (Heads x 63) + (Sectors - 1) rem rem This formula is only of use if the disk is smaller than 8GB; rem a larger disk will have artificial (i.e. maximum) CHS values. rem rem This formula can, nevertheless, calculate the number of sectors rem on a disk from the CHS information printed on the disk's casing rem (since the disk label does not observe the rule that Cylinder rem values cannot exceed 1023, because this form of labelling is a rem convenient way to record the disk's "geometry" - see below). rem rem rem Convert using PT Calc: rem rem The program PTCALC.EXE (and PT Calc for Windows) can translate rem CHS values to LBA, and vice versa ("PARTITION TABLE EDITOR", below). rem rem rem Sanity Check of Partition Table: rem rem In the MBR Partition Table, the starting sector and ending sector rem of each partition is described by a CHS value. These should agree rem with the LBA values for "start sector" and "number of sectors", rem even though those LBA values are enough to define the partition. rem rem NB: If the partition ends beyond the 8GB boundary, the CHS value rem for the ending sector will be merely the maximum permitted rem (typically 1024-254-63). A Cylinder value of 1024 is a special rem value, indicating that LBA values are in use instead of CHS. rem rem The LBA start sector is stored directly in the Partition Table. rem To calculate the LBA end sector: add "start sector" to "number rem of sectors", then subtract 1. rem DISK GEOMETRY rem ============= rem rem The Disk Geometry will usually be 255 Heads per cylinder and rem 63 Sectors per head (255 x 63 = 16,065 sectors per Cylinder); rem but don't just assume that, as other values are sometimes used. rem rem NB: Disk Geometry (the number of Cylinders - Heads - Sectors) rem can be read from the BIOS. It is also printed on a label rem on the Hard Disk's casing. rem rem To enter the BIOS, press the appropriate key (e.g. DEL) rem (or, on some systems, F1 or F2) repeatedly at startup. rem rem A sector is a real disk structure: a block of 512 bytes. But the rem terms 'Head' and 'Cylinder' are now mere conventionalisations; rem they are no longer related to the actual engineering structures. rem rem In a disk larger than 8GB all CHS values are unreal: CHS cannot rem address a disk larger than 8GB. But CHS values must be used in rem key disk structures, to ensure compatibility with the BIOS. So rem the CHS values used are typically the largest allowable values, rem i.e. 1023-254-63 or 1024-254-63 (or sometimes 512-254-63). rem rem NB: The CHS values are in what is known as "L-CHS" format, rem as they are CHS values that have been modified by LBA. rem rem The disk manufacturer will still typically label the disk with rem CHS values, but the values given are unreal. An 80GB hard disk rem will typically be labelled CHS 9729-254-63, but it does not have rem 9,729 cylinders within it, nor can a CHS value greater than 1024 rem be used in the disk's Partition Tables: that CHS value is merely rem a literal translation of the number of sectors on the disk. rem rem CHS values remain important because key BIOS functions are based rem on the Disk Geometry, by which is meant the CHS values: the rem number of Cylinders, Heads per cylinder, and Sectors per head. rem rem NB: The CHS value printed on the disk's casing, although unreal, rem is a convenient means of telling the user the Head and Sector rem values, which remain important (even though the figure given rem for the number of Cylinders is irrelevent, except for the key rem fact that the value *exceeds* 1,023). rem rem If you are unsure what the correct disk geometry is, try using the rem following values in the Partition Table, as one of these values is rem likely to be the correct one: rem rem (a) Sectors per Head: The most likely value is 63 (as almost all rem hard disks base their CHS values on this traditional number) rem rem (b) Heads per Cylinder: Try 255, 16, 32, 64, 128 and 240 rem (in that order). rem rem NB: The number FF in Hexadecimal (base 16) represents rem 255 in Decimal (base 10); thus 255 is the maximum rem decimal number that a 2-byte hex value can store. rem rem (Being the maximum value possible, 255 is the value rem most likely to be the correct one on a normal disk) rem rem The equivalent LBA sector number will be 1 less than rem the actual number (as LBA numbers start from 0 rather rem than 1). So the maximum LBA value in a Partition Table rem entry is 254 (i.e. 255 - 1 = 254). rem rem NB: Computers use Binary storage, so *any* factor of two rem that can be stored in a 2-byte hex value can be valid rem (i.e. 4, 8, 16, 32, 64, or 128). rem DISK SIZE rem ========= rem rem Disk Size in Megabytes - rem rem To calculate the size of a hard disk from its C-H-S values: rem rem (Cylinders x Heads per Cylinder x Sectors per Head) rem / 2,048 = MegaBytes rem rem To calculate the size of a disk from its LBA value: rem rem (LBA Sectors + 1) / 2,048 = MegaBytes rem rem rem Notes: rem rem 1. The LBA figure will be slightly greater, as the LBA calculation rem gives the true number of sectors on the disk. The CHS calculation rem only counts the number of sectors included in all the partitions; rem a few sectors are left unused, as partitioning rules demand that a rem partition MUST end on a Cylinder boundary (1 Cyl = 16,065 sectors). rem rem 2. To calculate the size of a Partition from its CHKDSK.EXE value: rem rem Kilobytes / 1,024 = MegaBytes rem rem NB: Even if the hard disk has only a *single* partition, rem this is NOT the size of the disk. It doesn't include rem the System Area (Track 0, Boot Sector, FAT x2, etc). rem rem 3. To convert from MegaBytes to Bytes: rem rem 1 MB = 512 x 2,048 (i.e. 2,048 sectors) = 1,048,576 bytes rem rem MegaBytes x 1,048,576 = Bytes rem Bytes / 1,048,576 = MegaBytes rem rem rem Disk Size limitations - rem rem In Windows 95 and 98, because the versions of SCANDISK and DEFRAG rem included with the Operating System are 16-bit applications, the FAT rem structure is unable to exceed approximately 4.2 million clusters, rem imposing a partition size limit of 127.53 GB. rem rem NB: ScanDisk for Win98 is a 16-bit program. Such programs have a rem memory block maximum allocation size of 64 KB less than 16 MB, rem so cannot process a FAT32 partition if the FAT is larger than rem 16 MB less 64 KB. As the File Allocation Table in FAT32 uses rem 4 bytes, ScanDisk cannot process a FAT that defines more than rem 4,177,920 clusters (including the two reserved clusters). So, rem including the FATs themselves, this works out at maximums of rem 32KB per cluster and 127.53 GB per partition. rem rem NB: The versions of SCANDISK and DEFRAG in Windows ME do NOT have this rem limitation (and can be used with Windows 98/98SE also). As true rem 32-bit applications, they function on a partition of up to 512 GB. rem rem Windows 9x and Windows ME do not support 48-bit LBA, so the maximum rem possible size of a partition is 127.53 GB (i.e. the largest partition rem size that's possible using 28-bit LBA). rem rem NB: The WinME driver ESDI_506.PDR (which Windows uses for 32-bit drive rem access) uses 28-bit LBA, so cannot access a partition larger than rem 127.53 GB. rem rem A disk exceeding 127.53 GB can be partitioned as several partitions, rem each *smaller* than 127.53 GB; then Win98/ME can access each. rem rem NB: But *only* if the BIOS can recognise a disk exceeding 137 GB. If rem the motherboard, i.e. the motherboard's ROM-BIOS chip, does not rem support 48-bit LBA, it can't recognise a disk exceeding 137 GB! rem rem An IDE or SATA disk can be attached to a PCI controller card that rem supports 48-bit LBA. This enables a disk larger than 137 GB to be rem present, even where the motherboard BIOS uses 28-bit LBA. rem CLUSTER SIZE rem ============ rem rem On a FAT32 partition, the default cluster size is: rem rem Partition size Cluster size rem -------------- ------------ rem 0 to 8 GB 4K rem 8 to 16 GB 8K rem 16 to 32 GB 16K rem Over 32 GB 32K rem rem 1 sector is 0.5K, so if a partition has a cluster size of 16K rem each cluster contains 32 sectors; but if cluster size is 32K, rem then each cluster contains 64 sectors. rem rem NB: These are the *default* values; but the user can override rem them in the initial partitioning and formatting of the disk. rem These values are thus only a guide, and will NOT be correct rem in all cases. rem rem The *maximum* number of Clusters in a partition: rem rem ( (No. of Sectors in Partition) - (No. of Sectors per FAT x 2) - rem (No. of Reserved Sectors) ) / (No. of Sectors per Cluster) rem rem If there is any remainder in the result from that formula, it just rem means there are a few unused sectors at the end of the partition rem (usually not enough to make another cluster). rem rem NB: The number of clusters can tell you the type of FAT in use, as rem a FAT16 partition cannot exceed 65,517 clusters. If the number rem of clusters is greater than 65,518 the partition is using FAT32. rem (Note: FAT16 has a maximum cluster size of 32K [32,768 bytes]) rem rem NB: The ONLY method used by WinME to determin a partition's FAT type rem is the value stored in the MBR for the total number of Clusters! rem rem It does NOT use the size of the partition. Cluster size, which rem is user-selectable, determines the number of clusters on disk, rem and thus the FAT type; so partition size is an unsafe guide! rem rem It does NOT use the ID string in the partition's Boot Sector, rem e.g. "FAT16" or "FAT32", which has no significance whatever. rem rem NB: The number of Clusters in a partition can be ascertained by rem running CHKDSK.EXE which reports: rem (a) The total number of clusters in the partition rem (describing them as "allocation units"), and rem (b) The number of bytes in each cluster. rem rem *** Run CHKDSK.EXE *** :: CHKDSK C: > F:\SAVED\CHKDSK_C.txt :: CHKDSK D: > F:\SAVED\CHKDSK_D.txt :: CHKDSK E: > F:\SAVED\CHKDSK_E.txt rem rem rem Minimum number of Clusters: rem rem A FAT32 partition MUST contain at least 65,527 clusters (because if it rem contains fewer, Windows will treat the partition as FAT16). Therefore rem the maximum cluster size possible is 32KB; a larger cluster size rem (i.e. 64KB) would make it possible to have less than 65,527 clusters. rem rem rem Maximum number of Clusters: rem rem FAT32 permits the maximum number of Clusters to be several million, rem by using 32-bit values in the File Allocation Table to store the rem cluster addresses. However, the maximum number of addresses is only rem 0FFFFFFF hex (a 28-bit value), not the full 32-bit value FFFFFFFF hex. rem rem This is to enable programs that manipulate the File Allocation Table rem to use four bits as tags in their internal data structures; but it rem has NO impact on the theoretical maximum FAT32 volume size, as that is rem capped by the FFFFFFFF (hex) maximum sector count: which, at 512 bytes rem per sector, results in a theoretical maximum volume size of 2 TeraBytes. rem rem rem Cluster No.2 - rem rem The "Data Area" starts with cluster number 2, not cluster zero, rem because there are two "reserved clusters" (numbers 0 and 1). rem rem Cluster 2 is the first sector occupied by the Root Directory Table rem (i.e. the first sector used for the storage of data); and Norton's rem DiskEdit identifies it as cluster 2. [Note: Cluster numbers are ONLY rem assigned to the Data Area of the partition, NOT to the "system area"] rem rem NB: To calculate the LBA location of the 1st sector occupied by rem the Root Directory Table, see below under "ROOT DIRECTORY". rem rem The first sector containing an actual file is thus the first sector rem in cluster 3 (bearing in mind that LBA counts from 0, not 1): rem rem 1st sector of Root Dir Table (LBA) + No. of Sectors per Cluster rem rem NB: This is because the Root Directory Table usually occupies rem 1 cluster (i.e. 32 sectors if the partition's cluster size rem is 16k, or 64 sectors if the partition uses 32k clusters). rem rem NB: Cluster 3 is typically occupied by the Directory Table rem for the directory RECYCLED (a hidden system directory). rem rem rem Examples: rem rem If cluster size is 16k, cluster 3 starts (in LBA sectors) at: rem (1st sector of Root Directory Table) + 32 rem rem If cluster size is 32k, cluster 3 starts (in LBA sectors) at: rem (1st sector of Root Directory Table) + 64 rem rem rem Clusters used by a File - rem rem Norton's DiskEdit can read from the FAT the cluster numbers used rem by a file, if the FAT is undamaged (see below: "FILE CLUSTERS"). rem FAT RANGES rem ========== rem rem The following are the ranges for partition size, which overlap: rem rem Type Min Partition Size Max Partition Size rem ----- ------------------ ------------------------------------- rem FAT12 1.5 KB 32 MB ( 33,472,512 bytes) rem FAT16 16 MB 2,047 MB (2 GB) (2,147,123,200 bytes) rem FAT32 ~32 MB 2,000 GB (2 TB) ( about 2^40 bytes) rem rem rem Practical Limits: rem rem The above partition sizes are the *theoretical* limits, but rem the following practical restrictions also apply - rem rem 1. Although FAT16 cannot be used for a partition larger than 2GB, rem a disk of up to 4GB can have several FAT16 partitions on it, rem each not exceeding 2GB. rem rem 2. Large Disk Support (FAT32) is NOT available on disks smaller rem than 510MB. A FAT32 partition smaller than 510MB can only exist rem as one of several partitions on a hard disk larger than that. rem rem 3. Windows 98/ME cannot address a FAT32 partition exceeding 137GB, rem and Windows XP cannot create a FAT32 partition exceeding 32GB; rem so in practice those are upper limits for a FAT32 partition. rem rem NB: For various reasons, in practice the largest partition size rem that can exist on a Windows 98/ME system is 127.53 GB. rem rem rem Notes: rem rem 16-bit FAT (i.e. FAT16) is commonly referred to simply as FAT rem by many disk tools (including FDISK.EXE and FORMAT.COM), and rem in documentation and Help files accompanying those programs. rem rem 32-bit FAT (i.e. FAT32) is sometimes referred to as "BigFAT" rem by disk tools, and in documentation and Help files. rem rem See also: http://en.wikipedia.org/wiki/File_Allocation_Table rem PARTITIONS rem ========== rem rem The disk space is sub-divided into one or more separate Partitions rem (usually called "Drives"). rem rem The Partition Table in the MBR sector defines: rem - one Primary partition (of type 0C); rem - one Extended partition (of type 0F) if disk space remains. rem rem The Partition Table begining the Extended partition defines: rem - one Logical partition (of type 0B), within the Extended partition; rem - one further partition (of type 05), containing a Logical partition, rem if the remaining disk space within the Extended partition permits. rem rem The Partition Table beginning a Type 05 partition defines: rem - one Logical partition (of type 0B), filling the Type 05 partition; rem - one further partition (of type 05), containing a Logical partition, rem if the remaining disk space within the Extended partition permits. rem rem NB: There can be up to 32 partitions in all, on a FAT32 disk, rem if the disk space within the Extended partition permits. rem rem rem In a WinME (or Win98/98SE) system using 32-bit FAT - rem rem 1. The Primary DOS partition will normally be type 0C (i.e. the rem the 1st entry in the MBR's partition table will be type 0C). rem rem 2. The Extended partition, in which the Logical partitions rem are stored, will normally be type 0F (i.e. the 2nd entry rem in the MBR's partition table will normally be type 0F). rem rem NB: If the Extended partition ends at cylinder 1024 or later rem (i.e. the hard disk exceeds 8GB), the Extended partition rem *must* be type 0F. If it is not, data damage will occur. rem rem 3. Each Logical partition (INCLUDING the first) will normally be rem type 0B (i.e. the 1st entry in each E-MBR partition table, with rem which the Logical partition begins, will normally be type 0B). rem rem NB: Each partition table sector (other than the MBR sector rem at CHS 0-0-1) is called an Extended MBR (E-MBR) sector, rem because it's part of the Extended partition. rem rem 4. Each Logical partition (EXCEPT the first), although part rem of the Extended partition, will *also* be in an individual rem partition of its own, of type 05 (i.e. the 2nd entry, if any, rem in each E-MBR partition table will normally be type 05). rem rem If a partition table (in the MBR or any E-MBR sector) does NOT rem specify the normal partition type expected, check carefully to rem establish why! An abnormal partition type may cause data damage. rem PARTITION TYPES rem =============== rem rem ID types in Partition Tables - rem rem FAT32 typically uses four main partition types: 05, 0B, 0C and 0F rem (these are numerical values, expressed in hex: i.e. hexadecimal). rem rem NB: The procedures set out in this page are ONLY safe to use with rem a hard disk that has those partition types AND NO OTHER. rem rem 0C = FAT32 Primary DOS Partition, ending at cylinder 1024 or later rem Type: FAT32X (Type 0B with Interrupt-13 extensions) rem (i.e. FAT32 with LBA) ("Win95 FAT32 (LBA)") (Entry No.1 in MBR) rem (NB: The normal type of FAT32 for a Primary partition larger rem than 8GB; i.e. where the 1024 cylinder limit is exceeded) rem rem Note: If the disk is bootable and contains only one partition, rem that will be a Primary DOS Partition (i.e. type 0C). rem rem 0F = FAT32 Extended Partition, ending at cylinder 1024 or later rem Type: Extended X (Type 05 with Interrupt-13 extensions) rem (i.e. FAT32 with LBA) ("Win95 Extended") (Entry No.2 in the MBR) rem (NB: The normal type of FAT32 for an Extended partition on a disk rem larger than 8GB, i.e. where the 1024 cylinder limit is exceeded) rem rem NB: This is a container of partitions (not a container of data), rem as indicated by its being labelled an "Extended" partition. rem rem Note: If there is more than one partition, an Extended partition rem (i.e. type 0F) contains all of them except the first one. rem rem Note: The 2nd partition will be a Logical partition (i.e. type 0B); rem as will any further partitions (e.g. the 3rd, 4th, etc). rem rem Note: If there are only two partitions on the disk, the 2nd partition rem will normally completely fill the Extended partition. If the disk rem has three or more partitions, each Logical partition will occupy rem PART of the Extended partition, but *without* any overlapping. rem rem 0B = FAT32 Partition ("Win95 FAT32") (NB: Originated in Windows 95) rem (Entry No.1 in an E-MBR) rem (NB: All Logical partitions on a FAT32 disk are type 0B) rem rem Note: If a FAT32 disk contains more than one partition, the rem 2nd partition (i.e. the 1st Logical partition), and any rem subsequent partition(s), will each be type 0B. rem rem 05 = MS-DOS Extended Partition rem (Entry No.2 in an E-MBR) rem (NB: On a FAT32 disk a *second* or subsequent Logical partition rem is contained in - and entirely fills - a partition of type 05) rem rem NB: This is a container of partitions (not a container of data), rem as indicated by its being labelled an "Extended" partition. rem rem Note: If there are MORE than two partitions on the disk, the rem 3rd partition (i.e. the 2nd Logical partition), and any rem subsequent one, each completely fills one type 05 partition. rem rem rem Hidden Partitions: rem rem 1B = Hidden FAT32 0B Partition rem 1C = Hidden FAT32 0C Partition (e.g. hidden IBM rescue partition) rem rem A hidden partition type starts with a 1, and an unhidden type rem starts with a 0. To hide a partition, change leading 0 to 1. rem For example: Type 0B is FAT32, and type 1B is Hidden FAT32. rem rem rem Warning for Windows 95: rem rem Types 0E and 0F can cause data loss in Win95 (but not in Win98 or rem WinME), if you exit from Windows to MS-DOS mode WITHOUT rebooting rem (although *only* if the Disk has more than one partition). rem rem This fault can be cured by installing the updated Windows 95 file rem DISKTSD.VXD v4.00.952 (dated 3/22/96), or any later version. rem rem rem Note on FAT16: rem rem If the partition type is 06 the partition is using FAT16. This also rem means that the partition size cannot be larger than 2GB. rem rem NB: A FAT16 disk cannot safely be repaired using any procedure set out rem here; there are crucial differences from FAT32 in the MBR, in the rem Partition Table, in the Boot Sector, in the Boot Record, in the rem File Allocation Table structure, and in the Root Directory table. rem PARTITIONING RULES rem ================== rem rem Partitioning rules demand that a partition MUST end on a rem Cylinder boundary (1 Cylinder = 255 x 63 = 16,065 sectors); rem i.e. every partition *must* be a multiple of 16,065 sectors. rem rem NB: This is a FUNDAMENTAL requirement. Data damage is a rem certainty if this rule is breached! rem rem NB: This ONLY applies to the Primary DOS partition and the rem Extended Partition, *not* to Logical partitions within rem the Extended Partition. But the 1st Logical partition rem will also obey this if it's the ONLY Logical partition rem and it occupies ALL the space in the Extended partition. rem rem Partitions are thus "cylinder aligned": they invariably start rem and end on a cylinder boundary (even though a Cylinder is now rem only a logical, rather than a physical, disk structure). rem rem NB: For tools to convert LBA values to CHS, and vice versa, rem see below under PTCALC.EXE and "CONVERSION CALCULATIONS" rem rem Therefore many partitions begin with the CHS address xxxx-0-1 rem (i.e. the first sector of a cylinder), and will end with the rem CHS address xxxx-254-63 (i.e. the final sector of a cylinder). rem rem NB: The Partition Table will therefore be at CHS xxxx-0-1 rem and the Boot Sector will therefore be at CHS xxxx-1-1 rem rem Although Logical partitions (other than the 1st Logical partition) rem can begin part-way through a Cylinder, they nevertheless will NOT rem begin part-way through a Head; they always start at CHS xxxx-x-1. rem PARTITION STRUCTURE rem =================== rem rem It may help in understanding disk structure to think of rem a partition as starting with a Partition Table, followed rem 63 sectors later (i.e. 1 Head later) by a Boot Sector. rem rem NB: Technically, though, the Partition Table *defines* rem the Partition (as begining with the Boot Sector), rem and is NOT treated as being part of the Partition. rem rem The Boot Sector defines the 63 sectors containing the rem Partition Table as "hidden sectors", and they are NOT rem counted as part of the Partition by any disk tool. rem rem rem Examples: rem rem In the case of the Primary DOS partition, the Partition Table rem is in the MBR sector, at CHS 0-0-1; and the Boot Sector is in rem CHS 0-1-1 (i.e. 63 sectors later). rem rem In the case of Logical Partitions, the relationship is clearer: rem the 1st Logical partition is defined in the MBR as *beginning* rem with its Partition Table sector (the MBR points to that sector). rem rem NB: Technically, the MBR is defining the Extended partition, by rem pointing to the first sector of it (which happens to contain rem the Partition Table for the 1st Logical partition). rem rem As with the Primary partition, the 63 sectors containing rem the Partition Table are defined as NOT being a part of the rem 1st Logical partition and are treated as "hidden sectors". rem rem rem Note on Partition Reconstruction: rem rem The Boot Sector usually contains all the necessary information rem (see below) to undelete the partition that it belongs to. rem rem Every partition begins with a Boot Sector, immediately preceeded rem by 1 Head (typically 63 sectors) containing a Partition Table. rem rem Thus a partition ends immediately before a sector that contains rem ONLY another Partition Table (not any boot code, because Logical rem partitions are not bootable). The sector will be entirely BLANK rem (i.e. filled with zeros), except for a 12 byte Partition Table. rem rem NB: A Logical partition *can* be bootable, but only in special rem circumstances not usually encountered (see below). rem rem To be valid, a Partition Table usually must be on a cylinder boundary rem (but see above, under "PARTITIONING RULES"). (NB: If it is not, rem it is probably a backup copy, created by a disk recovery tool) rem NON-DOS PARTITION rem ================= rem rem The first 63 sectors on the Disk (CHS 0-0-1 to 0-0-63). For rem historical reasons, sometimes called "Track 0". rem rem NB: Although called the "Non-DOS Partition" this is NOT truly rem a partition at all, as it does not contain any user data. rem (As disks were once so small that they usually had only a rem single DOS partition, the name "Non-DOS Partition" arose) rem rem It starts at sector 1 (CHS 0-0-1) (LBA 0) and ends at sector 63 rem (CHS 0-0-63) (LBA 62); a hidden 63 sectors at the start of the rem disk. It contains the Partition Table for the *entire* Disk. rem rem NB: The LBA sector numbering starts at 0, whereas CHS sector rem numbering starts at 1; hence there is a discrepancy of 1. rem rem Sector 1 (CHS 0-0-1), the Master Boot Record (MBR), contains: rem the Initial Program Loader (IPL) code, BIOS Parameter Block (BPB), rem and the Partition Table. rem rem All other sectors are usually blank; but special backup software rem sometimes stores recovery data in the 62 empty sectors, so it is rem prudent to make a backup copy of ALL the 63 sectors of Track 0. rem rem On the ST380011A Disk: rem (a) Sector CHS 0-0-3 contains recovery data. rem (b) Sector CHS 0-0-9 contains a backup copy of the MBR sector rem (from CHS 0-0-1), starting with the marker "90 E9 7D". rem rem On the M02GB2 (18GB) Disk: rem (a) Sector CHS 0-0-62 (at 7A00 hex) contains recovery data. rem (b) Sector CHS 0-0-63 (at 7C00 hex) contains recovery data. rem rem The name "Non-DOS partition", used for historical reasons, is rem misleading. This is NOT a partition: it contains NO user data. rem It's actually an essential part of ALL the partitions on the rem disk, because it contains the Master Partition Table. rem rem rem Master Boot Record (MBR) - rem rem The Master Boot Record is located in the first physical sector of rem the disk. It contains some executable code and the Partition Table. rem rem The executable code is loaded into RAM at boot time and executed. rem Its role is to determine which partition is the bootable one, rem and then to load and execute the code in the Boot Sector of that rem partition (which in turn loads the Operating System, i.e. Windows). rem rem FDISK's notorious /MBR command recreates the executable code in rem the Master Boot Record (but on Disk 0 only). rem rem NB: That command will be HARMFUL if any drive overlay software is rem installed (e.g. OnTrack Disk Manager), to handle large disks, rem something that is required only on a disk larger than 127.53 GB. rem The loader code in the MBR on such a disk is not standard code; rem the command will destroy the special loader code, so the disk rem will no longer be accessible. (The Partition Table information rem is also *not* the same on such a disk as it would be on a disk rem that does not have drive overlay software.) rem rem NB: That command will also be HARMFUL if - rem (a) the Hard Disk has more than four partitions, or rem (b) the Hard Disk has dual-boot capability installed, or rem (c) the Hard Disk was originally partitioned using a SpeedStor rem utility from Storage Dimensions, with the /BOOTALL option. rem rem rem Structure of MBR Sector: rem rem Offset Nature Size rem -------- ------------------------- --------- rem 00(hex) Executable code 446 bytes rem 1BE(hex) 1st partition table entry 16 bytes rem 1CE(hex) 2nd partition table entry 16 bytes rem 1DE(hex) 3rd partition table entry 16 bytes rem 1EE(hex) 4th partition table entry 16 bytes rem 1FE(hex) Executable marker (55 AA) 2 bytes rem rem rem Executable Code: rem rem On a FAT32 hard disk, formatted by Windows 98/98SE/ME, the first 446 bytes rem of the MBR Sector normally look like this (in Hex and ASCII): rem :: <------------------- Hexadecimal --------------------> <--- ASCII ----> :: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF :: --------------------------------------------------------------------------- :: 0000: 33 C0 8E D0 BC 00 7C FB-50 07 50 1F FC BE 1B 7C [ 3м |P P | ] :: 0010: BF 1B 06 50 57 B9 E5 01-F3 A4 CB BE BE 07 B1 04 [ PW ˾ ] :: 0020: 38 2C 7C 09 75 15 83 C6-10 E2 F5 CD 18 8B 14 8B [ 8,| u ] :: 0030: EE 83 C6 10 49 74 16 38-2C 74 F6 BE 10 07 4E AC [ It 8,t N ] :: 0040: 3C 00 74 FA BB 07 00 B4-0E CD 10 EB F2 89 46 25 [ < t F% ] :: 0050: 96 8A 46 04 B4 06 3C 0E-74 11 B4 0B 3C 0C 74 05 [ -F < t < t ] :: 0060: 3A C4 75 2B 40 C6 46 25-06 75 24 BB AA 55 50 B4 [ :u+@F% u$UP ] :: 0070: 41 CD 13 58 72 16 81 FB-55 AA 75 10 F6 C1 01 74 [ A Xr Uu t ] :: 0080: 0B 8A E0 88 56 24 C7 06-A1 06 EB 1E 88 66 04 BF [ V$ f ] :: 0090: 0A 00 B8 01 02 8B DC 33-C9 83 FF 05 7F 03 8B 4E [ 3Ƀ  N ] :: 00A0: 25 03 4E 02 CD 13 72 29-BE 46 07 81 3E FE 7D 55 [ % N r)F >}U ] :: 00B0: AA 74 5A 83 EF 05 7F DA-85 F6 75 83 BE 27 07 EB [ tZ څu' ] :: 00C0: 8A 98 91 52 99 03 46 08-13 56 0A E8 12 00 5A EB [ R F V Z ] :: 00D0: D5 4F 74 E4 33 C0 CD 13-EB B8 00 00 00 00 00 00 [ Ot3 ] :: 00E0: 56 33 F6 56 56 52 50 06-53 51 BE 10 00 56 8B F4 [ V3VVRP SQ V ] :: 00F0: 50 52 B8 00 42 8A 56 24-CD 13 5A 58 8D 64 10 72 [ PR BV$ ZXd r ] :: 0100: 0A 40 75 01 42 80 C7 02-E2 F7 F8 5E C3 EB 74 49 [ @u B ^tI ] :: 0110: 6E 76 61 6C 69 64 20 70-61 72 74 69 74 69 6F 6E [ nvalid partition ] :: 0120: 20 74 61 62 6C 65 00 45-72 72 6F 72 20 6C 6F 61 [ table Error loa ] :: 0130: 64 69 6E 67 20 6F 70 65-72 61 74 69 6E 67 20 73 [ ding operating s ] :: 0140: 79 73 74 65 6D 00 4D 69-73 73 69 6E 67 20 6F 70 [ ystem Missing op ] :: 0150: 65 72 61 74 69 6E 67 20-73 79 73 74 65 6D 00 00 [ erating system ] :: 0160: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 [ ] :: 0170: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 [ ] :: 0180: 00 00 00 8B FC 1E 57 8B-F5 CB 00 00 00 00 00 00 [ W ] :: 0190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 [ ] :: 01A0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 [ ] :: 01B0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 ... [ ] rem rem Notes - rem 1. Hexadecimal: Base 16 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). rem 2. ASCII: American Standard Code for Information Interchange rem (a set of 255 characters, including A to Z and 0 to 9). rem 3. For each 2-digit hexadecimal number in the above table, rem you can identify its (hexadecimal) address in the sector rem by combining the row number (hex) in the left-hand margin rem with the column number (also in hex) across the top; rem e.g. the number in the 3rd column of the 3rd line is 7C rem and its address is 22 hex: 0020 (left column) + 02 (top). rem rem Examples: Copies of sector CHS 0-0-1 are set out below, saved by rem the program MBRSCAN.EXE from several FAT32 disks, as examples of rem the correct code for that sector (see "MBRSCAN RESULTS", below). rem rem rem CHS values in the MBR: rem rem If the disk is larger than 8GB, the only VALID numbers in the MBR rem are the LBA sector numbers (the numbers in the fields "sectors" rem and "sectors before"). The CHS values in the MBR are NOT correct rem as they stand: they are "L-CHS" values (see above); a conversion rem factor must be applied to them to calculate the *true* CHS values. rem rem rem Disk Serial Number: rem rem The six bytes DA to DF (bytes 219 to 224) in the MBR sector are rem a serial number, used by Windows to identify the different disks rem attached to the computer. [NB: In line 14, on a standard display] rem rem If two hard disks have the same serial number, a fault will occur rem during bootup (because, in effect, both have the same "address"). rem rem The fault can be prevented, or repaired, by manually zeroing these rem six bytes (a.k.a. the "mystery bytes") on either disk. This forces rem Windows to allocate a new serial number to the disk, on the next rem bootup, thereby preventing a clash of disk addresses. rem rem NB: This serial number must NOT be confused with - rem rem (a) the hardware serial number, set by the disk's manufacturer rem (a.k.a. the "physical serial number"), on the disk's label; rem rem (b) the serial number that Windows allocates to each Partition rem (the Volume Serial Number), to allow it to differentiate rem between the different partitions [readable with CHKDSK.EXE]. rem rem rem This fault may cause the following errors:- rem rem 1. Windows may refuse to start. rem rem Restart in DOS, and use a Disk Editor (below) to set the six rem bytes to 00 (zero hex), on either disk. rem rem 2. Windows may WIPE the system registry. rem rem The registry can be *restored* in DOS from the backups in rem C:\WINDOWS\SYSBCKUP by using the following commands (and rem then carrying out the on-screen instructions): rem :: SET PATH=%path%;C:\WINDOWS\COMMAND :: SCANREG /RESTORE rem rem 3. Windows may change the Volume Identifier on the affected disk, rem setting it as non-bootable. If it's subsequently installed as rem the Primary Master, the computer will not boot. rem rem Use PowerQuest's Partition Table Editor (below) to set the rem Primary DOS partition on the disk to "active" (i.e. bootable). rem rem rem Alternate MBR Type: rem rem In practice, the following MBR sector is sometimes encountered. rem rem This is (informally) the "90 E9 7D 01 FA" variant, as it always begins rem with those 5 bytes. They immediately preceed the three bytes "33 C0 8E" rem which typically begin a standard MBR in FAT32 (see above). rem rem The first 446 bytes of this variant (i.e. the beginning of the sector, rem prior to the Partition Table) are usually in the following form: rem :: <------------------- Hexadecimal --------------------> <--- ASCII ----> :: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF :: --------------------------------------------------------------------------- :: 0000: 90 E9 7D 01 FA 33 C0 8E-D0 8E C0 8E D8 BC 00 7C [ } 3Ўؼ | ] :: 0010: 8B F4 FB BF 00 06 B9 00-01 F3 A5 BB 20 06 FF E3 [ ] :: 0020: 90 90 BE 7D 07 81 3C AA-55 75 11 E8 58 00 73 0C [ } }Uu ] :: 0070: EA 00 7C 00 00 BE 6A 07-AC 0A C0 74 FE BB 07 00 [ | j t ] :: 0080: B4 0E CD 10 EB F2 BB 00-7E C6 07 13 C6 47 01 00 [ ~ G ] :: 0090: B2 80 B8 00 E0 CD 13 C3-BF 00 7E BA F0 01 B3 A0 [ ÿ ~ ] :: 00A0: E8 84 00 72 0C B1 01 E8-48 00 72 05 E8 19 00 73 [ r H r s ] :: 00B0: 16 F6 C3 10 75 05 80 CB-10 EB E5 81 FA 70 01 74 [ u p t ] :: 00C0: 05 BA 70 01 EB D8 F9 C3-81 BD FE 01 55 AA 75 17 [ p Á Uu ] :: 00D0: 8B 75 02 81 FE BE 01 77-0E 03 F7 81 3C AA 55 75 [ u w