Pseudo Filesystems
- The proc virtual filesystem exists since the beginning of Linux
- It allows
- The kernel to expose statistics about running processes in the system
- The user to adjust at runtime various system parameters about process management, memory management, etc.
- The proc filesystem is used by many standard user space applications, and they expect it to be mounted in /proc
- Applications such as ps or top would not work without the proc filesystem
- Command to mount /proc:
mount -t proc nodev /proc
- Documentation/filesystems/proc.txt in the kernel sources
- man proc
proc contents
- One directory for each running process in the system
- /proc/
- cat /proc/3840/cmdline
- It contains details about the files opened by the process, the CPU and memory usage, etc.
- /proc/interrupts, /proc/devices, /proc/iomem, /proc/ioports contain general device-related information
- /proc/cmdline contains the kernel command line
- /proc/sys contains many files that can be written to to adjust kernel parameters
- They are called sysctl. See Documentation/sysctl/ in kernel sources.
- Example
echo 3 > /proc/sys/vm/drop_caches
sysfs filesystem
- The sysfs filesystem is a feature integrated in the 2.6 Linux kernel
- It allows to represent in user space the vision that the kernel has of the buses, devices and drivers in the system
- It is useful for various user space applications that need to list and query the available hardware, for example udev or mdev.
- All applications using sysfs expect it to be mounted in the /sys directory
- Command to mount /sys:
mount -t sysfs nodev /sys
- $ ls /sys/
block bus class dev devices firmware fs kernel module power