In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the usage of Linux basic command fsck". In daily operation, I believe many people have doubts about the usage of Linux basic command fsck. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of Linux basic command fsck"! Next, please follow the editor to study!
Fsck
Check or repair the specified file system, which can be a device name, mount point, an ext2 label, or a UUID. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Fsck [options]-t systype device
Fsck [- sAVRTMNP] [- C [fd]] [- t fstype] [filesys...] [- -] [fs-specific-options]
2. List of options
Option
Description
S
The sequence of checks. If you have more than one file system to check, do it sequentially. Note: e2fsck (8) runs in interactive mode by default. For e2fsck (8) to run in non-interactive mode, you must specify the-p or-an option, and if you want to automatically correct errors, you must specify the-n option.
-t fslist
Specifies the type of file system to check. When the-A flag is specified, only the file systems that match the fslist are checked. The fslist parameter is a comma-separated list of file systems and option descriptors. All file systems in this comma-separated list may use the negative operator "no" or "!" As a prefix, this operator requires that only file systems that are not listed in fslist be checked. If all file systems in fslist are not prefixed with negative operators, only the file systems listed in fslist will be checked.
Option specifiers may be contained in a comma-separated fslist. They must have the format "opts=s-option". If there is an option specifier, only file systems that contain s-option in the mount options field of "/ etc/fstat" are checked. If the option specifier is prefixed with a negative operator, then only those file systems that do not have fs-option will be selected. It will be checked in their mount options field "/ etc/ffstab". For example, if "opts=ro" appears in fslist, only the file systems listed in "/ etc/fstab" with the ro option will be checked.
To be compatible with the Mandrake distribution, its boot script relies on unauthorized ui changes to fsck programs, and if a loop of file system type is found in fslist, it is treated as a parameter that specifies opts=loop as the-t option.
Typically, the file system type is inferred by searching for files in the "/ etc/fstab" file and using the corresponding entries. "if the type cannot be inferred, and there is only one file system as an argument to the-t option, fsck uses the specified file system type." If the type is not available, the default file system type (current Ext 2) is used.
A
Walk through the "/ etc/fstab" file and try to check all file systems in one run. This option usually comes from the "/ etc/rc" system initialization file, rather than multiple commands used to check a single file system. Unless the-P option is specified (see below), the root file system is checked first. The file system is then checked in in the order specified in the fs_passno (sixth) field in the "/ etc/fstab" file. File systems with a fs_ passno value of 0 are skipped, and file systems with a fs_passno value greater than zero are checked. If multiple file systems have the same pass number, fsck will try to check them in parallel, although it will avoid running multiple file system checks on the same physical disk.
Fsck does not check stacking devices in parallel with any other devices. Therefore, a very common configuration in the "/ etc/fstab" file is to set the root file system to the fs_ passno value of 1 and all other file systems to the fs_ passno value of 2. If for some reason you need to avoid multiple file system checks running in parallel, choose not to use this configuration. For example, if the machine in question is out of memory, so too much paging can cause concern.
Fsck usually does not check whether the device actually exists before calling the inspector of the file system. Therefore, if a file system specific inspector returns a fatal error, a device that does not exist may cause the system to enter file system repair mode during boot. The "/ etc/fstab" mount option does not fail and allows fsck to skip devices that do not exist. Fsck also skips non-existent devices with a special file system type AUTO.
-C [fs]
Displays the progress of the inspection. Displays the completion / progress bar that supports these file system checkers (currently used only for ext 2 and ext 3). Fsck manages file system inspectors so that only one progress bar is displayed in them at a time. The gui front end can specify the file descriptor fd, in which case the progress bar information is sent to the file descriptor.
-M
Do not check the mounted file system and return the exit code 0 for the mounted file system.
-N
No check operation is performed, just a demonstration
-P
When the-A flag is set, the root file system is checked in parallel with other file systems. This is not the safest thing in the world, because if the root file system suspects that the e2fsck (8) executable may be corrupted! This option is mainly for system administrators who do not want to repartition the root file system into small and compact (which is the really right solution).
-R
Skip the root file system when checking all file systems with the-a flag
-T
Do not display the title at startup
-V
Show execution process
Fs-specific-options
Options that fsck does not understand are passed to file system-specific inspectors. These parameters cannot be used because fsck cannot correctly guess which parameters can choose options and which parameters cannot. The following options and parameters are treated as file system-specific options to be passed to the file system-specific inspector.
Note that fsck is not designed to pass arbitrarily complex options to file system-specific inspectors. If you are doing something complex, execute a file system-specific checker directly. If you pass fsck some very complex options and parameters and it doesn't work as you expected, don't report it as bug. You're almost certainly doing something you shouldn't have done with fsck.
The options for specific fsck for different file systems are not standardized. If in doubt, refer to the man page of the file system-specific inspector. Although there is no guarantee, most file system checkers support the following options
-a
Automatically repairs the file system. Note that e2fsck (8) only supports backward compatibility. This option maps to the-p option of e2fsck, which is secure unlike the-an option supported by some file system inspectors.
-n
For some file system-specific inspectors, the-n option will cause fs-specific fsck to avoid trying to fix any problems, but simply report such problems to stdout. However, this is not the case with all file system-specific checkers. In particular, given this option, fsck.reiserfs (8) will not report any damage. Fsck.minix (8) does not support the-n option at all.
-r
Repair the file system interactively (request confirmation). Note: if multiple fsck runs in parallel, it is usually a bad idea to use this option. Also note that this is the default behavior of e2fsck; it supports this option only for backward compatibility reasons.
-y
For some file system-specific inspectors, the-y option will cause fs-specific fsck to always attempt to automatically repair any detected file system corruption. Sometimes experts may be better able to manually drive fsck. Note that not all file system-specific inspectors implement this option. In particular, the-y option is not supported by fsck.minix (8) and fsck.lamfs (8).
3. Description
If no file system is specified on the command line and the-An option is not specified, fsck will check the file system in / etc/fstat serially by default. The fsck instruction can have the following return value:
There are no mistakes.
1. File system error correction.
2. The system should restart.
4. The system error has not been corrected.
8, operation error.
16, grammatical errors.
32, the user cancels the fsck.
128, shared library error.
The exit code returned when multiple file systems are checked is the bitwise OR of the exit code for each file system being checked.
In fact, fsck is just the front end of the various file system checkers (fsck.fstype) available under linux. File system-specific inspectors search first in / sbin, then in / etc/fs and / etc, and finally in the directories listed in the PATH environment variable.
4. Environmental variables
The execution of fsck is affected by the following environment variables:
1) FSCK_FORCE_ALL_PARALLEL, if this environment variable is set, fsck will try to run all specified file systems in parallel, regardless of whether the file system is on the same device or not. (this is useful for RAID systems or high-end storage systems, such as those sold by companies such as IBM or EMC.) Notice that the fs_ passno value is still used.
2) FSCK_MAX_INST, this environment variable limits the maximum number of file system checkers that can be run at a time. This allows a configuration with a large number of disks to prevent fsck from starting too many file system inspectors at a time, which may overload available CPU and memory resources on the system. Is zero, an unlimited number of processes can be generated. This is the current default, but future versions of fsck may attempt to automatically determine how many file system checks can be run based on the collection of accounting data from the operating system.
3) the PATH,PATH environment variable is used to find the file system inspector, first searching a set of system directories: / sbin, / sbin/fs.d, / sbin/fs, / etc/fs, and / etc/fs, and then searching for a set of directories in the path environment.
4) FSTAB_FILE, an environment variable that allows system administrators to override the standard location of the / etc/fstab file, is also useful for developers who are testing fsck.
5. Examples
Check sdb4
[root@localhost] # [root@localhost] # fsck-t swap / dev/sdb4
Fsck from util-linux-ng 2.17.2
E2fsck 1.41.12 (17-May-2010)
/ dev/sdb4 was not cleanly unmounted, mandatory check.
Resize inode not valid. reconstruction? Yes
Step 1: check inode, block, and size
Step 2: check the directory structure
Step 3: check directory connectivity
Pass 4: Checking reference counts
Step 5: check the cluster profile information
Free block s count wrong for cluster # 0 (7854, counted=7855).
Deal with it? Yes
Free block s count wrong (15722, counted=15723).
Deal with it? Yes
/ dev/sdb4: * File system has been modified *
/ dev/sdb4: 11 non-contiguous 4096 files (0.0% non-contiguous), 661 plus 16384 blocks
[root@localhost ~] #
At this point, the study of "the usage of the Linux basic command fsck" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.