[NCLUG] increasing swap space on the fly?

Michael Dwyer mdwyer at sixthdimension.com
Mon Oct 29 11:35:59 MST 2001


----- Original Message -----
From: "Mike Loseke" <mike at verinet.com>
To: <nclug at nclug.org>
Sent: Monday, October 29, 2001 11:17 AM
Subject: Re: [NCLUG] increasing swap space on the fly?


> Thus spake Daniel Herrington:
> > How can you increase the amount of swap space without killing your
> > other partitions?  Is there a good "partition magic"-like program to
> > use that will resize partitions on the fly?  I seem to recall
> > something like cfdisk, or fips, or something.  But back when I was
> > reading about it, it was pretty unreliable.
>
>  You can do this without modifying partitions, or even adding
partitions.
> How, you ask? Files, my friend. :-)
>
>  See the manpages for dd, mkswap and swapon (as well as fstab).
Basically,
> using dd you can create a file of whatever size you need, mkswap
initializes
> it and swapon adds it to the paging area. To make it permanent, mount
it
> as swap in fstab. You can also remove swap space using swapoff.
>
>  Now, I've never done this in Linux but reading these manpages
(especailly
> mkswap) it looks like it works fine. I've done this numerous times in
> Solaris (using mkfile, swap and dfstab) with great results.

I've done this.  It works quite well:

dd if=/dev/zero of=/tmp/swap count=<sufficiently large number)
mkswap /tmp/swap
swapon /tmp/swap

Using this sort of strangeness, you can also share a swap partition
between Linux and Windows. I think there is a howto to this effect.

Also, take a look for swapd -- This daemon watches your memory, and
if you start running out, it dynamically creates these swap files
on the fly to keep you running. It is pretty old, but I guess it
still works, if you insist on doing things this way.

's probably cheaper to just get more memory. :)





More information about the NCLUG mailing list