FreeBSD : zapping file system error

My box crashed many times last week until its file system had inconsistency issue. In another words, it is corrupted. Even manual fsck won’t help fixing the issue. The problem appeared to be a directory had its “.” file missing!! Whenever I tried to remove the directory, “rm” with force option or “rmdir” utilities just complained about “bad file descriptor” and did nothing! Shit happened… Log is showing the error.
Aug 22 13:20:11 zeus fsck: /dev/label/usr: SETTING DIRTY FLAG IN READ_ONLY MODE
Aug 22 13:20:11 zeus fsck:
Aug 22 13:20:11 zeus fsck: /dev/label/usr: UNEXPECTED SOFT UPDATE INCONSISTENCY; RUN fsck MANUALLY.
Aug 14 03:15:18 zeus fsck: /dev/label/usr: 551052 files, 6960462 used, 14873313 free (244305 frags,
1828626 blocks, 1.1% fragmentation)
The solution is rather simple. Just use a handy utility, clri(8), to clear the corrupted inode. Reboot the box into single user mode and run fsck_ufs -y /dev/label/usr. fsck(8) will provide you the inode number which is corrupted.
Its usage is simple
clri special_device inode_number
In my case (i have geom_label. Thus, you are seeing /dev/label/usr here.):-
clri /dev/label/usr 5111832
Exit single user mode, login as usual and run “rm” or “rmdir” to remove the directory. Voila! A word of advice, messing around with inode is the least thing that you want to do. In any case, BACK UP YOUR STUFF BEFORE YOU ATTEMPT ANYTHING. YOU ARE WARNED!



