Wednesday, August 12, 2009

Error in Linux Bad File Descriptor


In a Linux system, files, blocks, directories, sockets and other items are referred by corresponding file descriptors. If your system have errors like file descriptor is bad, one of possible causes is that file system is corrupt and thus you required restoring from backup. If backup is not valid enough to restore complete information, you need to use advanced data recovery Linux applications.
You might encounter the below error message with your Linux based system:

“Bad file descriptor”

You might receive this error while trying to access a file or while trying to boot the system.

Possible reasons for the ‘Bad file descriptor’ error to occur are:

Linux systems use a special file, called /dev/null (also called the null device). This file removes all the data that is written to it after reporting that the write process has successfully succeeded. You might receive the above error message if /dev/null has been deleted or overwritten. You can infer this cause when file system is reported as read-only at the time of booting through error messages, such as“/dev/null: Read-only filesystem” and “dup2: bad file descriptor”

If you get this error message while trying to access a file, the main causes are file system corruption or damaged disk block(s). In such conditions , you also get write errors.


To resolve deleted or overwritten /dev/null file issues, you need to replace it with the suitable inode. To do so, follow these steps:

Boot the system in single-user mode

Mount the /proc file system as:

mount -o ro /proc

/proc is the dynamically generated file system while boot process

Mount the file system in read-write mode as:

mount -o remount,rw /

Delete the /dev/null file:

m -f /dev/null

Use correct inode to replace it as:

mknod -m 666 /dev/null c 1 3

Remount the file system in read-only mode and restart your system

To correct file system and disk block problem, execute fsck command. You should run the command when the file system is not mounted. If problem persists, reformat the volume and restore from backup. In case of backup problems, you will need to use Linux recovery tools. Such utilities perform data recovery Linux using powerful scanning algorithms and provide graphically rich user interface.

0 comments: