How to find size of RAM cache use for ramfs, tmpfs
I'm wondering if there is any way to specify the size of RAM cache used to store ramfs
, tmpfs
?
When I look at /proc/
, I can't find anything about ramfs
size.
Solution 1:
From http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt:
Further on you can check the actual RAM+swap use of a tmpfs instance with df(1) and du(1).
So simply use df
or du
(you can also use them for ramfs):
$ df | grep tmpfs
tmpfs 205032 1136 203896 1% /run
so 1136 KB is in use.
$ sudo du -s /run
[sudo] password for jaume:
1416 /run
so 1416 KB is in use.
Thats's interesting... df
and du
report different sizes. What is happening here and which one is right?
/run
has a subfolder called /run/shm
, which is itself a separate tmpfs filesytem (although shown as none
):
$ df | grep run
tmpfs 205032 1136 203896 1% /run
none 5120 0 5120 0% /run/lock
none 512572 280 512292 1% /run/shm
Adding both amounts you get the size reported by du
:
$ expr 1136 + 280
1416
So the whole story is that 2 tmpfs filesystems use 1416 KB.
(Here's another reason why du
and df
outputs may differ.)