Re: swap file vs swap partition

From: Scott Long <scottl_at_samsco.org>
Date: Sun, 04 Feb 2007 13:16:37 -0700
Aloha Guy wrote:
> Greetings everyone:
> 
> I am planning to build a few new boxes which will run -RELEASE and -CURRENT and I have a question about the swap file.  In the past, I had always used a swap partition of 256MB since I originally had 128MB system memory in the 1990's but my system has been upgraded to 2GB and it seems the swap file would have more flexibility as I can just change the size of the swapfile if I needed to. My question is is there any difference in performance between a swap file versus a swap partition and can one run a system with a swap file instead of a swap partition?

Yes.  A swap file requires a pass through the filesystem code in order
to figure out where each block is.

> Also, searching has not gotten me very far but are there any drawbacks to a swap file instead of a swap partition?  I read somewhere that a few people seem to think that a swap file can't handle kernel crash dumps?

That's correct, it cannot.

> Shouldn't it be the same as both of them occupy disk space and as long as the swap file is large enough, wouldn't it work?

The crashdump code is written to assume that the dump space is
completely contiguous, something that is not at all guaranteed by
a swap file.  While it would certainly be possible to modify it
to make a pass through the filesystem like above, the intention
of the crashdump code is also to be as simple as possible and to
depend on as few kernel services as possible.  When the system has
crashed, who knows what can be trusted anymore, right?  Also, filesystem
corruption is a frequent cause of crashes; why risk that dumping to
a swapfile might encounter corruption and trash your entire filesystem.

Scott
Received on Sun Feb 04 2007 - 19:16:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC