Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at

Monitor the virtual memory system


The virtual memory subsystem may have an important impact on a system's overall performance. Be able to configure a swap device and review swap usage.


TODO: define thrashing ?

TODO: mention NetBSD example?? UVM: pid 8808 (perl), uid 1000 killed: out of swap

TODO: show examples of swap in fstab

TODO: mention start up scripts for enabling swap devices and files and basic setup

TODO: show examples on FreeBSD and test this; is this the preferred beginner way?

$ mdev=`mdconfig -a -t vnode -f /path/to/swap/file`
$ swapon /dev/${mdev}

TODO: check this DragonFly example:

$ vnconfig -e vn0c /path/to/swap/file swap

TODO: show examples of loading swap file on OpenBSD or NetBSD

On NetBSD and OpenBSD, the swapctl tool can be used to enable swap devices or files at boot time. The following two commands are often done by default in NetBSD and OpenBSD startup to enable all block-type swap devices and swap files listed in /etc/fstab (with "sw"), respectively:

swapctl -A -t blk

swapctl -A -t noblk

NetBSD swap partition example in /etc/fstab:

/dev/wd0b none swap sw 0 0

TODO: show example of swap file in fstab

NetBSD and OpenBSD's swapctl tool can be used to add, remove, prioritize, and list swap files and devices.

TODO: this topic should not go into detail on virtual memory theory but just quickly explain it

Some tools to quickly show physical and/or virtual memory utilization are pstat, systat, top, and vmstat. On FreeBSD and DragonFly, the swapinfo tool is same as "pstat -s".

The following example lists the enabled swap files and devices:

$ pstat -s -k
Device        1K-blocks     Used    Avail Capacity  Priority
/dev/wd0b        170800   101004    69796    59%    0
/opt/swapfile    250000   129680   120320    52%    0
Total            420800   230684   190116    55%

TODO: should this mention that this is same as 'swapctl -l -k' ??

TODO: mention that DragonFly has "Type" like "Interleaved". I don't see on FreeBSD. TODO: while NetBSD and OpenBSD have "Priority"

TODO: should this mention unloading swap files? some systems may not support unloading sawp devices??

TODO: show how to read top for virtual memory info

TODO: show how to use vmstat for virtual memory info

TODO: show how to use systat for virtual memory info


Practice Exercises

More information

pstat(8); systat(1); top(1); vmstat(8); swapctl(8); swapinfo(8)

TODO: add swapon(8) and fstab(5)

Front | Information | Lists | Newsfeeds