To check a File Allocation Table (FAT)-based disk, a flash file system, or a Class C file system for damage and to repair
any problems, use the
fsck command in privileged EXEC or diagnostic mode.
Supported Platforms Other than the Cisco 7600 Series and Cisco ASR1000 Series Routers
fsck [/ nocrc] [/ automatic] [/ all] [/ force] [filesystem:]
Cisco 7600 Series Routers
fsck [/ automatic] [/ all] [/ force] [filesystem:]
Cisco ASR 1000 Series Routers
fsck [/ all] [/ force] [filesystem:]
Syntax Description
/nocrc
|
(Optional) This keyword is available for Class C flash file systems only. Omits cyclic redundancy checks (CRCs).
|
/automatic
|
(Optional) This keyword is available for Advanced Technology Attachment (ATA) FAT-based disks only. Specifies that the check
and repair actions should proceed automatically. This option can be used to skip the prompts for each check and repair action.
Note
|
This command also specifies the automatic mode for the Cisco 7600 series router; see the “Usage Guidelines” section for additional
information.
|
|
/ all
|
(Optional) Specifies that all partitions on the disk be checked for problems.
|
/force
|
(Optional) Ensures forced termination of simultaneous file operations on the same device.
|
filesystem
:
|
The file system prefix indicating the disk to be checked. The colon (:) is required. Typically, the file system prefix will
be
disk0: or
disk1: . In case of dual processors, the file system on the redundant supervisor engine can also be specified.
|
Command Default
A FAT-based disk, flash file system, or Class C file system is not checked for damage and repaired. If you do not enter the
/automatic keyword, command-line interface (CLI) prompts for actions are issued. For the Cisco 7600 series router, if you do not specify
the
disk0: keyword, the current file system is checked.
This command is available in both privileged EXEC and diagnostic mode on the Cisco ASR1000 series routers.
Command Modes
Privileged EXEC (#) Diagnostic (diag)
Command History
Release
|
Modification
|
11.3 AA
|
This command was introduced.
|
12.0(22)S
|
This command was implemented on the Cisco 7000 family of routers and on the Cisco 10000 series router and the Gigabit Switch
Router (GSR) to support ATA disks.
|
12.2(13)T
|
This command was integrated into Cisco IOS Release 12.2(13)T.
|
12.2(14)SX
|
This command was modified. Support for this command was added for the Supervisor Engine 720.
|
12.2(17d)SXB
|
This command was modified. Support for this command on the Supervisor Engine 2 was extended to Release 12.2(17d)SXB.
|
12.2(33)SRA
|
This command was integrated into Cisco IOS Release 12.2(33)SRA.
|
Cisco IOS XE Release 2.1
|
This command was introduced on the Cisco ASR 1000 Series Routers and the following enhancements were introduced:
-
This command was introduced in diagnostic mode for the first time. The command can be entered in both privileged EXEC and
diagnostic mode on the Cisco ASR 1000 series routers.
-
The
/all option was introduced.
-
The
harddisk: ,
obfl: ,
stby-harddisk: ,
stby-usb [0 -1 ]: ,and
usb [0 -1 ]:
filesystem
: options were introduced.
|
15.0(1)M
|
This command was modified. The
/force keyword was added.
|
Usage Guidelines
Supported Platforms Other than Cisco 7600 Series Router
This command performs all steps necessary to remove corrupted files and reclaim unused disk space. Changes include checking
for incorrect file sizes, cluster loops, and so on. The default form of this command issues multiple prompts to confirm each
of the changes. However, you can skip these prompts by using the
/automatic keyword when issuing the command.
When you use the
/automatic keyword you are prompted to confirm that you want the automatic option. Prompts for actions will be skipped, but all actions
performed are displayed to the terminal (see the example below).
This command works with ATA Personal Computer Memory Card Industry Association (PCMCIA) cards formatted in Disk Operating
System (DOS), or for Class C flash file systems.
Note
|
Only one partition (the active partition) is checked in the ATA disk.
|
Cisco 7600 Series Router
The disk0: or slavedisk0: file systems are the only file systems in the Cisco 7600 series routers on which you can run the
File-System-Check ( fsck) utility. The slavedisk0: file system appears in redundant supervisor engine systems only.
This command is valid only on Class C flash file systems and only on PCMCIA ATA flash disks and CompactFlash disks.
The output for the
fsck
slavedisk0: command is similar to the
fsck
disk0: command output.
If you do not enter any arguments, the current file system is used. Use the
pwd command to display the current file system.
If you enter the
disk0: or
slavedisk0: keyword, the fsck utility checks the selected file system for problems. If a problem is detected, a prompt is displayed asking
if you want the problem fixed.
If you enter the
/automatic keyword, you are prompted to confirm that you want the automatic mode. In automatic mode, problems are fixed automatically
and you are not prompted to confirm.
If you do not specify the
/force keyword, any simultaneous file operations on the same device are not terminated. Instead, an error message stating files are
open for read or write access appears. If you specify the
/force keyword, the fsck utility terminates files that are open for read or write access and continues to check for problems.
The table below lists the checks and actions that are performed by the fsck utility.
Table 1. fsck Utility Checks and Actions
Checks
|
Actions
|
Checks the boot sector and the partition table and reports the errors.
|
No action.
|
Validates the media with the signature in the last 2 bytes of the first sector (0x55 and 0xaa, respectively).
|
No action.
|
Checks the os_id to find whether this is a FAT-12 or FAT-16 file system (valid values include 0, 1, 4, and 6).
|
No action.
|
Checks the number of FAT’s field (correct values are 1 and 2).
|
No action.
|
Checks these values:
-
n_fat_sectors cannot be less than 1.
-
n_root_entries cannot be less than 16.
-
n_root_sectors cannot be less than 2.
-
base_fat_sector, n_sectors_per_cluster, n_heads, n_sectors_per_track is not 0.
|
No action.
|
Checks the files and FAT for these errors:
|
Checks the FAT for invalid cluster numbers.
|
If the cluster is a part of a file chain, the cluster is changed to end of file (EOF). If the cluster is not part of a file
chain, it is added to the free list and unused cluster chain. The table below lists valid cluster numbers; numbers other than
those listed in the table below are invalid numbers.
|
Checks the file’s cluster chain for loops.
|
If the loop is broken, the file is truncated at the cluster where the looping occurred.
|
Checks the directories for nonzero size fields.
|
If directories are found with nonzero size fields, the size is reset to zero.
|
Checks for invalid start cluster file numbers.
|
If the start cluster number of a file is invalid, the file is deleted.
|
Checks files for bad or free clusters.
|
If the file contains bad or free clusters, the file is truncated at the last good cluster; an example is the cluster that
points to this bad/free cluster.
|
Checks to see if the file’s cluster chain is longer than indicated by the size fields.
|
If the file’s cluster chain is longer than indicated by the size fields, the file size is recalculated and the directory
entry is updated.
|
Checks to see if two or more files share the same cluster (crosslinked).
|
If two or more files are crosslinked, you are prompted to accept the repair, and one of the files is truncated.
|
Checks to see if the file’s cluster chain is shorter than is indicated by the size fields.
|
If the file’s cluster chain is shorter than is indicated by the size fields, the file size is recalculated and the directory
entry is updated.
|
Checks to see if there are any unused cluster chains.
|
If unused cluster chains are found, new files are created and linked to that file with the name fsck-start
cluster
|
The table below lists the valid cluster numbers. Numbers other than those listed in the table below are invalid numbers.
Table 2. Valid Cluster Numbers
Cluster
|
FAT-12
|
FAT-16
|
Next entry in the chain
|
2-FEF
|
2-FFEF
|
Last entry in chain
|
FF8-FFF
|
FFF8-FFFF
|
Available cluster
|
0
|
0
|
Bad Cluster
|
FF7
|
FFF7
|
Examples
The following example shows sample output from the
fsck command in automatic mode:
Router# fsck /automatic disk1:
Proceed with the automatic mode? [yes] y
Checking the boot sector and partition table...
Checking FAT, Files and Directories...
Start cluster of file disk1:/file1 is invalid, removing file
File disk1:/file2 has a free/bad cluster, truncating...
File disk1:/file2 truncated.
File disk1:/file3 has a free/bad cluster, truncating...
File disk1:/file3 truncated.
File disk1:/file4 has a invalid cluster, truncating...
File disk1:/file4 truncated.
File disk1:/file5 has a invalid cluster, truncating...
File disk1:/file5 truncated.
File disk1:/file6 has a invalid cluster, truncating...
File disk1:/file6 truncated.
File size of disk1:/file7 is not correct, correcting it
File disk1:/file8 cluster chain has a loop, truncating it
File disk1:/file8 truncated.
File disk1:/file9 cluster chain has a loop, truncating it
File disk1:/file9 truncated.
File disk1:/file16 has a free/bad cluster, truncating...
File disk1:/file16 truncated.
File disk1:/file20 has a free/bad cluster, truncating...
File disk1:/file20 truncated.
Reclaiming unused space...
Created file disk1:/fsck-4 for an unused cluster chain
Created file disk1:/fsck-41 for an unused cluster chain
Created file disk1:/fsck-73 for an unused cluster chain
Created file disk1:/fsck-106 for an unused cluster chain
Created file disk1:/fsck-121 for an unused cluster chain
Created file disk1:/fsck-132 for an unused cluster chain
Created file disk1:/fsck-140 for an unused cluster chain
Created file disk1:/fsck-156 for an unused cluster chain
Created file disk1:/fsck-171 for an unused cluster chain
Created file disk1:/fsck-186 for an unused cluster chain
Created file disk1:/fsck-196 for an unused cluster chain
Created file disk1:/fsck-235 for an unused cluster chain
Created file disk1:/fsck-239 for an unused cluster chain
Updating FAT...
fsck of disk1: complete
Examples
This example shows how to run a check of the current file system:
Router# fsck
Checking the boot sector and partition table...
Checking FAT, Files and Directories...
Files
1) disk0:/FILE3 and
2) disk0:/FILE2
have a common cluster.
Press 1/2 to truncate or any other character to ignore[confirm] q
Ignoring this error and continuing with the rest of the check...
Files
1) disk0:/FILE5 and
2) disk0:/FILE4
have a common cluster.
Press 1/2 to truncate or any other character to ignore[confirm] 1
File disk0:/FILE5 truncated.
Files
1) disk0:/FILE7 and
2) disk0:/FILE6
have a common cluster.
.
.
.
1) disk0:/FILE15 and
2) disk0:/FILE13
have a common cluster.
Press 1/2 to truncate or any other character to ignore[confirm] i
Ignoring this error and continuing with the rest of the check...
Reclaiming unused space...
Created file disk0:/fsck-11 for an unused cluster chain
Created file disk0:/fsck-20 for an unused cluster chain
Created file disk0:/fsck-30 for an unused cluster chain
Created file disk0:/fsck-35 for an unused cluster chain
Created file disk0:/fsck-40 for an unused cluster chain
Created file disk0:/fsck-46 for an unused cluster chain
Created file disk0:/fsck-55 for an unused cluster chain
Created file disk0:/fsck-62 for an unused cluster chain
Created file disk0:/fsck-90 for an unused cluster chain
Updating FAT...
fsck of disk0: complete