In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of the Linux basic command e2fsck". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command e2fsck".
Ex2fsck
Check the ext2, ext3, and ext4 file systems. It is not recommended to check if the system is mounted, because it is not safe. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
E2fsck [- pacnyrdfkvtDFV] [- b superblock] [- B blocksize] [- l |-L bad_blocks_file] [- C fd] [- j external-journal] [- E extended_options] device
A device is a device file that stores the file system (for example, / dev/hdc 1).
2. List of options
Option
Description
-a |-p
Automatically repair the file system
-b superblock
Specifies the block size. Instead of using a normal super block, use an alternative super block specified by superblock. This option is usually used when the main superblock is damaged. The location of the backup super block depends on the block size of the file system. For file systems with 1k blocks, you can use backup super blocks. Found at block 8193; for file systems with 2k blocks, at block 16384; for 4k blocks, at block 32768.
Other backup super blocks can be determined by using the mke2fs program to print out the location where the super blocks were created using the-n option. The-b option of mke2fs must specify the block size of the file system in order to print out the exact location of the super block.
If another superblock is specified and the file system is not read-only, e2fsck ensures that the primary superblock is updated appropriately after completing the file system check.
-B blocksize
Normally, e2fsck will search for super blocks under different block sizes in an attempt to find the appropriate block size. In some cases, this search may be fooled. This option forces e2fsck to try to locate the super block only on a specific block size. If the super block is not found, e2fsck ends with a fatal error.
-c
This option causes e2fsck to use the badblock (8) program to perform a read-only scan of the device to find any bad blocks. If any bad blocks are found, add them to the bad block inode to prevent them from being assigned to files or directories. If this option is specified twice, a bad block scan is completed using a lossless read-write test.
-C fd
This option causes e2fsck to write completion information to the specified file descriptor to monitor the progress of file system checks. Programs running e2fsck typically use this option. If the file description symbol is negative, the absolute value of the file descriptor is used, and the progress information is initially suppressed. You can then enable it by sending a SIGUSR 1 signal to the e2fsck process. If the specified file descriptor is 0meme2fsck, a completion column will be printed while its business is in progress. This requires e2fsck to run on the video console or terminal.
-d
Display debugging information
-D
Optimize directories in the file system. This option causes e2fsck to try to optimize all directories by re-indexing them, or sorting and compressing directories with smaller directories, or using traditional linear directories to sort and compress the file system, if the file system supports directory indexing. Even without the-D option, e2fsck can sometimes optimize several directions. For example, you will benefit if catalog indexing is enabled and the catalog does not have an index, or if the index structure is corrupted and needs to be rebuilt. The-D option forces optimization of all directories in the file system. They are smaller and search a little faster, but in fact, you don't need to use this option. The-D option detects directory entries with duplicate names in a single directory, and e2fsck is usually not enforced for performance reasons.
-E extended_options
Set e2fsck extension options. The extension options are comma-separated and can be set using the equal to ('=') sign.
Ea_ver=extended_attribute_version, when checking the file system, set the version of the extended attribute block required by e2fsck. The version number may be 1 or 2. The default extended attribute version format is 2.
Fragcheck, during transmittal 1, prints a detailed report of any discontiguous blocks for files in the file system.
Discard, after a full file system check, attempts to discard free blocks and unused inode blocks.
Nodiscard, do not attempt to discard free blocks and unused inode blocks. This option is the opposite of the discard option. This setting is the default.
-f
Compulsory inspection
-F
Clear the buffer before starting the check
-I file
Specifies that blocks in the file are added to the damage list
-j file
Set the path of the file system in the log file
-k
When combined with the-c option, any existing bad blocks in the bad block list are retained, while any new bad blocks found by running badblocks (8) are added to the existing bad block list.
-l filename
Adds the block number listed in the file specified by the file name to the list of bad blocks. The format of this file is the same as that generated by the badblocks (8) program. Note that the block number is based on the block size of the file system. Therefore, it is easier and safer to use the-c option with e2fsck because it ensures that the correct parameters are passed to the badblock program.
-L filename
Sets the list of bad blocks to the list of blocks specified by the file name. (this option is the same as the-l option, unless you clear the list of bad blocks before adding the blocks listed in the file to the list of bad blocks.)
-n
Open the file system read-only and assume that the answer to all questions is "no". Allow non-interactive use of e2fsck. This option cannot be specified with the-p or-y options.
-p
Automatically repairs ("preen") the file system. This option causes e2fsck to automatically fix any file system problems that can be safely fixed without human intervention. If e2fsck finds a problem that may require additional corrective action by the system administrator, e2fsck prints a description of the problem and exits with code 4. (see the exit code section.) This option is typically used by the system's boot script. It cannot be specified at the same time as the-n or-y option.
-r
Do nothing to provide backward compatibility
-S
Swap the byte order of the file system
-t
Print time statistics for e2fsck. If you use this option twice, additional time statistics are printed as transmitted.
-v
Show the detailed process of execution
-V
Displays the command version number and exits
-y
All interactive replies answer yes, and this option cannot be specified with the-n or-p options.
3. Description
E2fsck is used to check the ext 2/ext 3/ext 4 series file system. For ext 3 and ext 4 file systems that use logs, if the system is uncleanly shut down without any errors, the file system should be marked clean usually after the committed transaction is replayed in the log. Therefore, for file systems that use logs, e2fsck usually replays the logs and exits unless its super block indicates that further inspection is needed.
Note that it is generally not safe to run e2fsck on a mounted file system. The only exception is that the-n option is specified and the-c,-l, or-L options are not specified. However, even if it is safe to do so, the result of e2fsck printing is invalid if the file system is mounted.
4. Return value
E2fsck can return the following values:
There are no mistakes.
1. File system error correction.
2. File system error correction, system should be rebooted.
4. The file system error has not been corrected.
8, operation error.
16, grammatical errors.
32, the user cancelled the operation.
128, shared library error
5. Signal
Send the following signal to e2fsck and produce the corresponding result:
SIGUSR1, this signal causes e2fsck to start displaying the completion bar or sending out progress information. (see discussion of the-C option.)
SIGUSR2, this signal causes e2fsck to stop displaying the completion bar or to send progress information.
6. Examples
Check sda1 read-only
[root@localhost] # e2fsck-n / dev/sda1
E2fsck 1.41.12 (17-May-2010)
Warning! / dev/sda1 is mounted. / / the file system is mounted, so there will be a warning
Warning: skipping journal recovery because doing a read-only filesystem check. / / execute as read-only without repairing
/ dev/sda1: clean, 39/128016 files, 49152/512000 blocks
Thank you for your reading, the above is the content of "the usage of the Linux basic command e2fsck". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command e2fsck, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.