Learn a Linux command every day (81): e2fsck

Time:2022-2-14

Recommended reading:Learn a Linux command every day (76): fsck

Command introduction

The e2fsck command is used to check ext2 / ext3 / ext4 file systems.

Syntax format

e2fsck [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
  [-I inode_buffer_blocks] [-P process_inode_size]
  [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
  [-E extended-options] device

Option description

-D # display debug debugging information
-T # displays time information
-P # without prompting, the file system will be repaired automatically
-N # turn on the file system in read-only mode
-Y # takes a non interactive way to execute, and all prompts are confirmed with "yes"
-C # executes badblocks to mark the damaged blocks
-F # mandatory inspection
-V # display details
-B # superblock # set the position of # superblock
-B # blocksize # specifies the size of the block in bytes
-j external_ Journal # sets where to find the pathname of the external log of this file system
-l bad_ blocks_ File # adds the block specified in the file to the list of damaged blocks
-L bad_ blocks_ File # first clears the list of damaged blocks, and then adds the blocks specified in the file to the list of damaged blocks
-C < < file descriptor > # completely records the information of the inspection process in the file descriptor, so that the whole inspection process can be completely monitored.

After the e2fsck command is executed, the returned value and meaning are as follows

0 # no errors occurred
1 # file system error and has been fixed
2 # a file system error has occurred and has been fixed
4 # file system error, but not fixed
8 # operation error
16 # error in syntax used
128 # shared library error

Application examples

Check the file system of disk partition / dev / SDB

[[email protected] ~]# e2fsck /dev/sdb
e2fsck 1.42.9 (28-Dec-2013)
/dev/sdb: clean, 11/655360 files, 83137/2621440 blocks

Check the file system of disk partition / dev / SDB and repair the file system automatically

[[email protected] ~]# e2fsck -p /dev/sdb

Learn a Linux command every day (74): host

Learn a Linux command every day (75): Mount / umount

Learn a Linux command every day (77): DD

Learn a Linux command every day (78): fdisk

Learn a Linux command every day (79): parted

Learn a Linux command every day (80): mkfs