Wednesday 4 February 2009

dup2: Bad file descriptor

Operating System: Redhat Enterprise Linux 4
Linux Kernel: 2.4.21-37.ELsmp
Error keywords seen:
dup2: Bad file descriptor
/dev/null: Read-only filesystem


This is one of the scariest errors I've ever seen. Mainly because it appeared on boot-up after reracking one of our more important Oracle database servers. One of those 'blood runs cold' moments when you realise that the simple, 'turn off, move, turn on' plan has gone wrong, and you're looking at a halted system with an error message you've never seen before.

Left with a prompt inviting me to log in as root, and fix the problem, the first, obvious, thing to do is fsck the drive. fsck (-f) uncovered and repaired a handful of unreferenced inodes and a few missing blocks. But this didn't work - the same error message appeared after a reboot.

Google's great though, and thanks to this page I was able to fix the error quite quickly.

I'm not convinced the error is caused by device inode permission problems, but certainly some form of corruption was affecting /dev/null

The root filesystem had been mounted as read-only, so the first task is to remount this with a write option:

mount -n -o remount,rw /

Next we remove the offending /dev/null entry:

rm -f /dev/null

Now we create a new /dev/null

mknod -m 666 /dev/null c 1 3


Happily, the system now rebooted without a problem.

No comments: