Fixing 'dup2: bad file descriptor error' on Linux

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!

Reply

  • You can use Mediawiki syntax. It is possible that not all formatting options are supported at the moment.
    Links to other pages: [[Page Title]] or [[path/to/page|Title]].
    External links: http://example.com or [http://example.com some link title].
    Interwiki links: [[site:Page Title]].
    You can use the following interwiki links: path, gdo, wp

More information about formatting options