re: Routine to BACKUP and RESTORE key sectors of a FAT32 Hard Disk
Thursday, August 7, 2008 at 10:48 am Windows Me Annoyances Discussion Forum
Posted by Ed
(659 messages posted)
Routine to BACKUP and RESTORE key sectors of a FAT32 Hard Disk
on a system with up to two Hard Disks, each with up to four Partitions
Continued...
RESTORE a Sector
==================
Svend's Utilities: FINDPART for DOS (version 4.72)
NB: PUTSECT is a switch (i.e. option) in this version of FINDPART.EXE,
not a seperate program!
RECOVERY PROCEDURE:
The quickest way to recover is -
1) Boot to the DOS prompt (with a Win9x bootable floppy disk)
2) Rebuild the partition table (CHS 0-0-1) (from backup)
3) Rebuild the boot sector (CHS 0-1-1) (from backup)
4) Restore FAT1 (from backup)
Note: If FAT2 is undamaged, set the first 4 bytes of the first FAT
to 00000000. When Windows 9x detects that the first FAT is corrupt
it automagically uses the second FAT.
Write contents of a 512-byte file to Disk
==============================================
*** Set the FINDPART environment variable ***
*** ALL PUTSECT OPERATIONS WILL FAIL IF THIS IS NOT SET ***
SET FINDPART=EDIT
SYNTAX of PUTSECT -
Writes a 512 byte file to a (512 byte) disk sector
(NB: The program will ONLY write a 512 byte file!)
First is the number of the Disk (numbered from 1), e.g. 1
(NB: Valid disk numbers are from 1 to 8)
Next is the sector's CHS number: e.g. 0 0 1
Next is the FILENAME of the source file
Next is the number of cylinders on the disk, a 4-digit number
(NB: Get this number with PARTINFO.EXE - a DECIMAL number)
Next is the hash number of the source file, an 8-digit number
(To find that number: FINDPART PUTSECT GETHASH FILENAME.TYP)
(Or HASH can be entered as 00000000 if FORCE added to command)
*** Identify number of Cylinders on the Disk with PARTINFO ***
** Identifies CHS values for ALL Disks present **
PARTINFO > PARTINFO.txt
Notes:
PUTSECT can only write a 512 byte file, but -
1. The program MBRutilD.EXE can save and restore the entire
TRACK 1 (CHS 0-0-1 to 0-0-63), but ONLY for Disk 1
2. The program SRCFAT.COM can save and restore an entire FAT
*** Display the Help screen ***
FINDPART PUTSECT /?
*** Save the Help screen to a file ***
FINDPART PUTSECT /? > PUTSECT.TXT
DISK 1 [____ cylinders (decimal)]
=======
NON-DOS PARTITION:
*** Write Sector 0-0-1 (MBR Sector) ***
FINDPART PUTSECT 1 0 0 1 0-0-1.D1 ____ 00000000 FORCE
*** Write Sector 0-0-3 (Third Sector) ***
FINDPART PUTSECT 1 0 0 3 0-0-3.D1 ____ 00000000 FORCE
*** Write Sector 0-0-9 (Backup MBR Sector) ***
FINDPART PUTSECT 1 0 0 9 0-0-1.D1 ____ 00000000 FORCE
*** Write Sector 0-0-62 (Sector 62) ***
FINDPART PUTSECT 1 0 0 62 0-0-62.D1 ____ 00000000 FORCE
*** Write Sector 0-0-63 (Sector 63) ***
FINDPART PUTSECT 1 0 0 63 0-0-63.D1 ____ 00000000 FORCE
*** MBRutilD Copyright (c) 2002 PowerQuest Corporation ***
** MBRutil.exe [/?] [/S[H]=filename] [/R[H]=filename] **
** /S Save MBR (sector 1 only) to filename **
** /SH Save entire first head to filename **
** /R Restore MBR (sector 1 only) from filename **
** /RH Restore entire first head from filename **
MBRUtilD.exe /RH=0-0-1-63.D1
PRIMARY PARTITION:
*** Write Sector 0-1-1 (Boot Record) ***
FINDPART PUTSECT 1 0 1 1 0-1-1.D1 ____ 00000000 FORCE
*** Write Sector 0-1-2 (FS Info Sector) ***
FINDPART PUTSECT 1 0 1 2 0-1-2.D1 ____ 00000000 FORCE
*** Write Sector 0-1-3 (Root Directory) ***
FINDPART PUTSECT 1 0 1 3 0-1-3.D1 ____ 00000000 FORCE
*** Write Sector 0-1-7 (Backup Boot Record) ***
FINDPART PUTSECT 1 0 1 7 0-1-1.D1 ____ 00000000 FORCE
*** Write Sector 0-1-8 (Backup FS Info Sector) ***
FINDPART PUTSECT 1 0 1 8 0-1-2.D1 ____ 00000000 FORCE
*** Write Sector 0-1-9 (Backup Root Directory) ***
FINDPART PUTSECT 1 0 1 9 0-1-3.D1 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
Most other sectors in Track 1 and in the first 33 sectors
of each Partition are empty, i.e. filled with zero's, and may
need to be set to zero if overwritten with garbage by a crash
FINDPART PUTSECT 1 _____ ___ __ !zero ____ 00000000 FORCE
DISK 2 [____ cylinders (decimal)]
=======
NON-DOS PARTITION:
*** Write Sector 0-0-1 (MBR Sector) ***
FINDPART PUTSECT 2 0 0 1 0-0-1.D2 ____ 00000000 FORCE
*** Write Sector 0-0-3 (Third Sector) ***
FINDPART PUTSECT 2 0 0 3 0-0-3.D2 ____ 00000000 FORCE
*** Write Sector 0-0-9 (Backup MBR Sector) ***
FINDPART PUTSECT 2 0 0 9 0-0-1.D2 ____ 00000000 FORCE
*** Write Sector 0-0-62 (Sector 62) ***
FINDPART PUTSECT 2 0 0 62 0-0-62.D2 ____ 00000000 FORCE
*** Write Sector 0-0-63 (Sector 63) ***
FINDPART PUTSECT 2 0 0 63 0-0-63.D2 ____ 00000000 FORCE
PRIMARY PARTITION:
*** Write Sector 0-1-1 (Boot Record) ***
FINDPART PUTSECT 2 0 1 1 0-1-1.D2 ____ 00000000 FORCE
*** Write Sector 0-1-2 (FS Info Sector) ***
FINDPART PUTSECT 2 0 1 2 0-1-2.D2 ____ 00000000 FORCE
*** Write Sector 0-1-3 (Root Directory) ***
FINDPART PUTSECT 2 0 1 3 0-1-3.D2 ____ 00000000 FORCE
*** Write Sector 0-1-7 (Backup Boot Record) ***
FINDPART PUTSECT 2 0 1 7 0-1-1.D2 ____ 00000000 FORCE
*** Write Sector 0-1-8 (Backup FS Info Sector) ***
FINDPART PUTSECT 2 0 1 8 0-1-2.D2 ____ 00000000 FORCE
*** Write Sector 0-1-9 (Backup Root Directory) ***
FINDPART PUTSECT 2 0 1 9 0-1-3.D2 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
Most other sectors in Track 1 and in the first 33 sectors
of each Partition are empty, i.e. filled with zero's, and may
need to be set to zero if overwritten with garbage by a crash
FINDPART PUTSECT 2 _____ ___ __ !zero ____ 00000000 FORCE
EXTENDED Partition
====================
DISK 1 [____ cylinders (decimal)]
======
1st Logical Partition -
*** Write Boot Record ***
** User must insert CHS value (from sector 0-0-1) of 1st sector **
FINDPART PUTSECT 1 _____ ___ __ L1_1st.D1 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L1_2nd.D1 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L1_3rd.D1 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L1_1st.D1 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L1_2nd.D1 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L1_3rd.D1 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 1 _____ ___ __ !zero ____ 00000000 FORCE
2nd Logical Partition -
*** Write Boot Record ***
** User must insert CHS value from 1st Logical Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_1st.D1 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_2nd.D1 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_3rd.D1 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_1st.D1 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_2nd.D1 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L2_3rd.D1 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 1 _____ ___ __ !zero ____ 00000000 FORCE
3rd Logical Partition -
*** Write Boot Record ***
** User must insert CHS value from 2nd Logical Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_1st.D1 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_2nd.D1 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_3rd.D1 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_1st.D1 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_2nd.D1 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 1 _____ ___ __ L3_3rd.D1 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 1 _____ ___ __ !zero ____ 00000000 FORCE
DISK 2 [____ cylinders (decimal)]
======
1st Logical Partition -
*** Write Boot Record ***
** User must insert CHS value (from sector 0-0-1) of 1st sector **
FINDPART PUTSECT 2 _____ ___ __ L1_1st.D2 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L1_2nd.D2 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L1_3rd.D2 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L1_1st.D2 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L1_2nd.D2 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L1_3rd.D2 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 2 _____ ___ __ !zero ____ 00000000 FORCE
2nd Logical Partition -
*** Write Boot Record ***
** User must insert CHS value from 1st Logical Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_1st.D2 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_2nd.D2 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_3rd.D2 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_1st.D2 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_2nd.D2 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L2_3rd.D2 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 2 _____ ___ __ !zero ____ 00000000 FORCE
3rd Logical Partition -
*** Write Boot Record ***
** User must insert CHS value from 2nd Logical Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_1st.D2 ____ 00000000 FORCE
*** Write FS Info Sector ***
** User must insert CHS value of 2nd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_2nd.D2 ____ 00000000 FORCE
*** Write Root Directory ***
** User must insert CHS value of 3rd sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_3rd.D2 ____ 00000000 FORCE
*** Write Backup Boot Record ***
** User must insert CHS value of 7th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_1st.D2 ____ 00000000 FORCE
*** Write Backup FS Info Sector ***
** User must insert CHS value of 8th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_2nd.D2 ____ 00000000 FORCE
*** Write Backup Root Directory ***
** User must insert CHS value of 9th sector of this Partition **
FINDPART PUTSECT 2 _____ ___ __ L3_3rd.D2 ____ 00000000 FORCE
*** Write all zero's to a sector ***
** This command replaces the filename with a special value **
FINDPART PUTSECT 2 _____ ___ __ !zero ____ 00000000 FORCE
/--------------------------------------------------------------/
Utilities for FAT
===================
Svend's Utilities: FINDPART for DOS (version 4.72)
NB: FINDFAT is a switch (i.e. option) in this version of FINDPART.EXE,
not a seperate program!
These can be used for two purposes:
1. To identify the starting sector of the 1st or 2nd FAT
on a working Disk, so as to BACKUP that FAT.
2. To locate a lost or damaged FAT on a damaged Disk.
*** Report starting sector (CHS) and size (sectors) ***
*** of both FAT 1 & FAT 2 (saves report to file) ***
** 1: Search Primary Partition only (Cylinders 0 & 1) **
FINDPART FINDFAT 1 0 1 A:\FAT_DSK1.TXT
FINDPART FINDFAT 2 0 1 A:\FAT_DSK2.TXT
FINDPART FINDFAT ALL 0 1 A:\FAT_ALL.TXT
** 2: Search Primary & Extended Partitions **
FINDPART FINDFAT ALL comprehensive A:\FAT_ALL.TXT
*** Find lost FAT on Disk 1 ***
** Saves the report to a file **
FINDFAT 1 comprehensive A:\FAT_DSK1.TXT
FINDPART FINDFAT 1 comprehensive A:\FAT_DSK1.TXT
*** Find lost FAT on Disk 2 ***
** Saves the report to a file **
FINDFAT 2 comprehensive A:\FAT_DSK2.TXT
FINDPART FINDFAT 2 comprehensive A:\FAT_DSK2.TXT
** Find lost FAT on ALL Disks **
** Saves the report to a file **
FINDFAT ALL comprehensive A:\FAT_ALL.TXT
FINDPART FINDFAT ALL comprehensive A:\FAT_ALL.TXT
SRCFAT.COM
SRCFat v1.3(c)2001 - The W0rm
Usage: SRCFat {drive:} {filename} {switch}
Program to RESTORE the 1st or 2nd FAT
SRCFat can SAVE, RESTORE and CHECK the FAT on a FAT32 Disk
(NB: Replaces older utilities that don't support FAT32)
The program can save and restore the first or second FAT,
or both; and can restore the 2nd FAT over a damaged 1st FAT
(i.e. restore the second FAT to the first), or vice versa.
Switches:
/S - Save FAT table to file
/R - Restore FAT table from file
/C - Compare FAT table to file
/2 - Use the second FAT copy
Note:
This program can *also* restore a FAT which was saved by
a DIFFERENT program (e.g. one saved by FINDPART.EXE)
A: BACKUP THE FAT
** Save 1st FAT **
SRCFAT C: F:\SAVED\SRC_FAT1.C /S
SRCFAT D: F:\SAVED\SRC_FAT1.D /S
** Save 2nd FAT **
SRCFAT C: F:\SAVED\SRC_FAT2.C /S /2
SRCFAT D: F:\SAVED\SRC_FAT2.D /S /2
** In practice, the following Backup routine is preferable **
** This saves 3 backup copies instead of only a single one **
** using the Serial Copy program SERCOPY.COM **
** (For saving files to USB Disk in F:, see below) **
** Save 1st FAT on Drive C: **
SRCFAT C: C:\SAVED\C_FAT1.BIN /S
SERCOPY C:\SAVED\C_FAT1.BIN F:\SAVED /L:3
** Save 1st FAT on Drive D: **
SRCFAT D: D:\SAVED\D_FAT1.BIN /S
SERCOPY D:\SAVED\D_FAT1.BIN F:\SAVED /L:3
** Save 2nd FAT on Drives C: & D: **
SRCFAT C: F:\SAVED\C_FAT2.001 /S /2
SRCFAT D: F:\SAVED\D_FAT2.001 /S /2
B: RESTORE THE FAT
*** Help Screen Operations ***
** Display Help screen **
SRCFAT /?
** Save Help screen to file **
SRCFAT /? > SRCFAT.txt
*** Operations on 1st FAT ***
** Compare 1st FAT to Backup file **
SRCFAT C: F:\SAVED\SRC_FAT1.C /C
SRCFAT D: F:\SAVED\SRC_FAT1.D /C
** Restore 1st FAT from Backup file **
** Firstly, save a backup of damaged 1st FAT **
** (NB: Depending on degree of file system damage **
** may report "Error, could not read sector") **
SRCFAT C: F:\SAVED\BAD_FAT1.C /S
SRCFAT D: F:\SAVED\BAD_FAT1.D /S
** Secondly, write 1st FAT backup file to Disk **
SRCFAT C: F:\SAVED\SRC_FAT1.C /R
SRCFAT D: F:\SAVED\SRC_FAT1.D /R
*** Operations on 2nd FAT ***
** Compare 2nd FAT to Backup file **
SRCFAT C: F:\SAVED\SRC_FAT2.C /C /2
SRCFAT D: F:\SAVED\SRC_FAT2.D /C /2
** Restore 2nd FAT from Backup file **
** Firstly, save a backup of damaged 2nd FAT **
** (NB: May give error: "Error, could not read sector") **
SRCFAT C: F:\SAVED\BAD_FAT2.C /S /2
SRCFAT D: F:\SAVED\BAD_FAT2.D /S /2
** Secondly, write 2nd FAT backup file to Disk **
SRCFAT C: F:\SAVED\SRC_FAT2.C /R /2
SRCFAT D: F:\SAVED\SRC_FAT2.D /R /2
*** Replace 1st FAT with 2nd FAT ***
** Compare 1st FAT to backup file of 2nd FAT **
SRCFAT C: F:\SAVED\SRC_FAT2.C /C
SRCFAT D: F:\SAVED\SRC_FAT2.D /C
** Restore 1st FAT from backup file of 2nd FAT **
** Firstly, save a backup of damaged 1st FAT **
** (NB: May give error: "Error, could not read sector") **
SRCFAT C: F:\SAVED\BAD_FAT1.C /S
SRCFAT D: F:\SAVED\BAD_FAT1.D /S
** Secondly, write 2nd FAT backup file to Disk **
SRCFAT C: F:\SAVED\SRC_FAT2.C /R
SRCFAT D: F:\SAVED\SRC_FAT2.D /R
Note:
If the first 8 bytes of the 1st FAT are replaced with 00000000
Win9x will automatically default to using the 2nd FAT instead
(i.e. treats the 1st FAT as corrupt). This might be tried
*before* attempting to replace the 1st FAT with the 2nd!
*** Replace 2nd FAT with 1st FAT ***
** Compare 2nd FAT to backup file of 1st FAT **
SRCFAT C: F:\SAVED\SRC_FAT1.C /C /2
SRCFAT D: F:\SAVED\SRC_FAT1.D /C /2
** Restore 2nd FAT from backup file of 1st FAT **
** Firstly, save a backup of damaged 2nd FAT **
** (NB: May give error: "Error, could not read sector") **
SRCFAT C: F:\SAVED\BAD_FAT2.C /S /2
SRCFAT D: F:\SAVED\BAD_FAT2.D /S /2
** Secondly, write 1st FAT backup file to Disk **
SRCFAT C: F:\SAVED\SRC_FAT1.C /R /2
SRCFAT D: F:\SAVED\SRC_FAT1.D /R /2
Note:
This procedure should normally only be necessary if
BOTH copies of the FAT are corrupted on a damaged Disk
*and* the backup copy of the 1st FAT is ALSO corrupted.
In theory, that situation can never arise! The backup copy
should be on a different Disk (i.e. at F:\SAVED).
CONTENTS OF THE FAT:
A cluster is a group of sectors holding user data.
Examples: A 4K cluster has 8 sectors in it (512*8=4,096)
A 16K cluster has 32 sectors in it (512*32=16,384)
The data area in a Partition starts at cluster #2. This leaves
the first two entries in the FAT unused. In the first entry,
the first byte is a copy of the media descriptor (F8); and
the last 3 bytes are 0F FF FF (written backwards as FF FF 0F).
The second entry is the end-of-cluster-chain marker (0F FF FF FF,
written backwards as FF FF FF 0F). This is the Dirty Shutdown
flag: its value changes if the last shutdown was not clean,
or if a disk I/O error was detected last session.
NB: In *all* Disks I have inspected, the second entry in the FAT
is actually 07 FF FF FF (written as FF FF FF 07)!
Each cluster has a 4-byte entry in the FAT. The entry tells you
whether the cluster has data in it (if the entry is 0, there is
no data in that cluster); and whether it is the end of the data
in the file (if the entry is 0FFFFFFFh it's the final entry
in the chain).
NB: On disk the bytes are (as always) written BACKWARDS,
so for instance 0FFFFFFFh reads on disk as FF FF FF 0F
Value Description
----- -----------
00000000 Free cluster (No data in it)
00000001 Reserved cluster, do not use
00000002 - 0FFFFFEF Number of the next cluster
0FFFFFF0 - 0FFFFFF6 Reserved cluster, do not use
0FFFFFF7 Bad sector in cluster or reserved cluster
0FFFFFF8 - 0FFFFFFF Last cluster in file (written FF FF FF 0F)
FILENAMES:
In FAT32, filenames (in 8.3 format) are stored in the Directory Table,
*not* in the FAT. Each 8.3 file entry is 32 bytes long. LFNs are
also stored in the Directory Table, alongside the 8.3 filename.
Directory Table format (8.3 filename entry):
Size Description
---- -----------
8 bytes Filename
3 bytes Extension
1 byte Attribute: 0 = unused; A = archive; R = read-only;
S = system; D = directory; V = volume
1 byte Reserved (00h)
1 byte Time Created (Seconds)
2 bytes Time Created (Hour & Minute)
2 bytes Date Created
2 bytes Date Last Accessed
2 bytes Reserved (00h)
2 bytes Time
2 bytes Date
2 bytes Cluster (Location of beginning of file)
4 bytes File Size
Total = 32 bytes
An additional 640 bytes are occupied by the LFN (Long FileName),
making each entry 672 bytes long (32 bytes + 640 bytes).
The Directory Table is not stored in a fixed location, nor does
it have a fixed size. Each directory (folder) has such a table,
which is just a file, but with a special (Directory) attribute.
:: /--------------------------------------------------------------/
DIRECTORIES
============
ROOT DIRECTORY
The Root Directory can be stored anywhere in the partition.
Unlike FAT16, it does NOT immediately follow the 2nd FAT.
SUB-DIRECTORIES
Svend's Utilities: FINDPART for DOS (version 4.72)
Searches for subdirectories, and calculates the estimated
location of cluster number two and cluster size.
Disks are numbered from 1.
The report can be written to a file. File extension must be .txt
** Display the Help screen **
FINDPART FINDDIR
** Save the Help screen to a file **
FINDPART FINDDIR > FINDDIR.TXT
** Search Disk 1 for Subdirectories **
** Saves report to a file **
FINDPART FINDDIR 1 FINDDIR1.txt
** Search Disk 2 for Subdirectories **
** Saves report to a file **
FINDPART FINDDIR 2 FINDDIR2.txt
FIND LOST DIRECTORIES
CYLDIR, version 5.5
Copyright Svend Olaf Mikkelsen, 2004
Lists lost (and deleted) directories found in a FAT32 partition.
Displays file names.
The correct DOS codepage must be loaded, before searching for or
copying files. [NB: DOS codepage for UK (country 044) is 850]
SET CODEPAGE=850
Usage: Cyldir {disk number} {cylinder} {head} {sector} {FAT size}
{cluster size} {root} [copyfiles {directory cluster}] [{logfile}]
{FAT size} in sectors (see Ranish Partition Manager: RPM.exe)
{cluster size} in KB (NB: If disk exceeds 32GB, must be 32KB)
{root} root cluster for FAT32 (NB: Usually cluster 2)
{logfile} extension must be .txt
A: List the Lost Files
To list the lost (or deleted) files in Partition 1 on Disk 1
where the Partition uses 32K clusters (i.e. exceeds 32GB):
CYLDIR 1 0 1 1 ____ 32 2 CDIR.TXT
Example:
From FINDPART FINDFAT you have this result for disk 1 -
-----FAT CHS -Size Cl --Root -Good -Rep. Maybe --Bad YYMMDD DataMB
260 0 33 1204 4 2 1204 0 0 0 981124
516
The CYLDIR command line to list the files to CDIR.TXT is the
disk number, followed by the first 6 numbers in the above line,
followed by the file name CDIR.TXT:
cyldir 1 260 0 33 1204 4 2 cdir.txt
B: Copy the Lost Files
Run CYLDIR.EXE from a floppy disk or an undamaged partition.
If the option COPYFILES is used, it copies files from a lost
directory. The cluster numbers are saved in the log file.
The current directory must be empty, unless it's the Root
directory. NB: Copied files *cannot* be expected to be okay!
** To speed up file copying, load HIMEM.SYS and SMARTDRV.EXE **
** 1: Load HIMEM.SYS in CONFIG.SYS **
** Syntax: device=himem.sys **
** 2: Load SMARTDRV.EXE before running CYLDIR **
SMARTDRV.EXE 4096 16>nul
CYLDIR 1 0 1 1 ____ 32 2 COPYFILES ____ CDIR.TXT
Note: Files are copied using their short file names. A file,
LONGNAME.BAT, for renaming them to Long File Names,
will automatically be created. A file named CYLDIR.LOG
records the names of files that are not readable or are
FDISK damaged. Files bigger than 2 GB cannot be copied.
Copying, Alternate usage:
Syntax:
Cyldir {directory cluster} dir [{copy logfile}]
Cyldir {directory cluster} tree [{copy logfile}]
Two additional ways to copy files from a lost partition.
Directories are relative to the current directory.
If 'tree' is specified, files in any subdirectories are copied.
If the target subdirectories already exist, they must be empty.
The main thing is to be certain that no copy of the lost files
is in the target partition. This could occur if partitions
overlap, or if old deleted copies of the lost files exist.
The logfile CDIR.TXT must exist in the current directory, or
in the Root of current partition. (Suggestion: Put CDIR.TXT
and CYLDIR.EXE in an empty directory and work from there.)
Up to ten {directory cluster}'s can be entered. If the Root
directory cluster number is entered with the 'tree' option, you
can add '+lost' to the command line to include lost directories,
beginning with ? in CDIR.TXT
CYLDIR ____ tree +lost COPYLOG.TXT
To stop the copy after the current directory, press ESC.
If run in pure DOS, a file LONGNAME.BAT for recreating long file
names is created in each directory. Must be enough free space.
To write a directory listing to CDIR.LST, use:
CYLDIR LIST
Choose some directory cluster numbers in CDIR.TXT; or do
'cyldir list' and find the numbers in CDIR.LST.
Example: To copy a single directory, whose cluster number is e.g. 117:
cyldir 117 dir
CYLDIR ___ DIR
Example: To copy an entire tree, whose cluster number is e.g. 117:
cyldir 117 tree
CYLDIR ___ TREE
Example -
Disk: 1 Cylinders: 9729 Heads: 255 Sectors: 63 MB: 76317
-PCyl N ID -----Rel -----Num ---MB -Start CHS- --End CHS-- BS CHS
0 - 0C 63 42973812 20983 0 1 1 2674 254 63 B OK
2675 1 0B 63113322447 55333 2675 1 1 9728 254 63 R0 OK
0 - 0B 42973938113322447 55333 2675 1 1 9728 254 63 B OK
6200 1 0B 63 56661192 27666 6200 1 1 9726 254 63 R0 OK
0 - 0B 99603063 56661192 27666 6200 1 1 9726 254 63 B OK
-----FAT CHS -Size Cl --Root -Good -Rep. Maybe --Bad YYMMDD DataMB
2675 1 33 13832 32 2 13832 0 0 0 080206
11160
6200 1 33 13830 16* 2*13830 0 0 0
2
Syntax:
CYLDIR + Disk number + first 6 numbers from lower table + CDIR.txt
** Disk 1, Partition 2 (Example) **
cyldir 1 2675 1 33 13832 32 2 cdir.txt
** Disk 1, Partition 4 (Example) **
cyldir 1 6200 1 33 13830 16 2 cdir.txt
/--------------------------------------------------------------/
Utilities for writing MULTIPLE sectors
==========================================
MBRUTILD.EXE
MBRUTILD.EXE: PowerQuest's MBR Utility for DOS
Backup and restore MBR Sector & Track 1 on Disk 1
NB: The program only works on Disk 1, not on Disks 2 or 3.
Saves and restores the entire Track 1 (CHS 0-0-1 to 0-0-63)
(i.e. all 63 sectors at once). This is the DOS version of
the MBR manager program: MBRutil.exe.
It might be made to work on *any* Hard Disk, by setting the
disk as Primary Master on the IDE cables. But that might be
impractical, as the disk to be restored will inevitably
be damaged and not bootable.
** Save the MBR (Sector 0-0-1) to a file **
MBRutilD /S=MBR_MBR.D1
** Restore the MBR (Sector 0-0-1) from a file **
MBRutilD /R=MBR_MBR.D1
** Save the entire first Track to a file **
** (Save sectors 0-0-1 to 0-0-63: all 63 sectors of first Track) **
MBRutilD /SH=MBR_TRK1.D1
** Restore the entire first Track from a file **
** (Restore sectors 0-0-1 to 0-0-63 from a backup file) **
MBRutilD /RH=MBR_TRK1.D1
/--------------------------------------------------------------/
LONG FILE NAME Utils
=======================
*** Set PATH to include LFN Utils Directory ***
** Example: Put the utils in the root directory of Drive F: **
SET PATH=%PATH%;F:\
*** LDIR.EXE: Directory Listing with Long File Names ***
** Pauses after each screen **
LDIR.EXE /P
*** LCOPY.EXE: Long filename version of COPY.EXE ***
** Copy file in DOS preserving its Long File Name **
Syntax:
LCOPY "[Source]" "[Destination]"
Example:
LCOPY "C:\PROGRA~1\TELEVI*" "A:\DATA"
1. The file LCOPY.EXE must be located in the DOS path.
(Set the PATH in autoexec.bat, e.g. SET PATH=A:\;F:\)
2. The destination directory must already exist, and
must be a valid DOS directory name (i.e. in 8.3 format).
3. It is NOT necessary to define a name for the file in the
destination instruction.
4. If the long file name contains spaces, the source and the
destination must BOTH be enclosed in quotation marks.
5. The DOS wildcard *.* is not valid. The wildcard * must be
used instead.
6. The wildcard * must come BEFORE the first space in the long
file name for the source to be valid.
7. The switch /A copies ALL files, including HIDDEN files.
8. To copy only directory structure use: LCOPY . {dest} /S
NB: The destination {dest} must be a valid path, e.g. F:\
*** Copy all files in current directory to Floppy Disk in A: ***
** Use of LCOPY.EXE preserves the Long File Names **
*** Copy ALL files in current directory ***
LCOPY.EXE "*" A:\ /A
*** Include all SUBDIRECTORIES of current (the /S switch) ***
LCOPY.EXE "*" A:\ /A /S
*** Copy all files in current directory to RAM disk in E: ***
** Use of LCOPY.EXE preserves the Long File Names **
*** Copy ALL files in current directory ***
LCOPY.EXE "*" E:\ /A
*** Include all SUBDIRECTORIES of current (the /S switch) ***
LCOPY.EXE "*" E:\ /A /S
Note:
To provide RAM disk in DOS, add this to CONFIG.SYS:
device=ramdrive.sys /E 16384
Note: RAMDRIVE.SYS is included on WinME's Emergency Boot Disk
*** Copy all files in current directory to USB disk in F: ***
** Use of LCOPY.EXE preserves the Long File Names **
*** Copy ALL files in current directory ***
LCOPY.EXE "*" F:\ /A
*** Include all SUBDIRECTORIES of current (the /S switch) ***
LCOPY.EXE "*" F:\ /A /S
USBASPI.SYS:
USBASPI.SYS merely maps USB devices to an ASPI device. An
additional driver, the "Motto Hairu" driver DI1000DD.SYS, is needed to
map the ASPI mass storage to a DOS drive letter.
Switches for the Panasonic USBASPI.SYS driver, v2.06:
device=USBASPI.SYS [/e] [/o] [/u] [/v] [/w] [/r] [/l[#]] [/slow] [/nocbc]
/e EHCI, for enabling only USB 2.0 controller
/o OHCI, for enabling only add-on/onboard USB 1.1 controller
/u UHCI, for enabling integrated USB 1.1 controller
/v Verbose mode, useful for troubleshooting
/w Wait, displays message to prompt attaching of USB device
/r Resident, load as memory resident if USB floppy detected
/l# Luns, specify highest number of LUN assigned: default /L0
/slow Use SLOW mode, gives longer delays on scanning USB ports
/nocbc No CardBus Controller, disable detection on CardBus slots
You can specify more than one controller type (e.g. /e /u). Use
this feature to specify which port types to enable: limiting
the port types scanned for results in a faster startup.
Specifying /u or /o and omitting /e forces USB 1.1 mode on USB 2.0 devices.
To connect both a USB 2.0 CD drive AND external USB 2.0 hard disk simultaneously
-
(a) Include the following lines in CONFIG.SYS:
device=USBASPI.SYS /e
device=USBCD.SYS /d:USBCD001
device=DI1000DD.SYS
(b) Include the following line in AUTOEXEC.BAT:
MSCDEX /d:USBCD001
To provide USB Support in DOS, add these lines to CONFIG.SYS:
device=USBASPI.SYS /e /o /u /v
device=DI1000DD.SYS
NOTES:
1. If the files to be recovered are too large for a floppy,
or a USB pen drive, attach a second HDD to an IDE cable
2. LCOPY.EXE and other LFN utils could be held on Drive E:,
a RAM disk where rescue utils are stored while carrying out
data recovery on an IDE Hard Disk
/--------------------------------------------------------------/
DOSKEY
=======
*** Set PATH to include DOSKEY ***
SET PATH=%PATH%;C:\WINDOWS\COMMAND
*** Run DOSKEY ***
DOSKEY
Useful DOSKEY commands:
F7 : Lists command history in current session
UP & DOWN ARROWS : Recall previous/next commands
SAVE FILES TO DRIVE F:
========================
*** Save output data to Drive F: (USB Pen Drive) ***
** NB: Check that the USB disk is Drive F: **
** STEP 1: Make a destination directory at Drive F: **
MD F:\SAVED\DATA
** STEP 2: Copy all output files to Drive F: **
** Options -
** /V Verify file was written correctly
** /Y Suppress prompt to overwrite if file already exists
COPY *.* F:\SAVED\DATA /V /Y
PATH
=====
*** Restore the original PATH settings ***
PATH ;
Set PATH=%DOSpath%
|