LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ramfs maxsize limit (https://www.linuxquestions.org/questions/linux-software-2/ramfs-maxsize-limit-4175431223/)

matiasar 10-08-2012 05:58 PM

ramfs maxsize limit
 
I'd like to create a little FS in ram. Just to use there a little SQLite3 database.

I know ramfs size grows dynamically, so I tried this "maxsize" option and I got no error:

Code:

# mount -t ramfs -o size=128k,maxsize=256k ramfs ./ramfs/
But I think limit didn't work cos' I tried copying a file greater that 256Kb and it was copied.

I know tmpfs can use limit (doesn't grow dynamically) but as fas as I know tmpfs uses swap space, and what I want to do is avoiding use of hard disk, so ramfs is the one which best fits my needs.

Does anybody know if a limit can be set to ramfs filesystem?

I didn't find very much documentation. Thanks in advance.

nugat 10-08-2012 09:04 PM

Quote:

Originally Posted by matiasar (Post 4800715)
I know tmpfs can use limit (doesn't grow dynamically) but as fas as I know tmpfs uses swap space, and what I want to do is avoiding use of hard disk, so ramfs is the one which best fits my needs.

If you want to avoid use of the hard disk, then why don't you disable swap entirely? If swap is disabled, I don't think tmpfs will create it.

syg00 10-09-2012 03:14 AM

Nope.
Have a read of this.

matiasar 10-09-2012 07:15 AM

Thanks for your advices folks.
I wouldn't like disabling swap space.
Thanks for the documentation! After reading the document I just have a doubt I couldn't find the answer:

tmpfs by default uses swap space? Or first it uses RAM and in case of necessity swap?

Regards,
Matías

syg00 10-09-2012 03:57 PM

tmpfs uses kernel cache (RAM).
Unless you are under heavy memory pressure, it is (extremely) unusual to see it swap. I haven't used anything else for years where tmpfs is an option.

matiasar 10-09-2012 04:11 PM

Cool SygOO. Then tmpfs is definitely my choice!
Thanks a lot for the info.

nugat 10-09-2012 08:17 PM

Quote:

Originally Posted by syg00 (Post 4801031)
Nope.
Have a read of this.

Yeah, I read that, too. I think you misunderstood me. I'm not saying tmpfs won't use swap, I'm saying that if there are no swap partitions mounted, tmpfs will not magically make them come into being (i think anyway!). Of course it will use them if they're there (if it really needs to, as you pointed out).

but if the OP doesn't want to disable swap, then that doesn't matter. however, the OP does not mention why he wishes not to swap. if it is for security reasons, then encrypting swap is always another layer of protection.

also, as to the original question: I believe there is work going on to patch the kernel to support the use of user quotas (like disk space usage) on tmpfs, but it is not a clean solution (yet).


All times are GMT -5. The time now is 06:40 PM.