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?

1 Answers1

4

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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940