Virtual filesystems are filesystems that are created in memory when the system starts.
They present us with an ordered "filesystem-like" structure to access different resources in our system.
As examples, we have the below filesystems:
- procfs : contains system and processes information.
- sysfs : contains system information.
- tmpfs : holds temporary information in the RAM.
- ramfs : filesystem in the RAM for caching purposes.
The "proc" filesystem:
The "proc" filesystem is used to give us runtime information about about the running processes.The files in the "proc" directory that are not process IDs are kept there for backward compatibility.
Anything related to the kernel lives to the "sys" virtual filesystem and anything related to the hardware lives in the "dev" virtual filesystem.
We can go inside the "10" directory, which represents the process with the "ID=10"
Inside we can find all the information about the process with the "ID=10", its input/output, its mounted files, its resource , ...
There is some information that is system related, and not process related in the "/proc" filesystem, like the "mountinfo" or the "cpuset".
The "sys" filesystem:
The "sys" filesystem is used to store kernel information about the CPU, networking , ...
Since the "sys" filesystem is a relatively new addition to the kernel, we would still need to go to the "proc" folder for the information that is not showing in the "sys" filesystem.
The "dev" filesystem:
The "dev" filesystem is where the system can look for information about devices, virtual or physical.
The "/dev" directory contains information about the system devices like the hard drives, keyboards, ...