FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
-------------------------------------------------------------------------------
fsck, dfsck
PURPOSE
Interactively checks consistency and repairs a file system.
SYNTAX
+--------+ +---------------------+ +-------------+ +---------------+
fsck ---| one of |-| +- -s cyl : skip -+ |-| +---------+ |-| |-->
| +----+ | +-| |-+ +-| -f |-+ +- -b blocknum -+
+-| -y |-+ +- -S cyl : skip -+ A| -t file || A |
| -n | |+---------+| +-------------+
| -p | +-----------+
+----+
+------+ +---------------+ +-----------+ +--------------+
>---| 1|---| |---| |---| 2|---|
+- -c -+ +- -d blocknum -+ +- -i inum -+ +- filesystem -+
^ | ^ | ^ |
+-------------+ +---------+ +------------+
+-------------+ 2 +-------------+
dfsck ---| |-- filesystem -- - --| |-- filesystem2 --|
+- flaglist1 -+ +- flaglist2 -+
-----------------
1 The default action is to check every file system with the attribute
check=true in the file /etc/filesystems.
2 Use a minus (-) to separate the groups when you specify flags as part of
the argument.
DESCRIPTION
Warning: Always run the fsck command on file systems after a system crash.
Corrective actions may result in some loss of data. If you have write
permission, the system responds with "yes" or "no". If you do not have write
permission for an affected file, the fsck command defaults to a "no" response
in spite of your actual response.
Since the fsck command rearranges data on the file system, do not run this
command on a mounted file system unless you specify the -n flag. Otherwise,
fsck could damage your file system beyond repair.
The fsck command checks and interactively repairs inconsistent filesystems. It
should be run on every file system as part of system initialization (see "rc").
Processed November 8, 1990 FSCK, DFSCK(8,C) 1
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
You must have superuser authority to run the fsck command. Normally, the file
system is consistent, and the fsck command merely reports on the number of
files, used blocks and free blocks in the file system. If the filesystem is
inconsistent, the fsck command displays information about the inconsistencies
found and prompts you for permission to repair them. The fsck command is
conservative in its repair efforts and tries to avoid actions that might result
in the loss of valid data. In certain cases, however, the command recommends
the destruction of a damaged file.
If you do not specify filesystem, the fsck command looks at the file
/etc/filesystems to find a list of file systems to check by default. fsck can
perform checks (on separate arms) in parallel (running in parallel processes).
This type of checking can reduce the time required to check a large number of
file systems.
In the file /etc/filesystems, automatic checking may be enabled by adding a
line in the stanza, as follows:
check=true
If you specify the -p flag, the fsck command can perform multiple checks at the
same time. To tell this command which file systems are on the same drives,
change the check specification in the file /etc/filesystems to the following:
"check="number
The number tells the fsck command which group contains a particular file
system. File systems on a single drive are placed in the same group. Each
group is checked in a separate parallel process. File systems are checked, one
at a time, in the order that they appear in the file /etc/filesystems. All
"check=true" file systems are in group 1. The fsck command attempts to check
the root file system before any other file system regardless of the order
specified on the command line or in the file /etc/filesystems.
On input and output fsck uses units of 4096 bytes for block numbers.
The fsck command checks for the following inconsistencies:
o Blocks allocated to multiple files or to a file and the free list.
o Blocks allocated to a file or on the free list outside the range of
allowable block numbers.
o Discrepancies between the number of directory references to a file and the
link count in the file.
o Size checks:
- Incorrect number of blocks.
- Directory size not 16-byte aligned.
o Bad inode format.
Processed November 8, 1990 FSCK, DFSCK(8,C) 2
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
o Blocks not accounted for anywhere.
o Directory checks:
- File pointing to an inode that is not allocated.
- Inode number out of range.
- Dot (.) link missing or not pointing to itself.
- Dot dot (..) link missing or not pointing to the parent directory.
- Files that are not referenced or directories that are not reachable.
o Superblock checks:
- More than 65536 inodes.
- More blocks for inodes than there are in the file system.
o Bad free-block list format.
o Total free block and/or free inode count incorrect.
o If Transparent Computing Facility (TCF) is installed:
- Low high-water mark.
- Missing commit counts in the superblock list.
- Gaps in the commit count array of the superblock.
- Duplicate commit counts in the superblock array.
Orphaned files and directories (those that cannot be reached) are, if you
allow, reconnected by placing them in the lost+found subdirectory in the root
directory. The name assigned is the inode number. The only restriction is
that the directory lost+found must already exist in the root directory of the
file system being checked and must have empty slots in which entries can be
made (accomplished by copying a number of files to the directory and then
removing them before you run the fsck command). If you do not allow the fsck
command to reattach an orphaned file, it requests permission to destroy the
file.
The fsck command records the outcome of its checks and repairs through its exit
values. The return codes signal the following conditions:
0 All checked file systems are now okay.
1 Invalid arguments given.
2 fsck was interrupted before it could complete the checks.
4 fsck changed the mounted file system; the user must restart the system
immediately.
8 The file system contains unrepaired damage.
16 System resource error.
When the system is being started up normally, the fsck command should be run
with the -p flag from /etc/rc. (See "rc.") If the fsck -p command detects and
repairs errors on a file system to be mounted, it displays a message on the
console. If errors are detected that it cannot repair, it displays appropriate
Processed November 8, 1990 FSCK, DFSCK(8,C) 3
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
messages on the console and exits, causing init to halt operation after
displaying its own message on the screen.
dfsck
The dfsck command lets you check two file systems simultaneously on two
different drives. Use the flaglist1 and flaglist2 arguments to pass flags and
parameters for the two sets of file systems. Use a - (minus) to separate the
file system groups if you specify flags as part of the arguments.
The dfsck command permits you to interact with two fsck commands at once. To
aid in this, the dfsck command displays the file system name with each message.
When responding to a question from the dfsck command, you must prefix your
response with a 1 or 2 to indicate whether the answer refers to the first or
second file system group.
Note: Do not use the dfsck command to check the root file system /dev/root.
FLAGS
-bblocknum The blocknums parameter is a list of block numbers separated by
blanks. fsck will print out the inode number of all files for
which a block specified is allocated. Blocks are in the file
system blocksize, which is 4096 bytes on both AIX/370 and
AIX/PS2.
-c Instructs the fsck command to use the devices specified on the
command line and not the raw devices.
-dblocknum Searches for references to a specified disk block. Whenever the
fsck command encounters a file that contains a specified disk
block, it displays the inode number and all path names that
refer to it. Specify block numbers in 4096 byte units. Only
inodes referring to the individual block number are flagged by
error messages. This option does not add the blocks to inode 1.
-f Performs a fast check. Under normal circumstances, the only
file systems likely to be affected by halting the system without
shutting down properly are those that were mounted when the
system stopped. The -f flag tells the fsck command not to check
file systems that were cleanly unmounted. The fsck command
determines this by inspecting the s_fmod flag in the file system
superblock. This flag is set whenever a file system is mounted
and cleared when it is cleanly unmounted. If a file system was
cleanly unmounted, it is unlikely to have any problems. Since
most file systems are cleanly unmounted, not checking those file
systems can reduce the checking time.
-iinum Searches for references to a specified inode. Whenever the fsck
command encounters a directory reference to a specified inode
number, it displays the full path name of the reference.
Processed November 8, 1990 FSCK, DFSCK(8,C) 4
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
-n Assumes a "no" response to all questions asked by the
fsckcommand; does not open filesystem for writing.
-p Does not display messages about minor problems, but fixes them
automatically. This flag does not grant the wholesale license
that the -y flag does and is useful for performing automatic
checks when the system is to be started normally. You should
use this flag whenever the fsck command is being run
automatically as part of the system startup procedures.
When the fsck -p command is run, the following inconsistencies
are corrected automatically:
o Unreferenced inodes
o Link counts that are too large
o Missing blocks or bad blocks in the free list
o Blocks in the free list that are also in files
o Counts in the superblock that are wrong (total free inode
and free block counts), specified in 4096K byte limits.
o Low high-water mark in the superblock (if TCF is installed)
o Missing commit counts in the superblock list (if TCF is
installed)
o Gaps in the superblock commit-count list (if TCF is
installed)
If fsck -p encounters any other inconsistencies, it exits with
an abnormal return status. You can then run fsck manually to
correct the problems that exist on the file system.
If TCF is installed, the fsck command is extended to
automatically handle conditions specific to TCF file systems as
a result of commit and primary-copy replication. When a
non-primary copy of a primary-copy-replicated file system is
checked, the fsck command skips several of its internal passes,
and it avoids checking path names, reference counts, and
connectivity, since a non-primary copy need not store the parent
directory of every file that it stores.
-s[cyl:skip] Ignores the actual free list and unconditionally reconstructs a
new one. You can specify an optional interleave specification
with this flag, cyl to specify the number of blocks per cylinder
and skip to specify the number of blocks to skip. If you do not
specify cyl or skip, the fsck command uses the interleave
parameters in the superblock. The file system should be
unmounted while this is done; if this is not possible, be sure
that you are running no programs and that you perform a system
restart immediately afterwards so that the old copy of the
superblock in memory is not written to disk.
-S[cyl:skip] Conditionally reconstructs the free list. This flag is like the
-s flag except that the free list is rebuilt only if there are
no discrepancies discovered in the filesystem. Using -S forces
Processed November 8, 1990 FSCK, DFSCK(8,C) 5
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
a "no" response to all questions asked by the fsck command. Use
this flag to force free list reorganization on uncontaminated
file systems.
-tfile Uses file as a scratch file if the fsck command cannot obtain
enough memory to keep its tables. If you do not specify the -t
flag and the fsck command needs a scratch file, it prompts you
for the name of the scratch file. However, if you have
specified the -p flag, the fsck command fails. The file chosen
must not be on the file system being checked. If it is not a
special file, it is removed when the fsck command ends.
-y Assumes a "yes" response to all questions asked by the fsck
command. This lets the fsck command take any action that it
considers necessary. Use this flag only on severely damaged
file systems.
EXAMPLES
1. To check all the default file systems:
fsck
This command checks all the file systems marked "check=true" in the file
/etc/filesystems. This form of the fsck command asks you for permission
before making any changes to a file system.
2. To fix minor problems with the default file systems automatically:
fsck -p
3. To check a specific file system:
fsck /dev/hd1
This command checks the unmounted file system located on the device
"/dev/hd1".
4. To simultaneously check two file systems on two different drives:
dfsck -p /dev/hd1 - -p /dev/hd7
This command checks both file systems simultaneously, if the file systems
on the devices "/dev/hd1" and "/dev/hd7" are located on two different
drives. You can also specify the file system names that are found in the
/etc/filesystems file.
FILES
/etc/filesystems Contains the default list of file systems to check.
Processed November 8, 1990 FSCK, DFSCK(8,C) 6
FSCK, DFSCK(8,C) AIX Commands Reference FSCK, DFSCK(8,C)
RELATED INFORMATION
See the following commands: "rc," "fsdb," "istat," "mkfs," "ncheck," and
"shutdown."
See the filesystems and fs files in AIX Operating System Technical Reference.
See the discussion of the fsck and dfsck commands in Managing the AIX Operating
System
Processed November 8, 1990 FSCK, DFSCK(8,C) 7