Managing storage on OpenBSD: getting to know the FFS2, tmpfs, and mfs filesystems, using mount and umount, configuring partitions with disklabel and newfs, arranging /etc/fstab, performing maintenance with fsck, and adding a swap file.

In episode 6 you managed services with the rc system. But all those services write data somewhere — to the filesystem. This episode covers the storage foundation of OpenBSD: how data is organized, how disks are partitioned and formatted, how mounting works, and how to keep data healthy.
OpenBSD uses FFS2 as its default filesystem, laid out on partitions created by disklabel, mounted via /etc/fstab, and maintained with fsck. All of this is fully controllable from the command line — there's no GUI hiding anything.
FFS2 (Fast File System 2) is an improved successor to UFS. Its important features:
softdep, noatime, and wxallowed.Most system partitions — root, /var, /home — use FFS2.
Besides FFS2, OpenBSD provides memory-based filesystems:
| Filesystem | Description | Use Case |
|---|---|---|
tmpfs | RAM filesystem with a size limit | Small /tmp, temporary builds |
mfs | Memory-backed FFS | Legacy contexts, rarely used |
tmpfs is popular for reducing disk I/O: moving /tmp to tmpfs speeds up temporary operations, but its contents vanish on reboot. Mounting /tmp with the wxallowed option on OpenBSD allows executing binaries there (this option is considered risky, so it must be explicit).
Mounting connects a filesystem to a directory. Without arguments, mount displays all active filesystems:
mount
mount /dev/sd0a /mnt
umount /mntManual mount is used for repairs and recovery. For permanent mounts, you write an entry in /etc/fstab.
disklabel manipulates disk partitions. To view the layout:
disklabel sd0
disklabel -p wd0Each partition is given a letter. You can also use disklabel -E for interactive editing. Remember: don't mess with partitions currently in use without a backup.
After a partition is created, format it with newfs:
newfs sd0d
newfs -O 2 /dev/rsd0dThe -O 2 option explicitly sets the FFS2 version. This operation destroys data on the partition — only do it for new disks/partitions.
The /etc/fstab file determines what is mounted at boot. Its format: device, mount point, filesystem, options, dump frequency, and fsck pass:
/dev/sd0a / ffs rw,softdep 1 1
/dev/sd0b none swap sw 0 0
/dev/sd0d /tmp ffs rw,nodev,nosuid,softdep 1 2
tmpfs /var/run tmpfs rw,nodev,nosuid,mode=0755 0 0Note the security options: nodev and nosuid prevent devices and setuid binaries from being mounted at points where they shouldn't be. softdep enables soft updates. The last column (1 2) determines the fsck pass order.
fsck checks and repairs filesystem consistency. Before checking, the filesystem must be unmounted:
umount /dev/sd0d
fsck /dev/sd0d
mount /dev/sd0dDanger
Never run fsck on a filesystem that is mounted read-write — it can corrupt data. If root is damaged, boot from bsd.rd (the RAMDISK kernel) and run fsck from there. This is why understanding bsd.rd since episode 3 matters.
OpenBSD uses a swap partition (b) by default. But swap files are also supported — useful when you need more swap without repartitioning:
dd if=/dev/zero of=/var/swapfile bs=1m count=2048
chmod 600 /var/swapfile
chown 0:0 /var/swapfile
swapctl -a /var/swapfileTo make it permanent, add it to /etc/fstab as a swapfile entry. To view swap status:
swapctl -lAn administrator must know exactly what is consuming space:
df -h
du -h /vardf -h shows the usage of every filesystem; du walks through directory usage. The combination of both is the first step every time a disk fills up — and it will be used often in episode 11 when discussing backups.
In episode 7 you managed OpenBSD storage: getting to know FFS2 as the main filesystem plus tmpfs and mfs, performing mount and umount, shaping partitions with disklabel and newfs, arranging the mount blueprint in /etc/fstab, maintaining health with fsck, and adding a swap file.
Key takeaways:
/etc/fstab determines permanent mounts with security options like nodev and nosuid.fsck is only run on unmounted filesystems; use bsd.rd for a damaged root.b) or a file via swapctl.In the next episode, episode 8, we'll build networking and network configuration — arranging /etc/hostname.if, using ifconfig and route, configuring DNS in resolv.conf, and getting to know aliases, VLAN, trunk, and bridge as a bridge toward the pf firewall.