improve tip, no root, round up memsize

This commit is contained in:
prx 2022-06-29 15:20:49 +02:00
parent a9d604f1d4
commit 38e8801385
1 changed files with 13 additions and 7 deletions

View File

@ -2,14 +2,20 @@
<div class="puffies" aria-hidden="true">🐡🐡🐡</div>
<h2>Shell tips</h2>
<p>
To improve performances or avoid disk i/o, one may mount /tmp in memory (mfs). As example to create a /tmp using 10% of available RAM:
To improve performances or avoid disk i/o, one may mount /tmp in memory (mfs). The new fstab entry would look like this :
</p>
<pre> swap /tmp mfs rw,nodev,nosuid,-s=800MB 0 0</pre>
Of course, replace the size 800MB according to how much memory you want to let for /tmp.
</p>
<p> To know how much memory you have, you may use dmesg and awk : </p>
<pre>dmesg | awk '/avail mem/'</pre>
<p>
As example to create a /tmp using 10% of available RAM, the following command will output the line to copy in /etc/fstab to replace "/tmp" entry, using awk to compute the size :
</p>
<pre>
# sed -i '/\/tmp /s/^/\#/' /etc/fstab
# printf "swap /tmp mfs rw,nodev,nosuid,-s=%sB 0 0\n" \
$(dmesg |awk '/avail mem/ { print $4 /10 }') \
>> /etc/fstab
# chmod 1777 /tmp
# mount -a
printf "swap /tmp mfs rw,nodev,nosuid,-s=%sB 0 0\n" \
$(dmesg |awk '/avail mem/ { print int($4 /10) }')
</pre>
<p>You may have to adjust newly created /tmp permissions:</p>
<pre> # chmod 1777 /tmp</pre>
</article>