3

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?

3

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.

  • 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
  • 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
  • @AlanCurry What's this about /dev/shm? Nobody's mentioned that at all. – Michael Hampton Aug 28 '12 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy