openbsd-webzine/issues/issue-10/50_TIPS.html

22 lines
899 B
HTML
Raw Normal View History

2022-05-27 13:23:33 +00:00
<article id="tips">
<div class="puffies" aria-hidden="true">🐡🐡🐡</div>
<h2>Shell tips</h2>
<p>
2022-06-29 13:20:49 +00:00
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 :
2022-05-27 13:23:33 +00:00
</p>
<pre>
2022-06-29 13:20:49 +00:00
printf "swap /tmp mfs rw,nodev,nosuid,-s=%sB 0 0\n" \
$(dmesg |awk '/avail mem/ { print int($4 /10) }')
2022-05-27 13:23:33 +00:00
</pre>
2022-06-29 13:20:49 +00:00
<p>You may have to adjust newly created /tmp permissions:</p>
<pre> # chmod 1777 /tmp</pre>
2022-05-27 13:23:33 +00:00
</article>