Swap!

Swap!

Post by Yns » Sun, 31 Dec 1899 09:00:00



I've heard a lot of people discussing swap space ... what is
this used for?

I've just started using GNU/Linux RH6.2, and I've allocated
all of the 2gb hd to it.  Was this a bad idea? Should I have
allocated some swap??

I'm not too late to do a full install.

Cheers for any help.

                --Yunus
-------------------------------------------------------------
To reply by e-mail replace 'lovelyspam' with 'Yunus'.
-------------------------------------------------------------

 
 
 

Swap!

Post by Leejay W » Sun, 31 Dec 1899 09:00:00



Quote:> I've heard a lot of people discussing swap space ... what is
> this used for?

> I've just started using GNU/Linux RH6.2, and I've allocated
> all of the 2gb hd to it.  Was this a bad idea? Should I have
> allocated some swap??

> I'm not too late to do a full install.

Hm.  A decent OS book could give a better, more thorough description
than I.  But basically...

Approximately, swap is to main memory as main memory is to cache; it
has a much larger capacity, but higher latency.  Pages containing
seldom-used data (that is still nominally in memory) can be written
to disk in order to make room for pages that ARE more actively used.

For instance, on a typical single-user Linux box, there are getty
(or mingetty, or other variants) running on all the virtual
consoles, but most are going to be completely idle.  They can be
swapped out to disk, since it is unlikely that they'll be used and
in the meantime that (physical) memory that is freed could be better
used for, say, Quake.

So if you've got 128MB of physical RAM and 256MB of swap (note that
*older*, 2.0.x kernels limited you to 128 MB per swap partition),
you might nominally have 200MB of stuff (code/data) stored in
"memory".  But if most of that belongs to programs that have been
idly waiting for keypresses for an hour, much can be stored on disk
so as to free up much faster physical RAM.

As to whether you need swap:  unless you need the disk space for
other purposes, it generally won't *hurt*, because if there really
isn't anything that can reasonably be swapped out, the kernel isn't
obliged to do so.  It really depends on how much memory you consume
on a regular basis (like using Netscape, StarOffice, and Civ:CTP
together might be a BAD idea).

Note that you can use either a swap partition or a swap file, as
well...

--

|--------------------------| he writes really bad haiku |
|   #include <stddiscl.h>  | readers all go mad         |

 
 
 

Swap!

Post by John Mille » Sun, 31 Dec 1899 09:00:00


Just an example of what my linux box uses:  With StarOffice, Netscape,
setiathome, and some other smaller programs running, about 26 Megs of swap
are in use.  I have 128Megs of RAM.  Certainly 2Gb of swap os WAY
overkill.

-John



> > I've heard a lot of people discussing swap space ... what is
> > this used for?

> > I've just started using GNU/Linux RH6.2, and I've allocated
> > all of the 2gb hd to it.  Was this a bad idea? Should I have
> > allocated some swap??

> > I'm not too late to do a full install.

> Hm.  A decent OS book could give a better, more thorough description
> than I.  But basically...

> Approximately, swap is to main memory as main memory is to cache; it
> has a much larger capacity, but higher latency.  Pages containing
> seldom-used data (that is still nominally in memory) can be written
> to disk in order to make room for pages that ARE more actively used.

> For instance, on a typical single-user Linux box, there are getty
> (or mingetty, or other variants) running on all the virtual
> consoles, but most are going to be completely idle.  They can be
> swapped out to disk, since it is unlikely that they'll be used and
> in the meantime that (physical) memory that is freed could be better
> used for, say, Quake.

> So if you've got 128MB of physical RAM and 256MB of swap (note that
> *older*, 2.0.x kernels limited you to 128 MB per swap partition),
> you might nominally have 200MB of stuff (code/data) stored in
> "memory".  But if most of that belongs to programs that have been
> idly waiting for keypresses for an hour, much can be stored on disk
> so as to free up much faster physical RAM.

> As to whether you need swap:  unless you need the disk space for
> other purposes, it generally won't *hurt*, because if there really
> isn't anything that can reasonably be swapped out, the kernel isn't
> obliged to do so.  It really depends on how much memory you consume
> on a regular basis (like using Netscape, StarOffice, and Civ:CTP
> together might be a BAD idea).

> Note that you can use either a swap partition or a swap file, as
> well...

> --

> |--------------------------| he writes really bad haiku |
> |   #include <stddiscl.h>  | readers all go mad         |

 
 
 

Swap!

Post by Yns » Sun, 31 Dec 1899 09:00:00



> Note that you can use either a swap partition or a swap file, as
> well...

Thanks Leejay for the explaination .... does linux automatically
use swap files or will I have to configure my system?

I currently have all of my 2gig disk for linux only - no swap
partitions.  In this case will swap files automatically be used?

Thanks again.

Yunus.

 
 
 

Swap!

Post by Leejay W » Sun, 31 Dec 1899 09:00:00


Excerpts from netnews.comp.os.linux.setup: 20-Apr-100 Re: Swap! by

Quote:> Thanks Leejay for the explaination .... does linux automatically
> use swap files or will I have to configure my system?

Hmm.  To be honest, I've never used a swap file, only a swap
partition.  However... it looks like, judging from the 'swapon'
command (which apparently is used for both files/partitions)
you'll actually need to invoke swapon.

IIRC most distro's startup files include a 'swapon -a' which will
cover everything in /etc/fstab marked 'sw'.  Individual files
probably shouldn't be listed there, so if you use a swapfile
vs a partition you may need to edit a startup file.

Quote:> I currently have all of my 2gig disk for linux only - no swap
> partitions.  In this case will swap files automatically be used?

Hrm.  Probably not automatically.  'mkswap' to initialize the swap
file, and then 'swapon' to actually tell the OS to use it.
--

|--------------------------| he writes really bad haiku |
|   #include <stddiscl.h>  | readers all go mad         |
 
 
 

Swap!

Post by Peter T. Breu » Sun, 31 Dec 1899 09:00:00


: > Note that you can use either a swap partition or a swap file, as
: > well...

: Thanks Leejay for the explaination .... does linux automatically
: use swap files or will I have to configure my system?

Automatically? What do you mean? It'll use a swap file if you tell it
to. It'll use a swap partition if you tell it to. No difference.

: I currently have all of my 2gig disk for linux only - no swap
: partitions.  In this case will swap files automatically be used?

I still don't know what you mean by automatically! In any case,
you have a very bad partitioning design. You have / and /var in the
same partition! See the Partition-HOWTO.

The normal design would be to separate at least / /var /boot /usr
/usr/local /home into different partitions. See the above HOWTO for
why, if it weren't obvious (and if you tell me "what if you run out
of space", then no, it ain't obvious to you, and you need to do some
more reading).

Peter

 
 
 

Swap!

Post by Basti » Sun, 31 Dec 1899 09:00:00




>> Note that you can use either a swap partition or a swap file, as
>> well...

>Thanks Leejay for the explaination .... does linux automatically
>use swap files or will I have to configure my system?

>I currently have all of my 2gig disk for linux only - no swap
>partitions.  In this case will swap files automatically be used?

>Thanks again.

>Yunus.

A swapfile is pretty easy to create:
   dd if=/dev/zero of=swapfile count=blocks
Where 'blocks' are 512b blocks, and 'swapfile' is the name of the file. To
create a 64megs file, just do
   dd if=/dev/zero of=/swapfile count=131072
Then mkswap the file
   mkswap /swapfile
And switch it on
   swapon /swapfile
If everything works fine (check with "free" if the swap is recognised), add
the following line to /etc/fstab
   /swapfile swap swap defaults 0 0

Bastian

 
 
 

1. MS-DOS Swap File vs. Swap Partition

Hello, All;

What performance difference, if any, should I expect to see between a
native Linux swap partition and a swap file residing on an MS-DOS
partition?

I'm currently using my Microsoft Windows swap file as a Linux swap
file, and I'm considering adding a dedicated Linux swap partition as
well.  If there's no performance benefit, I may as well just use a
larger Windows swap file.

Bruce

2. SUNWesm

3. Unwanted Swapping in 2.4.14-pre8, no swapping in 2.4.14-pre6aa1

4. PSX/N64 USB HID Device

5. Swap file VS Swap partition

6. second hdd

7. 20+ meg Swap partition setup, but top only reports 860k of swap available...

8. Problem posting news with TRN

9. Installing Win/Linux shared swap on old swap partition

10. 2.5.30 swaps with no swap device mounted!!

11. Linux Swap Partition and Win3.1 Swap File

12. How to make swap files instead of swap partions???

13. plenty of swap space, but keep receiving error "swap space limit exceeded"