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

19 lines
862 B
HTML

<article id="tips">
<div class="puffies" aria-hidden="true">🐡🐡🐡</div>
<h2>Shell tips</h2>
<p>To improve performance or reduce disk i/o for some workload, you can mount /tmp in memory using mount_mfs. When doing so, the new fstab entry would look like this:</p>
<pre>swap /tmp mfs rw,nodev,nosuid,-s=800MB 0 0</pre>
<p>In this example, we used 800MB, you should adapt according to how much memory you want for /tmp.</p>
<p>You can find your memory size using dmesg and awk:</p>
<pre>dmesg | awk '/avail mem/'</pre>
<p>
Here is a command generating a fstab entry assigning 10% of your memory to /tmp/, you can use it in place of your /tmp/ entry:
</p>
<pre>
printf "swap /tmp mfs rw,nodev,nosuid,-s=%sB 0 0\n" \
$(dmesg |awk '/avail mem/ { print int($4 /10) }')
</pre>
<p>You need to adjust /tmp permissions:</p>
<pre> # chmod 1777 /tmp</pre>
</article>