Can i execute run tmpfs size

I am trying to use / dev / shm tmpfs to write my files. By default, half of the physical memory without a swap is used. When I write something in excess of the size of this mount, it gives the error "No free disk space."

My question is: shouldn't swap space be used, not errors? Is there a way that I can let my application use more than what stands out for tmpfs, possibly with an option?

What happens if one of my processes is running and running out almost all the space in / dev / shm and I have another process (outside / dev / shm) that also uses more than 50% of the RAM space? Which one is unloaded?

For example, suppose my shared physical memory is 40 GB and tmpfs is 20 GB. One process is to use / dev / shm and about 20 GB. Now there is another process that takes up about 30 GB. Which process will be replaced? Or is it impossible to determine?

+8
linux shared-memory
source share
1 answer

tmpfs will use swap space if necessary (this can happen even if tmpfs is half the size of RAM, because other things also use RAM), and “half RAM” is just the default size (quite normal defaul) of the file system. You can install it in whatever you want when installing or reinstalling using the "size" argument:

Mount options for tmpfs

size=nbytes Override default maximum size of the filesystem. The size is given in bytes, and rounded up to entire pages. The default is half of the memory. The size parameter also accepts a suffix % to limit this tmpfs instance to that percentage of your physical RAM: the default, when neither size nor nr_blocks is specified, is size=50% 

If your distribution uses fstab to mount tmpfs, you can add, for example. 'size = 40G'. You can also remount it at any time using:

 mount -o remount,size=40G /dev/shm 

Be careful. If the files on tmpfs take up too much of your virtual memory (RAM + swap), applications can be killed (byt OOM killer), and the whole system may crash.

Back to your questions ...

I don’t think it’s easy to determine what will be replaced, since AFAIK at this level for Linux everything (including process data memory, files in cached disks, mmaped disk, tmpfs files) is the same “virtual memory” Linux may consider some pages more important (recently used), others are ready to be replaced, so it can be part of the tmpfs file, and part of another process replaced.

+17
source share

All Articles