Mastering NetBSD filesystems: FFS as the default, tmpfs and cd9660, mount and umount, disk management with disklabel and newfs, and keeping the system healthy with fsck and swapctl.

In episode 6 we brought services to life with the rc system. But everything we do — users, packages, services — is stored somewhere: the filesystem. In this episode we'll dissect NetBSD's storage layer: the FFS filesystem as the foundation, special filesystems like tmpfs and cd9660, the mount/umount commands, disk management with disklabel and newfs, and keeping data healthy with fsck and swapctl.
FFS (Fast File System) is NetBSD's default filesystem — the heir to the BSD tradition that has evolved over decades. FFS is known for its stability, maturity, and support for modern features like snapshots.
Let's see how your current system is organized:
mount/dev/wd0a on / type ffs (local)
/dev/wd0e on /usr type ffs (local)
/dev/wd0f on /var type ffs (local)
ptyfs on /dev/pts type ptyfs
procfs on /proc type procfs
tmpfs on /tmp type tmpfs (local)Notice the different filesystems: ffs for persistent data, tmpfs for /tmp (in RAM), procfs and ptyfs for kernel interfaces. NetBSD uses special filesystems for special needs.
| Filesystem | Type | Purpose |
|---|---|---|
ffs | Disk | Main filesystem for persistent data |
tmpfs | RAM | Temporary data; lost on reboot |
mfs | RAM | Traditional-style memory filesystem |
cd9660 | Optical | CD/DVD/ISO media |
procfs | Pseudo | Kernel process interface |
ptyfs | Pseudo | Pseudo-terminals |
tmpfs is the modern choice for /tmp — fast because it lives in RAM, and automatically empty at reboot. mfs is its predecessor; tmpfs is now the recommended option.
Attaching a filesystem into the directory tree is done with mount. To attach a disk or partition to a specific mount point:
mount /dev/wd0g /mntdf -h /mntMounting an ISO image is just one command — handy when you need to access installation media:
mount -t cd9660 -o loop NetBSD-11.0-amd64.iso /mnt/isoUnmounting is done with umount:
umount /mntWarning
Always umount before removing media. If the system complains of "device busy", a process is using files inside it — look for it with fstat -m /mnt or lsof /mnt before unmounting.
Mounts that must exist at every boot are recorded in /etc/fstab. This is the system's permanent map:
/dev/wd0a / ffs rw 1 1
/dev/wd0b none swap sw 0 0
/dev/wd0e /usr ffs rw 1 2
/dev/wd0f /var ffs rw 1 2
tmpfs /tmp tmpfs rw,-s=512m 0 0Six columns per line: device, mount point, filesystem type, options, dump flag, and fsck pass. Notice two important lines: partition wd0b is swap (mounted with type sw), and /tmp uses tmpfs with a 512 MB limit.
Every NetBSD disk has a disklabel — the BSD-level partition table we met in episode 3. Reading it:
disklabel wd0# /dev/rwd0d:
type: ESDI
disk: wd0
sectors/track: 63
...
a: 4096000 63 4.2BSD 2048 16384 12192 # (Cyl. 0 - 202)
b: 2048000 4096063 swap # (Cyl. 202 - 303)
c: 20971520 0 unused 0 0 # (Cyl. 0 - 1039)
e: 4194304 6144063 4.2BSD 2048 16384 12192 # (Cyl. 303 - 510)
f: 10633153 10338367 4.2BSD 2048 16384 12192 # (Cyl. 510 - 1039)Partition c is the whole disk (BSD convention), and the other partitions stack on top of it. Type 4.2BSD marks FFS, and swap marks a swap partition.
After the disklabel is set up, format a partition with newfs to create an FFS filesystem:
newfs /dev/rwd0g/dev/rwd0g: 2048.0MB (4194304 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 512.00MB, 124 blks, 968 inodes.
super-block backups (for fsck -b #) at:
32, 1048576, ...Always use the raw device (with a leading r: rwd0g) for newfs — that's the BSD convention for buffer-less device access.
Danger
newfs erases the entire contents of a partition. Check the disklabel twice before running it, and make sure you're pointing at the right partition. There's no undo button.
fsck checks and repairs filesystem consistency. After a system crash or power loss, NetBSD automatically runs fsck at boot for filesystems marked dirty. Manually:
fsck /dev/rwd0a/dev/rwd0a: 512 files, 4096 used, 299468 freeModern FFS also supports snapshots — consistent copies of a filesystem for backup. Creating a snapshot uses fsck -t:
fsck -t /dev/rwd0eSnapshot of /dev/rwd0e created at /var/snapshot/rwd0e.0NetBSD swap is managed with swapctl — not swapon/swapoff as on Linux. Viewing the swap status:
swapctl -lDevice 512-blocks Used Avail Capacity Priority
/dev/wd0b 2048000 51200 1996800 3% 0Adding a new swap partition manually:
swapctl -a /dev/wd0bIn this episode 7, you've mastered NetBSD's storage layer: the FFS filesystem as the foundation, special filesystems (tmpfs, mfs, cd9660), the mount and umount commands, the permanent mount list in /etc/fstab, disk management with disklabel and newfs, and keeping data healthy with fsck and swapctl.
Key takeaways:
tmpfs for /tmp and temporary data./etc/fstab (six columns: device, mount, type, options, dump, pass).newfs creates an FFS filesystem — always check the partition before running it.fsck keeps the filesystem healthy; FFS supports snapshots with fsck -t.swapctl, not swapon.In the next episode, episode 8, we'll connect the system to the outside world: networking and network configuration — configuring interfaces with ifconfig, routing, /etc/resolv.conf, and advanced features like VLAN, bonding (lagg), and bridges. See you in episode 8!