Using mdconfig for swap space

Chuck Swiger cswiger at
Tue Sep 8 23:00:27 UTC 2009

Hi, Peter--

On Sep 8, 2009, at 2:51 PM, Peter Steele wrote:
> Are there any advantages to using mdconfig and creating a virtual  
> disk for swap space as opposed to having a designated swap  
> partition? For example, I could do something like this:
> mdconfig -a -t swap -f /var/swap0 -s 4g
> swapon -a /dev/md0
> to add 4G to the system swap space backed by the file /var/swap0.  
> How would this compare to repartitioning my hard drive and adding a  
> new 4GB swap partition?

First, using -f means using -t vnode.  Secondly, swapping directly to  
a swap partition is mildly faster than having to navigate through the  
filesystem layers to do swapfile based swapping.  Other platforms have  
chosen to go with the dynamically created and deleted swapfiles  
(under /var/vm/swapfile0, 1, etc for example) to allow the system to  
adjust the amount of disk used for swapspace dynamically.

With disk space costing a matter of a few cents per gigabyte nowadays,  
setting up a dedicated swap partition and just letting it do it's  
thing is much easier than trying to fiddle around with alternatives,  
IMHO, but you're welcome to experiment and see whether you end up with  
something which is actually better for your circumstances....


More information about the freebsd-questions mailing list