SUMMARY: Benefits of swap PARTITIONS vs. swap FILES?

From: Ned Forrester (
Date: Tue Jun 21 1994 - 15:03:43 CDT


My original question:

I have a Sparcstation IPX running SunOS 4.1.2 (someday 4.1.3),
with 16MB RAM and a 400MB disk having a 32MB swap (b) partition.
I use this primarily single user and while my applications don't
run out of memory, they do a lot of paging. I will be upgrading
to 32MB RAM and adding a local 1GB disk. I have read the
appropriate FAQs and searched the sun-managers gopher site to
learn that I should distribute swap space on the second disk (at
least an equal 32MB) for maximum performance.

My question is: What are the advantages of the following two
methods of creating swap space?
1. Create a separate swap (b) PARTITION on the new disk.
2. Use mkfile to create a swap FILE in a larger general use

I know of two considerations already:
1. A swap file is easier to change the size of at a later date.
2. Any level of dump of a device (partition) that contains a swap
   file will cause the (large) swap file to be dumped because it
   always changes.

Are there other considerations? Is there a performance difference
between the two methods?


The consensus of 18 responses is that partitions are faster than files
because the disk driver is called directly without having to call the
file system routines first. Opinions varied about how much faster, from
negligible to very significant; the most credible reporters (those
with quotable experts or seminars) aggree that the performance hit is
small (10-20%, 100's of usec out of 10 msec, etc.).

One reporter pointed out that a swap partition is more space efficient
than a swap file because there is no overhead for inodes and such.

Another issue mentioned is security. Some felt that a swap file is
more vulnerable to deletion or modification by malicious users.

I will certainly install a swap partition on the second disk, and then
I can always expand with a file if necessary.

Anyone wishing to receive the complete responses may send a request to
either my address above or below.


Thanks to: (Brett Lymn)
Casper Dik <>
Tom Reingold <> (Eric William Burger)
jason andrade <>
"Lewis E. Wolfgang" <>
Barry Margolin <>
Mike Raffety <> (Eckhard Rueggeberg) (Steve_Kilbane) (Pawel Marczewski) (Brian Sommers)
ye@Software.ORG (Jian Ye) (Michael D. Reynolds) (Russ Poffenberger) (Paul Bellan-Boyer) (Michael Sullivan)
Dan Stromberg - OAC-DCS <>


Ned Forrester
Applied Ocean Physics and Engineering Dept. / Oceanographic Systems Lab
Woods Hole Oceanographic Institution Woods Hole, MA 02543, USA

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:04 CDT