Compiling Swap space

John R. Levine johnl at
Tue Feb 27 19:16:11 UTC 2018

> You don't need mdconfig, just make a large file and use swapon like this:
># dd if=/dev/zero of=swapfile bs=1m count=1024
># swapon swapfile

Nope.  Try it.  You need a block device.

# dd if=/dev/zero of=/var/swap bs=1m count=100
100+0 records in
100+0 records out
# swapon /var/swap
swapon: /var/swap: Block device required

# mdconfig -f /var/swap
# swapon /dev/md0

Assuming you want your swap space to come back after a reboot, put a
line into /etc/fstab and it'll do the mdconfig and mount at boot time:

# Device		Mountpoint	FStype	Options		Dump	Pass#
/dev/vtbd1		none		swap	sw		0	0
/dev/vtbd0s1a		/		ufs	rw		1	1
md99			none		swap	sw,file=/var/swap,late 0 0

John Levine, johnl at, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail.

More information about the freebsd-questions mailing list