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

19 lines
862 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>
2022-07-02 12:57:23 +00:00
<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>
2022-07-02 10:29:10 +00:00
<p>You can find your memory size using dmesg and awk:</p>
2022-06-29 13:20:49 +00:00
<pre>dmesg | awk '/avail mem/'</pre>
<p>
2022-07-02 10:29:10 +00:00
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:
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" \
2022-07-02 12:57:23 +00:00
$(dmesg |awk '/avail mem/ { print int($4 /10) }')
2022-05-27 13:23:33 +00:00
</pre>
2022-07-02 10:29:10 +00:00
<p>You need to adjust /tmp permissions:</p>
2022-06-29 13:20:49 +00:00
<pre> # chmod 1777 /tmp</pre>
2022-05-27 13:23:33 +00:00
</article>