Server hard disks often show degraded performance due to file system errors. And, utilities like fsck is of great help in correcting the errors.
But, what if the utility itself report errors ? A typical error message appears as “fsck: error 2 (No such file or directory)“. Many times, this error happens due to missing fsck program in the server.
At 1onlyhost, we often see such fsck errors as part of our periodic server audits under Server Management Services.
Today, we’ll see the various reasons for “fsck error 2” and how our Dedicated Engineers solve it.
More details on FSCK
Website requests involve frequent reads and writes to/from the hard disk. As a result, it can often cause disk errors.
Verifying integrity of server hard disk periodically avoid potential website down issues. And, fsck (file system consistency check) utility comes as a boon to server administrators. In production servers, they schedule fsck automatically during boot time or at periodic intervals.
As fsck involves hard disk configuration directly, it always need a sound knowledge of the various disk partitions on the server. Therefore, our Support Engineers do a detailed study of hard disk partitions prior to any check. To check the consistency of a drive, say /dev/sda6, we execute the command:
fsck /dev/sda6
Fortunately, fsck command return couple of error codes depending on the results of the check. A typical operational error shows as:
"fsck: error 2 (No such file or directory) while executing fsck.ext4 for /dev/sdb1 fsck exited with status code 8"
What causes fsck error 2 ?
Now, its time to see the typical reasons for the “fsck error 2“. The exact reason can vary in different servers.
1. Missing fsck program
Missing fsck program often causes fsck errors. Usually, the fsck utility lies at the /sbin folder of the server. But, due to corrupt server binaries, or malformed packages, the fsck binary can be missing on the servers.
2. Typo in boot settings
Similarly, typo errors in specifying the boot settings may also result in fsck errors. The drive names should be always correct in boot settings of the server. For instance, while selecting to boot Ubuntu from a non-existing drive /dev/sbd, it results in fsck errors too.
Possible fixes for fsck error 2
We just saw two reasons for the fsck error. Now, we’ll see the fixes that our Dedicated Engineers apply on the server.
1. Correcting binary path
Recently, one of our customers reported error while executing fsck on an ntfs partition of his server. He was getting the following error message.
fsck: fsck.ntfs: not found
fsck: error 2 while executing fsck.ntfs for /dev/sda2
On checking the server, we found that there was no fsck.ntfs under /sbin. Therefore, we had to create a symbolic link by executing:
ln -s /bin/ntfsfix /sbin/fsck.ntfs
2. Update initramfs
Again, when a customer had trouble booting up his fresh installed Ubuntu server, we solved it by updating initramfs on the server. The initramfs is a complete set of directories as in a normal root filesystem.
We first verified the boot settings on the server. Then, our Dedicated Engineers solved the problem by getting into Recovery mode from GRUB of the server.
At the Root Prompt of the server, we executed:
mount -o remount,rw /
We, then ran the command to update initramfs :
update-initramfs -c -k
Finally, restarted server using:
shutdown -r now
This booted the server correctly and solved the error.
[Finding fsck errors on the server? Our Server Experts can solve and correct your server.]
Conclusion
Precisely, “fsck error 2″ happens due to broken or missing binary, typo errors while executing file system check etc. Today, we saw the reasons for the error and how our Dedicated Engineers fix it.