Fixing 'dup2: bad file descriptor error' on Linux
Submitted by robot_terror on Sun, 07/15/2007 - 09:56.
If you cannot boot into multiuser due to a read-only file system and, among the errors reported are the following: "dup2: bad file descriptor" to "/dev/null: Read-only filesystem" to "could not open /proc/partitions", etc., someone has accidentally (I hope) overwritten or deleted /dev/null. The step-by-step instructions below will help you fix these errors.
Boot into single user mode (maintenance mode) and then execute the following commands:
# mount -n -o remount,rw / # rm -f /dev/null # mknod -m 666 /dev/null c 1 3
Then reboot the server. All should be fixed.
Thanks to Google (and several mailing lists referred to there upon) for solving this for me!
