ldiskfsck.static8
Check a linux ext2/ext3/ext4 file system
Usage
e2fsck [-pacnyrdfkvtDFV]
[-b
superblock]
[-B
blocksize]
[{-l | -L
bad_blocks_file}]
[-C
fd]
[-j
external-journal]
[-E
extended_options]
device
Overview
e2fsck is used to check the ext2/ext3/ext4 family of file systems. For ext3 and ext4 filesystems that use a journal, if the system has been shut down uncleanly without any errors, normally, after replaying the committed transactions in the journal, the file system should be marked as clean. Hence, for filesystems that use journalling, e2fsck will normally replay the journal and exit, unless its superblock indicates that further checking is required.
device is the device file where the filesystem is stored (e.g. /dev/hdc1).
Note that in general it is not safe to run e2fsck on mounted filesystems. The only exception is if the -n option is specified, and -c, -l, or -L options are not specified. However, even if it is safe to do so, the results printed by e2fsck are not valid if the filesystem is mounted. If e2fsck asks whether or not you should check a filesystem which is mounted, the only correct answer is ``no''. Only experts who really know what they are doing should consider answering this question in any other way.
Options
-
-a -
This option does the same thing as the
-poption. It is provided for backwards compatibility only; it is suggested that people use-poption whenever possible.
-bsuperblock-
Instead of using the normal superblock, use an alternative superblock specified by superblock. This option is normally used when the primary superblock has been corrupted. The location of the backup superblock is dependent on the filesystem's blocksize. For filesystems with 1k blocksizes, a backup superblock can be found at block 8193; for filesystems with 2k blocksizes, at block 16384; and for 4k blocksizes, at block 32768.
-
Additional backup superblocks can be determined by using the
mke2fsprogram using the-noption to print out where the superblocks were created. The-boption tomke2fs, which specifies blocksize of the filesystem must be specified in order for the superblock locations that are printed out to be accurate.
-
If an alternative superblock is specified and the filesystem is not opened read-only, e2fsck will make sure that the primary superblock is updated appropriately upon completion of the filesystem check.
-Bblocksize-
Normally,
e2fsckwill search for the superblock at various different block sizes in an attempt to find the appropriate block size. This search can be fooled in some cases. This option forcese2fsckto only try locating the superblock at a particular blocksize. If the superblock is not found,e2fsckwill terminate with a fatal error.
-
-c -
This option causes
e2fsckto use badblocks(8) program to do a read-only scan of the device in order to find any bad blocks. If any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or directory. If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test.
-Cfd-
This option causes
e2fsckto write completion information to the specified file descriptor so that the progress of the filesystem check can be monitored. This option is typically used by programs which are runninge2fsck. If the file descriptor number is negative, then absolute value of the file descriptor will be used, and the progress information will be suppressed initially. It can later be enabled by sending thee2fsckprocess a SIGUSR1 signal. If the file descriptor specified is 0,e2fsckwill print a completion bar as it goes about its business. This requires that e2fsck is running on a video console or terminal.
-
-d -
Print debugging output (useless unless you are debugging
e2fsck).
-
-D -
Optimize directories in filesystem. This option causes e2fsck to try to optimize all directories, either by reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories for smaller directories, or for filesystems using traditional linear directories.
-
Even without the
-Doption,e2fsckmay sometimes optimize a few directories --- for example, if directory indexing is enabled and a directory is not indexed and would benefit from being indexed, or if the index structures are corrupted and need to be rebuilt. The-Doption forces all directories in the filesystem to be optimized. This can sometimes make them a little smaller and slightly faster to search, but in practice, you should rarely need to use this option.
-
The
-Doption will detect directory entries with duplicate names in a single directory, which e2fsck normally does not enforce for performance reasons.
-Eextended_options-
Set e2fsck extended options. Extended options are comma separated, and may take an argument using the equals ('=') sign. The following options are supported:
clone=dup|zero-
Resolve files with shared blocks in pass 1D by giving each file a private copy of the blocks (dup); or replacing the shared blocks with private, zero-filled blocks (zero). The default is dup.
shared=preserve|lost+found|delete-
Files with shared blocks discovered in pass 1D are cloned and then left in place (preserve); cloned and then disconnected from their parent directory, then reconnected to /lost+found in pass 3 (lost+found); or simply deleted (delete). The default is preserve.
ea_ver=extended_attribute_version-
Set the version of the extended attribute blocks which
e2fsckwill require while checking the filesystem. The version number may be 1 or 2. The default extended attribute version format is 2.
inode_badness_threshold=threshold_value-
A badness counter is associated with every inode, which determines the degree of inode corruption. Each error found in the inode will increase the badness by 1 or 2, and inodes with a badness at or above threshold_value will be prompted for deletion. The default threshold_value is 7.
fragcheck-
During pass 1, print a detailed report of any discontiguous blocks for files in the filesystem.
-
-f -
Force checking even if the file system seems clean.
-
-F -
Flush the filesystem device's buffer caches before beginning. Only really useful for doing
e2fscktime trials.
-jexternal-journal-
Set the pathname where the external-journal for this filesystem can be found.
-
-k -
When combined with the
-coption, any existing bad blocks in the bad blocks list are preserved, and any new bad blocks found by running badblocks(8) will be added to the existing bad blocks list.
-lfilename-
Add the block numbers listed in the file specified by filename to the list of bad blocks. The format of this file is the same as the one generated by the badblocks(8) program. Note that the block numbers are based on the blocksize of the filesystem. Hence, badblocks(8) must be given the blocksize of the filesystem in order to obtain correct results. As a result, it is much simpler and safer to use the
-coption toe2fsck, since it will assure that the correct parameters are passed to thebadblocksprogram.
-Lfilename-
Set the bad blocks list to be the list of blocks specified by filename. (This option is the same as the
-loption, except the bad blocks list is cleared before the blocks listed in the file are added to the bad blocks list.)
-
-n -
Open the filesystem read-only, and assume an answer of `no' to all questions. Allows
e2fsckto be used non-interactively. (Note: if the-c,-l, or-Loptions are specified in addition to the-noption, then the filesystem will be opened read-write, to permit the bad-blocks list to be updated. However, no other changes will be made to the filesystem.) This option may not be specified at the same time as the-por-yoptions.
-
-p -
Automatically repair ("preen") the file system. This option will cause
e2fsckto automatically fix any filesystem problems that can be safely fixed without human intervention. Ife2fsckdiscovers a problem which may require the system administrator to take additional corrective action,e2fsckwill print a description of the problem and then exit with the value 4 logically or'ed into the exit code. (See the EXIT CODE section.) This option is normally used by the system's boot scripts. It may not be specified at the same time as the-nor-yoptions.
-
-r -
This option does nothing at all; it is provided only for backwards compatibility.
-
-t -
Print timing statistics for
e2fsck. If this option is used twice, additional timing statistics are printed on a pass by pass basis.
-
-v -
Verbose mode.
-
-V -
Print version information and exit.
-
-y -
Assume an answer of `yes' to all questions; allows
e2fsckto be used non-interactively. This option may not be specified at the same time as the-nor-poptions.
--mdsdbmds_database_filename-
Specify which file to use for an MDS database on a Lustre filesystem. The mdsdb also needs to be specified when creating an OST database with
--ostdbbut the mdsdb file used in a read-only manner.
--ostdbostN_database_filename-
Specify which file to use for an OST database on a Lustre filesystem. A separate database file should be specified for each OST device in the filesystem. For convenience a stub
mdsdb.hdr file is generated for use by the OST e2fsck to avoid the need to wait for the MDS e2fsck to finish or copy the full mdsdb to the OSTs.
Exit code
The exit code returned by e2fsck is the sum of the following conditions:
0 - No errors
1 - File system errors corrected
2 - File system errors corrected, system should
be rebooted
4 - File system errors left uncorrected
8 - Operational error
16 - Usage or syntax error
32 - E2fsck canceled by user request
128 - Shared library error
Signals
The following signals have the following effect when sent to e2fsck.
SIGUSR1-
This signal causes
e2fsckto start displaying a completion bar or emitting progress information. (See discussion of the-Coption.)
SIGUSR2-
This signal causes
e2fsckto stop displaying a completion bar or emitting progress information.