Friday, August 10, 2007

Recreate the /dev/null Link using devlinks

If you inadvertently delete the /dev/null link, you can recreate it by using the devlinks command. The null device is basically a bit bucket. Here's an example.

# cd /dev/
# ls -l null
null: No such file or directory
# devlinks
# ls -l null
lrwxrwxrwx 1 root other 27 Aug 10 16:11 null -> ../devices/pseudo
mm@0:null

If null device and link is missing, use mknod.

# cd /devices/pseudo
# mknod mm@0:null c 13 2
# chown root:sys mm@0:null
# chmod 666 mm@0:null
# devlinks

1 comment:

Devon said...

drvconfig can be used to recreate your devices too followed by the devlinks command, though the man page now suggests using devfsadm.

I always found that if I had the luxury of rebooting the device the bootflag -r would nicely rebuild the /devices and /dev trees.