File system fundamentals in Linux(Virtual file systems) | Part 3

File system fundamentals in Linux(Virtual file systems) | Part 3

Virtual file systems

VFS is the file system that resides in memory, having no physical part in disk. You probably get bored from this piece of information that everything in Linux represented by a file :). So virtual file systems is a way of communication between the Kernel and applications through reading and writing to files.

To be precise its a real time communication. If you tried to ls files within a Virtual file system you may notice that timestamp is set to NOW. This is because these files are not in disk. The kernel just created it to provide you with information.

Exmples

  • Proc virtual file system

Hit cd /proc to find this VFS. Most files in proc are readable files. These files have information about all processes running on the system right now. Each process running has a directory with its pid(process id). It also contains other precious information about memory state, devices, network, file systems, etc. You can also know the command that started specific process by cating cmdline file within the process directory. Ex: This is the directory of chrome running on my machine. To show the command, I catted cmdline file.

chrome_screen.png

Actually commands like top and ps reads information from /proc VFS. All they do is to read information and print it to the terminal, they don't communicate to the Kernel. If you tried to unmount this file system and tried top command, it won't work.

  • Sys virtual file system

sys was created to be a light version of proc which have a lot of information. However its main target about hardware and system devices not processes. Its used by application, so it's not human readable like proc.