bobafetthotmail / folder2ram

mount those folders to ram without losing access to their counterpart on disk!
GNU General Public License v3.0
116 stars 22 forks source link

Option to specify size of ram disk per folder #24

Closed BigBrainAFK closed 2 years ago

BigBrainAFK commented 2 years ago

Hello,

I wanted to suggest a rather simple option to specify the size of each mount in RAM since folder2ram currently allocates what looks like 56G for /var/log which seems way overkill and could fill the RAM up fast on an accidental write of tons of data.

bobafetthotmail commented 2 years ago

The script allows you to specify custom mount options for that folder, like you use in fstab or when mounting manually. See the default config file:

#############################
#folder2ram main config file#
#############################
#
#PROTIP: to make /var/lock or /tmp available as ram filesystems,
#        it is preferable to set the variables RAMTMP, RAMLOCK
#        in /etc/default/tmpfs.
#
#TYPE: options available are "tmpfs" (for a ram folder)
#
#OPTIONS: mount option (will be passed as options to mount), if left blank "defaults" will be used
#
#TIMEOUT=2m #write here the timeout limit for folder2ram service activity
#           #(the time specified here must cover the mount/unmount time of all folders)
#           #if you are using systemd init, when you change this value you must run
#           #folder2ram -enablesystemd again to update the systemd service units with the new value 
#
#IMPORTANT: use 2 Tabs to separate "type" from "mount point" from "options", the script needs them to read correctly the configuration.
#
#<type>     <mount point>           <options>
#tmpfs      /var/log

tmpfs mount options allow you to define the size of the tmpfs for that mount https://www.man7.org/linux/man-pages/man5/tmpfs.5.html

so if you write this in the options


#<type>     <mount point>           <options>
tmpfs       /var/log        size=1g

the script will pass those options to the mount command. This example should limit that mount point to 1 gigabyte of size.

If you don't define mount options, the default mount options are setting the limit to half your RAM. If half your ram is 56 GB, you have a lot of RAM.