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 ?