On linux, I know procfs is a pseudo FS and only exist in memory. is there a simple way to access procfs (/proc) from disk by dumping that memory content to disk either through configuration or actively run command?
For the most part there is no "memory content" . The /proc
pseudo file system not only does not exist on disk, the majority of it also isn't explicitly instantiated as files in memory. Much of the content is instantiated on-demand from information stored elsewhere in kernel data structures. From the manual:
The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).
This is even reflected in the fact the /proc
file system reports no actual usage (in contrast to /dev/shm
, which is a real file system):
$ df -h /proc /dev/shm
Filesystem Size Used Avail Use% Mounted on
proc 0 0 0 - /proc
tmpfs 20G 336K 20G 1% /dev/shm
So for example, the contents of /proc/$$/status
and /proc/$$/stack
are constantly changing as a process runs, and the contents of those pseudofiles are only generated on-demand when you open the file.
If you want the contents of these files dumped to disk you can use a cp
operation to capture some of it (with sufficient user permission), but dumping it ALL to disk is probably a bad idea and might not even terminate.