fsck: exec fsck_ext2fs : No such file or directory

chris (2006-05-03 13:33:05)
15895 views
2 replies
There is a bug in FreeBSD which affects systems with mounted ext2 filesystems. Apparently this bug is a long standing issue which exists in freebsd 6.0 too. The effect is that the system halts on boot because it wants to fsck all partitions. This causes the system to drop into a safe mode shell awaiting user intervention. This leaves the system unaccessable until a manual fsck is carried out.

The cause for this has something to do with the unmount process at shutdown. It seems that ext2 filesystems aren't properly unmounted. I popped some relevant criteria into Yahoo! search and sure enough there are people out there facing this issue.

There are various work arounds, mostly written for the posix shell. I have done one in bash (just because I was a linux user yesterday :)) This script is then referenced from /etc/rc.shutdown. This is how it looks:
#!/usr/local/bin/bash

printf "nunmounting linux filsystemsn"
for i in `mount | grep ext2 | cut -f1 -d' '`
do
        umount -f $i
done

So I implemented this and just tried running it from the shell. Sure enough the linux partitions were unmounted:
brezhnev# df
Filesystem  1K-blocks    Used    Avail Capacity  Mounted on
/dev/ad0s1a   2434920   81536  2158592     4%    /
devfs               1       1        0   100%    /dev
/dev/ad0s1e  33410636      42 30737744     0%    /home
/dev/ad0s1d   2417038 2036174   187502    92%    /usr

However, when I rebooted the machine it still hung at the fsck_ext2fs stage. Crazy! My first instinct was to try fsck'ing manually to see if that runs okay:
brezhnev# /sbin/fsck_ext2fs /dev/ad3s1
/sbin/fsck_ext2fs: Command not found.

hmm - there's a clue. Lets try which, whereis and apropos:
brezhnev# which fsck_ext2fs
fsck_ext2fs: Command not found.
brezhnev# whereis fsck_ext2fs
fsck_ext2fs:
brezhnev# apropos fsck_ext2fs
fsck_ext2fs: nothing appropriate

So it looks like I need to install something. We're getting warmer. Searching on http://www.freshports.org/ for e2fsprogs reveals the following:
e2fsprogs 1.38_2 / sysutils search for ports that depend on this port
    Utilities and library to manipulate ext2/ext3 filesystems
    Maintained by: matthias.andree@gmx.de search for ports maintained by this maintainer

    CVSWeb : Sources : Main Web Site : PortsMon

    To install the port: cd /usr/ports/sysutils/e2fsprogs/ && make install clean
    To add the package: pkg_add -r e2fsprogs

So there it is with a simple one-liner for installing the port. This means that if the sources aren't there, they will be downloaded from a registered mirror and then the package will be compiled on the local system. This will provide a number of utilities for managing ext2 and ext3 filesystems.

Once the port was installed, I tried to run a fsck locally just to try the new package out:
brezhnev# /usr/local/sbin/fsck_ext2fs -y /dev/ad3s1
execve: No such file or directory

I don't know what's causing that so I'm going to try with the e2fsck utility instead. It looks like the file installed was: /usr/local/sbin/e2fsck. Let's try that out:
brezhnev# /usr/local/sbin/e2fsck -y /dev/ad3s1
e2fsck 1.38 (30-Jun-2005)
/dev/ad3s1: clean, 10/7520256 files, 235992/15012892 blocks

Well that's good, but it's kinda odd, because when the system boots, it attempts to fsck with fsck_ext2fs from /sbin or /usr/sbin - Neither exists, which is the source of the problem. So all we need to do here is create a symbolic link from /usr/local/sbin/e2fsck to /sbin/fsck_ext2fs.

Once the symbolic link was in place, I rebooted.... but still the same problem occurred. I tried moving the link into /usr/sbin, rebooted again ... and again, the problem perisited. Every reboot just hangs because the system seems unable to find the right fsck utility for ext2fs:
fsck: exec fsck_ext2fs for /dev/ad1s1 in /sbin:/usr/sbin: No file or directory.

My last attempt at fixing this issue is to tell the system not to fsck at all. Alex Zbyslaw on the freeBSD mailing list suggests just disabling the pass by setting the 'pass' parameter to 0 for the linux filesystems listed in the fstab. I tried that and...

Bingo. The system booted straight through to a prompt, with all the disks mounted as required. I remain somewhat bemused and irritated that the problem wasn't actually solved, but at least a work around is in place for now.

christo
comment
r_a_f
2010-03-20 11:57:57

Thanks!


pkg_add -r e2fsprogs
brezhnev# /usr/local/sbin/e2fsck -y /dev/ad3s1
e2fsck 1.38 (30-Jun-2005)

This is it. I couldn't mount my linux partition. And that is rock it!

Good Job And thanks again! :)
reply iconedit reply
Deepak
2014-06-18 12:59:51

Well since long time

Well since long time passed since your blog post this plrabboy is not relevant anymore.If during the scan fsck was fixing some inconsistencies (not just removing unused blocks) then you might want to add background_fsck= NO to your /etc/rc.confThe goal of SoftUpdates is reorganize writes in such order that any power failure will result mostly in unnecessarily allocated blocks and no data ever will be lost. The whole point of background fsck is to reclaim those blocks.The problem is with drives which increase performance by reordering writes (most often through write cache) when that happens all hard work done through SoftUpdates is lost and it is possible for drive to be in inconsistent state.If that happens and you have background fsck enabled, you might miss any idications that there's something wrong with filesystem and by using inconsistent FS you might increase chances of data loss
reply iconedit reply