Have you ever wondered which processes/tasks write or read to disk in Linux? Maybe a real time log?
It’s quite simple to enable that feature with the following command:
echo 1 >/proc/sys/vm/block_dump
The output of the command goes to /var/log/messages or /var/log/kernel.log . It depends on the distribution you are using and how your log manager is configured.
Nov 9 21:21:01 hellboy kernel: [140072.428410] bash(31632): READ block 14156776 on md126p4 (8 sectors)
Nov 9 21:21:01 hellboy kernel: [140072.443138] bash(31632): READ block 14156816 on md126p4 (8 sectors)
Nov 9 21:21:57 hellboy kernel: [140127.746763] gnome-shell(5073): WRITE block 120375776 on md126p4 (8 sectors)
Nov 9 21:21:57 hellboy kernel: [140127.765385] gnome-shell(5073): dirtied inode 3627285 (?) on md126p4
Nov 9 21:22:00 hellboy kernel: [140130.602614] nvidia-settings(31743): dirtied inode 689070 (exe) on proc
The output shows the timestamp, the process name, the operation being done (read/write/dirty inode), block or inode number and the device.
Just to take note, a dirty inode is an inode that has had new data written into it but it has not been flushed to disk.
A Linux server of my own executes from time to time an rsync script, which one it finishes up doing its magic, leaves behind a lot of stuff cached in memory.
In order to “make available” the memory again to other applications, I recommend reading the following as seen on linux-mm.org
Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache…
To use /proc/sys/vm/drop_caches, just echo a number to it.
To free pagecache:
This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run “sync” first to flush them out to disk, these drop operations will tend to free more memory.
Rather than explaining the problem the title says, I’ll point you to the link you must read to understand/fix it: