Difference between procfs and sysfs filesystem in Linux

/proc and /sys partitions keeps the system information on which its running and are useful to get any system details or running configuration we need.

As we know in Linux, everything is a file. Hence in these two partitions every information related to system hardware, drivers, and configuration is stored as run time files.

The files on these partitions can’t be changed, however we can get the running configuration and make changes to get it in effect on next system boot.

There are few parameters you can force to apply via files in /proc or /sys. The example is to re-scan storage, to clean dentries or inode cache, etc.

1. Where are these runtime partitions mounted ?

[root@nglinux ~]# mount | egrep -i 'proc|sysfs'
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

2. Contents of /proc and sys partiton ?

[root@nglinux ~]# ls /proc/
1     1444  1565  1724  21    2186  2327  2486  33    5          cmdline      irq         mounts        swaps
10    1468  1581  1727  2120  2191  2329  25    34    6          cpuinfo      kallsyms    mpt           sys
1092  1478  1595  1754  2131  2193  2332  2527  35    7          crypto       kcore       mtd           sysrq-trigger
11    15    16    1773  2143  2195  2338  26    36    8          devices      key-users   mtrr          sysvipc
1153  1538  1601  18    2158  2197  2360  27    3844  80         diskstats    keys        net           timer_list
1158  1551  1626  1812  2169  22    2368  28    3919  81         dma          kmsg        pagetypeinfo  timer_stats
1167  1552  1651  19    2178  2202  2376  29    3922  9          driver       kpagecount  partitions    tty
1172  1553  1664  2     2179  2203  24    3     4     997        execdomains  kpageflags  sched_debug   uptime
1177  1556  1666  20    2180  2204  2409  30    4006  998        fb           loadavg     schedstat     version
1182  1557  1677  202   2181  2217  2416  308   413   acpi       filesystems  locks       scsi          vmallocinfo
12    1558  1678  203   2182  2220  2448  309   43    asound     fs           mdstat      self          vmstat
1203  1559  17    204   2183  2256  2449  31    45    buddyinfo  interrupts   meminfo     slabinfo      zoneinfo
13    1560  170   2065  2184  23    2459  32    46    bus        iomem        misc        softirqs
14    1561  171   207   2185  2326  2484  327   47    cgroups    ioports      modules     stat

[root@nglinux ~]# ls /sys/
block  bus  class  dev  devices  firmware  fs  hypervisor  kernel  module  power
[root@nglinux ~]# 

/proc : The first old age implementation to keep the running system information is /proc. Because of which it is not managed well as we can see in above output and looks a bit messy.

/sys : It is implemented late with 2.6 kernel which is aimed to keep the running system information in a managed structured way to easily search the available information.

3. Explanation of /proc and /sys
/proc
Process Information
Key system attributes of various system utilities
Settings of various kernel parameters

[root@nglinux ~]# ps
  PID TTY          TIME CMD
 3922 pts/0    00:00:00 bash
 4095 pts/0    00:00:00 ps
[root@nglinux ~]# ls  /proc/3922/
attr       clear_refs       cpuset   fd      loginuid   mounts      oom_adj        personality  sessionid  statm    wchan
autogroup  cmdline          cwd      fdinfo  maps       mountstats  oom_score      root         smaps      status
auxv       comm             environ  io      mem        net         oom_score_adj  sched        stack      syscall
cgroup     coredump_filter  exe      limits  mountinfo  ns          pagemap        schedstat    stat       task
[root@nglinux ~]# 

/sys
Adding structure to /proc messy filesystem.
Providing uniform way to provide system information except processes which is kept in /proc.
Separate sub directory inside /sys filesystem for each element.

1 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments