1

Recently we get a lot of kernel messages on our RHEL VM server as:

[Mon Oct 4 11:33:32 2021] EXT4-fs error (device sdb): htree_dirblock_to_tree:914: inode #397095: block 1585151: comm du: bad entry in directory: rec_len is smaller than minimal - offset=0(4096), inode=0, rec_len=0, name_len=0 

so we derided too run fsck automatically with -a option ( after umount of course )

$ fsck -a /dev/sdb fsck from util-linux 2.23.2 /dev/sdb contains a file system with errors, check forced. /dev/sdb: Directory inode 397095, block #1, offset 0: directory corrupted /dev/sdb: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options) 

in spite we declare to use the -a option , fsck insist to not use it

So the last option is to do it manually as

# fsck /dev/sdb fsck from util-linux 2.23.2 e2fsck 1.42.9 (28-Dec-2013) /dev/sdb contains a file system with errors, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Inode 2134692 ref count is 2, should be 1. Fix<y>? yes Unattached inode 2134798 Connect to /lost+found<y>? yes Inode 2134798 ref count is 2, should be 1. Fix<y>? yes Unattached inode 2135050 Connect to /lost+found<y>? yes Inode 2135050 ref count is 2, should be 1. Fix<y>? yes Unattached inode 2135058 Connect to /lost+found<y>? yes Inode 2135058 ref count is 2, should be 1. Fix<y>? yes 

and as we can see above it takes time

Any idea how to force fsck to use -a flag or to run fsck without manual steps ?

1 Answer 1

3

The -a (or -p) option is used to tell fsck to try to fix the filesystem without user interaction, if this is not possible (there is a risk of losing data or further corrupting the filesystem by choosing a wrong option) fsck -a will fail and tell you to run it in manual mode and decide yourself how each error should be fixed.

From e2fsck man page:

Automatically repair ("preen") the file system. This option will cause e2fsck to automatically fix any filesystem problems that can be safely fixed without human intervention. If e2fsck discovers a problem which may require the system ad‐ ministrator to take additional corrective action, e2fsck will 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.

If you want to run fsck completely non-interactively you can use the -y option to answer yes to all question but I would advice against doing that.

1
  • 1
    Could be added that -p is preferred over -a: -a This option does the same thing as the -p option. It is provided for backwards compatibility only; it is suggested that people use -p option whenever possible. Commented Oct 4, 2021 at 12:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.