back
2 comments
Mount temporary directories as tmpfs

While this is a great tip it is missing one important piece which is to specify a size. Each tmpfs mount by default will allocate half of memory as shared memory. This is fine until applications and people actually utilize this space and can cause out of memory and system panic conditions. To avoid this specify a size. So

    tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777   0 0
    tmpfs   /var/tmp   tmpfs   defaults,noatime,mode=1777   0 0
might become adjust size as desired or as required

    tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777,size=2g   0 0
    tmpfs   /var/tmp   tmpfs   defaults,noatime,mode=1777,size=512m   0 0
Then for other scratch/temp spaces set the size as required by the application or number of people that simultaneously utilize the system. It may also be important to note that tmpfs is swap backed meaning that if one has sensitive data in that tmpfs mount then swap should be encrypted. This can occur even if vm.swappiness is set to 0.
Nice one, thanks!