Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Jan 28 '13 at 7:39

This question came from our site for professional and enthusiast programmers.

    
did you checked #cat /proc/meminfo –  sujeesh Jan 28 '13 at 6:44
    
I already check /proc/meminfo and /proc/vmstat but there are no field about ramfs. –  Nick Jan 28 '13 at 7:09
    
ramfs and tmpfs dynamically use/acquire RAM based on need. They do not have a fixed or hard allocation of RAMemory. Hence there is no way to specify any allocation size like ramdisk has. –  sawdust Jan 28 '13 at 10:04
    
You can simply use df or du, have a look to my answer below. –  jaume Feb 6 '13 at 19:01
    
A good talk about ramdisk(initrd), vs ramfs(initramfs), vs tmpfs and their various behavior in terms of memory allocation and usage can be found at the following article written by the guys from the Tin Hat and Tor-ramdisk projects: opensource.dyc.edu/ramdisk-vs-ramfs –  dustymabe Oct 3 '13 at 17:35

1 Answer 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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.