increase swap space without free space in HD

Cameron Simpson cs at zip.com.au
Fri Oct 7 04:24:04 UTC 2005


On 06Oct2005 13:23, Opesh <opeshalkara at gmail.com> wrote:
| I don't have unpartitioned space in my hard disk to increase the swap space....
| Please suggest how should I go ahead to increase 
| I believe I need to format any primary/extended partition and recreate
| it with less size to reclaim space for swap depending upon whether swap
| lies in primary or extended.......
| I am confused ...please suggest...

If your disc is fully partitioned you need a swap _file_!
Find a partition you're using for files that has lots of spare room.
Make the swap file on that partition.

See "man mkswap" and "man swapon". From the former:

       To setup a swap file, it is necessary to create that file  before  ini-
       tializing it with mkswap , e.g. using a command like

              # dd if=/dev/zero of=swapfile bs=1024 count=65536

       Note  that  a  swap file must not contain any holes (so, using cp(1) to
       create the file is not acceptable).

That example makes a 64MB swap file named "swapfile". Then prepare it:

	mkswap swapfile

and then start using it:

	swapon swapfile

I like to protect the file from accidental damage, too:

	chmod 0 swapfile

You can name such a file in /etc/fstab, too, so it will get used on boot.

Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Reminds me of the time that I had one of those Hav-A-Hart traps.  It was
the damnedest thing, I'd throw the cage into the pool and when I'd pull
it out about an hour later there'd be a cold, still, bug-eyed cat in it.
        - Bill Berbenich




More information about the redhat-list mailing list