💾 Archived View for perso.pw › blog › articles › mfs-tmp.gmi captured on 2024-05-12 at 15:41:40. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-03-21)

-=-=-=-=-=-=-

Use ramdisk on /tmp on OpenBSD

NILIf you have enough memory on your system and that you can afford to

use a few hundred megabytes to store temporary files, you may want to

mount a mfs filesystem on /tmp. That will help saving your SSD drive,

and if you use an old hard drive or a memory stick, that will reduce

your disk load and improve performances. You may also want to mount a

ramdisk on others mount points like ~/.cache/ or a database for some

reason, but I will just explain how to achieve this for /tmp with is a

very common use case.

First, you may have heard about **tmpfs**, but it has been disabled in

OpenBSD years ago because it wasn't stable enough and nobody fixed

it. So, OpenBSD has a special filesystem named **mfs**, which is a FFS

filesystem on a reserved memory space. When you mount a mfs

filesystem, the size of the partition is reserved and can't be used

for anything else (tmpfs, as the same on Linux, doesn't reserve the

memory).

Add the following line in /etc/fstab (following fstab(5)):

swap /tmp mfs rw,nodev,nosuid,-s=300m 0 0

The permissions of the mountpoint /tmp should be fixed **before**

mounting it, meaning that the `/tmp` folder on `/` partition

should be changed to 1777:

# umount /tmp

# chmod 1777 /tmp

# mount /tmp

This is required because **mount_mfs** inherits permissions from the

mountpoint.