Some ideas for FreeBSD

Chad Perrin perrin at
Wed Feb 13 23:51:05 UTC 2008

On Wed, Feb 06, 2008 at 10:32:16PM -0800, Jason C. Wells wrote:
> Norberto Meijome wrote:
> >But I agree with you really want to use swap files?
> One could mount an md filesystem and then use that as swap.  That way 
> you wouldn't need to use any disc space.  As a plus, the performance 
> would be way better than disc.

Okay, I'm confused.  Are we talking about using md(4) to create a virtual
disk in RAM, then putting your swap there?  If so . . . why?

Do you just lack understanding of what swap is?

Say you have 100 MB of RAM and 50 MB of swap on disk.  When your system
uses more than 100 MB of memory, it fills up RAM, and the extra spills
over into swap.

Now, let's say your 50 MB of swap is in md(4).  This means you have 50 MB
of free RAM and 50 MB of swap in RAM.  When your system uses up more than
50 MB of memory, the extra spills over into the md(4) swap.  When your
system uses more than 100 MB of memory, though, as in the first example,
well . . .

Then it has nowhere to go.  Your swap is already used up, because your
free RAM was used up 50 MB faster (since there was 50 MB less free RAM).

By analogy:

  You have 100 paper cups.  You want to use paper cups for a party you're
  having.  You want to make sure that you have extra cups in case more
  people show up than you expect.

  You prefer to use paper cups as much as possible, because they can just
  be thrown away when they're done, and you don't have to waste time
  later doing dishes like you would for actual glasses.

  You can decide to keep 50 clean glasses in your kitchen, ready to be
  used in case you have more than 100 guests.

  You can also decide to only make 50 paper cups available, and keep 50
  in reserve.  You decide you don't need any glasses at all, because
  you've very cleverly kept 50 paper cups in reserve.  You then pack up
  your glasses in a box and store it in the attic where you won't have to
  worry about how slow they are to wash when they've been used.

  Now . . . what do you do when you find out you have 120 guests to your

CCD CopyWrite Chad Perrin [ ]
McCloctnick the Lucid: "The first rule of magic is simple. Don't waste your
time waving your hands and hopping when a rock or a club will do."

More information about the freebsd-questions mailing list