Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Today at work a client had rm -rf /dev and ended up deleting two files in /dev/shm that forced his site to no longer work.

From what I learned previously /dev is not virtual, but a fellow technician had suggested to reboot the server because /dev is virtual like /proc. Sure enough I rebooted the server and the files that the client rm -rf'd were there.

So, my question is; is /dev virtual? Is it the kind of virtual like /proc? Is there more documentation on this? How can I restore the /dev files without a server reboot?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

The answer for a very long time has been "sort of".

Currently the Linux device tree is managed by udev, a userspace device manager which replaced devfs several years ago. udev populates /dev with any device nodes the system needs, depending on the rules configured in its configuration files.

On the newest Linux systems, /dev is in a temporary RAM disk provided by devtmpfs. You could call these virtual.

Example:

devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=6109940k,nr_inodes=1527485,mode=755)

The only reason for actual device nodes in /dev nowadays is for the boot environment, before udev has started. Typically only /dev/console and /dev/null are needed in the actual filesystem, which is sufficient to get to the point where udev can be started. It will then provide everything else.

share|improve this answer
    
That doesn't mean that it's virtual, just that it's autopopulated by the system. –  Ignacio Vazquez-Abrams Aug 28 '12 at 2:13
    
True. I've updated the answer. –  Michael Hampton Aug 28 '12 at 2:16
    
Is it possible to invoke udev to reload some/all /dev files without a reboot? –  josten Aug 28 '12 at 2:18
1  
@user973917 You could run udevadm control --reload or just restart udevd. –  Michael Hampton Aug 28 '12 at 2:22
3  
/dev/shm is a separate thing. Files in there are not created by udev, but they are temporary (not meant to survive a reboot). –  Alan Curry Aug 28 '12 at 2:38
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.