swap space in a file?
Rick Stevens
rstevens at vitalstream.com
Thu Dec 14 17:54:39 UTC 2006
On Thu, 2006-12-14 at 13:29 +0000, Alan wrote:
> On Thu, 14 Dec 2006 7:26:26 -0500
> Tom Horsley <tomhorsley at adelphia.net> wrote:
>
> > Are there nice simple foolproof instructions somewhere that would let me add
> > more swap space to my system by using an ordinary file as swap (I don't want to
> > repartition the disk). Seems like the device mapper voodoo might work for
> > this, but my brain is too tiny to figure out how on my own :-).
>
> dd if=/dev/zero of=/swapfile bs=1M count=whatever
>
> [Make a file that size, you don't have to make it with dd, thats just the
> quick but arcane command old Unix heads tend to use for it]
Well, yeah, but you do want the swapfile to be contiguous and NOT a
sparse file so you must fill it with _something_. /dev/zero is a nice
source of zero bytes and dd will write a contiguous, non-sparse file.
So, to create a 1GB swap file:
dd if=/dev/zero of=/path/to/swap/file bs=1M count=1000
And Bob's your uncle!
> mkswap /swapfile
>
> [Mark it as a swap file and set it up]
>
> Then add /swapfile (or whever you put it) to /etc/fstab
>
> swapon -a
>
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer rstevens at vitalstream.com -
- VitalStream, Inc. http://www.vitalstream.com -
- -
- Brain: The organ with which we think that we think. -
----------------------------------------------------------------------
More information about the fedora-list
mailing list