Thursday, August 16, 2007

check and repair MS-DOS file systems howto

Using linux, there are ways to check and repair for MS-DOS type of file systems. This has been possible using dosfsck linux command.

dosfsck verifies the consistency of MS-DOS file systems and optionally tries to repair them.
dosfsck repairs MS-DOS file system in this order

- FAT contains invalid cluster numbers. Cluster is changed to EOF.
- File’s cluster chain contains a loop. The loop is broken.
- Bad clusters (read errors). The clusters are marked bad and they are removed from files owning
them. This check is optional.
- Directories with a large number of bad entries (probably corrupt). The directory can be dropped.
- Files . and .. are non-directories. They can be dropped or renamed.
- Directories . and .. in root directory. They are dropped.
- Bad file names. They can be renamed.
- Duplicate directory entries. They can be dropped or renamed.
- Directories with non-zero size field. Size is set to zero.
- Directory . does not point to parent directory. The start pointer is adjusted.
- Directory .. does not point to parent of parent directory. The start pointer is adjusted.
- Start cluster number of a file is invalid. The file is truncated.
- File contains bad or free clusters. The file is truncated.
- File’s cluster chain is longer than indicated by the size fields. The file is truncated.
- Two or more files share the same cluster(s). All but one of the files are truncated. If the file
being truncated is a directory file that has already been read, the file system check is restarted
after truncation.
- File’s cluster chain is shorter than indicated by the size fields. The file is truncated.
- Clusters are marked as used but are not owned by a file. They are marked as free.
- Invalid parameters in boot sector.
- Absence of . and .. entries in non-root directories

When dosfsck checks a file system, it accumulates all changes in memory and performs them only after all checks are complete. This can be disabled with the -w option.

USAGE:
------

To automatically repair a floppy disk, you can issue the following commands.

# dosfsck -a -v /dev/fd0

To mark all unreadable clusters as bad

# dosfsck -t -v /dev/fd0

Everything happens in memory unless you specify all changes to be written to disk immediately like so

# dosfsck -t -v -w /dev/fd0

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy