Linux.com

Feature: System Administration

All about Linux swap space

By Gary Sims on December 03, 2007 (4:00:00 PM)

Share    Print    Comments   

When your computer needs to run programs that are bigger than your available physical memory, most modern operating systems use a technique called swapping, in which chunks of memory are temporarily stored on the hard disk while other data is moved into physical memory space. Here are some techniques that may help you better manage swapping on Linux systems and get the best performance from the Linux swapping subsystem.

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

However, swapping does have a downside. Compared to memory, disks are very slow. Memory speeds can be measured in nanoseconds, while disks are measured in milliseconds, so accessing the disk can be tens of thousands times slower than accessing physical memory. The more swapping that occurs, the slower your system will be. Sometimes excessive swapping or thrashing occurs where a page is swapped out and then very soon swapped in and then swapped out again and so on. In such situations the system is struggling to find free memory and keep applications running at the same time. In this case only adding more RAM will help.

Linux has two forms of swap space: the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.

To see what swap space you have, use the command swapon -s. The output will look something like this:

Filename        Type            Size    Used    Priority
/dev/sda5       partition       859436  0       -1

Each line lists a separate swap space being used by the system. Here, the 'Type' field indicates that this swap space is a partition rather than a file, and from 'Filename' we see that it is on the disk sda5. The 'Size' is listed in kilobytes, and the 'Used' field tells us how many kilobytes of swap space has been used (in this case none). 'Priority' tells Linux which swap space to use first. One great thing about the Linux swapping subsystem is that if you mount two (or more) swap spaces (preferably on two different devices) with the same priority, Linux will interleave its swapping activity between them, which can greatly increase swapping performance.

To add an extra swap partition to your system, you first need to prepare it. Step one is to ensure that the partition is marked as a swap partition and step two is to make the swap filesystem. To check that the partition is marked for swap, run as root:

fdisk -l /dev/hdb

Replace /dev/hdb with the device of the hard disk on your system with the swap partition on it. You should see output that looks like this:

 Device Boot    Start   End     Blocks  Id      System
/dev/hdb1       2328    2434    859446  82      Linux swap / Solaris

If the partition isn't marked as swap you will need to alter it by running fdisk and using the 't' menu option. Be careful when working with partitions -- you don't want to delete important partitions by mistake or change the id of your system partition to swap by mistake. All data on a swap partition will be lost, so double-check every change you make. Also note that Solaris uses the same ID as Linux swap space for its partitions, so be careful not to kill your Solaris partitions by mistake.

Once a partition is marked as swap, you need to prepare it using the mkswap (make swap) command as root:

mkswap /dev/hdb1

If you see no errors, your swap space is ready to use. To activate it immediately, type:

swapon /dev/hdb1

You can verify that it is being used by running swapon -s. To mount the swap space automatically at boot time, you must add an entry to the /etc/fstab file, which contains a list of filesystems and swap spaces that need to be mounted at boot up. The format of each line is:

<file system>     <mount point>     <type>     <options>        <dump>    <pass>

Since swap space is a special type of filesystem, many of these parameters aren't applicable. For swap space, add:

/dev/hdb1       none    swap    sw      0       0

where /dev/hdb1 is the swap partition. It doesn't have a specific mount point, hence none. It is of type swap with options of sw, and the last two parameters aren't used so they are entered as 0.

To check that your swap space is being automatically mounted without having to reboot, you can run the swapoff -a command (which turns off all swap spaces) and then swapon -a (which mounts all swap spaces listed in the /etc/fstab file) and then check it with swapon -s.

Swap file

As well as the swap partition, Linux also supports a swap file that you can create, prepare, and mount in a fashion similar to that of a swap partition. The advantage of swap files is that you don't need to find an empty partition or repartition a disk to add additional swap space.

To create a swap file, use the dd command to create an empty file. To create a 1GB file, type:

dd if=/dev/zero of=/swapfile bs=1024 count=1048576

/swapfile is the name of the swap file, and the count of 1048576 is the size in kilobytes (i.e. 1GB).

Prepare the swap file using mkswap just as you would a partition, but this time use the name of the swap file:

mkswap /swapfile

And similarly, mount it using the swapon command: swapon /swapfile.

The /etc/fstab entry for a swap file would look like this:

/swapfile       none    swap    sw      0       0

How big should my swap space be?

It is possible to run a Linux system without a swap space, and the system will run well if you have a large amount of memory -- but if you run out of physical memory then the system will crash, as it has nothing else it can do, so it is advisable to have a swap space, especially since disk space is relatively cheap.

The key question is how much? Older versions of Unix-type operating systems (such as Sun OS and Ultrix) demanded a swap space of two to three times that of physical memory. Modern implementations (such as Linux) don't require that much, but they can use it if you configure it. A rule of thumb is as follows: 1) for a desktop system, use a swap space of double system memory, as it will allow you to run a large number of applications (many of which may will be idle and easily swapped), making more RAM available for the active applications; 2) for a server, have a smaller amount of swap available (say half of physical memory) so that you have some flexibility for swapping when needed, but monitor the amount of swap space used and upgrade your RAM if necessary; 3) for older desktop machines (with say only 128MB), use as much swap space as you can spare, even up to 1GB.

The Linux 2.6 kernel added a new kernel parameter called swappiness to let administrators tweak the way Linux swaps. It is a number from 0 to 100. In essence, higher values lead to more pages being swapped, and lower values lead to more applications being kept in memory, even if they are idle. Kernel maintainer Andrew Morton has said that he runs his desktop machines with a swappiness of 100, stating that "My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful."

One downside to Morton's idea is that if memory is swapped out too quickly then application response time drops, because when the application's window is clicked the system has to swap the application back into memory, which will make it feel slow.

The default value for swappiness is 60. You can alter it temporarily (until you next reboot) by typing as root:

echo 50 > /proc/sys/vm/swappiness

If you want to alter it permanently then you need to change the vm.swappiness parameter in the /etc/sysctl.conf file.

Conclusion

Managing swap space is an essential aspect of system administration. With good planning and proper use swapping can provide many benefits. Don't be afraid to experiment, and always monitor your system to ensure you are getting the results you need.

Gary Sims has a degree in Business Information Systems from a British university. He worked for 10 years as a software engineer and is now a freelance Linux consultant and writer.

Share    Print    Comments   

Comments

on All about Linux swap space

Note: Comments are owned by the poster. We are not responsible for their content.

How much swap do you need?

Posted by: Anonymous [ip: 212.123.159.163] on December 03, 2007 07:00 PM
After reading the part: "How big should my swap space be?" I am still not sure how much I do need. According to rule 1, I should have 2 times the RAM which is 2x4G = 8Gbyte for my desktop. However I think that is a huge overkill. When reading rule 3 I get the idea that 1G is already a lot. So what should it be?

I think it is also important to take suspend / hibernating into account. Suspend can write the memory contents to the swap partition, so it would be important to have a swap space that is at least larger than your RAM size. Further your swap space size depends a lot on the applications you are running, so I understand that no easy formula can be given. Taken all into account I would use a swap space size, for a modern desktop of 1*RAM + 512MB. If you know you are using applications that use a lot of data (photos with multiple layers for example) add another 512MB. Therefore 5G would be good for my system. Adding much more has not much use, you will notice your machine slowing down if it starts to swap to often and then you know you need more RAM (not more swap...).

#

Re: How much swap do you need?

Posted by: Anonymous [ip: 70.185.160.3] on December 03, 2007 08:34 PM
I think 1.5 gigabytes would be good enough for your needs. 8GB is just overkill, I agree. O_O

#

Re: How much swap do you need?

Posted by: Anonymous [ip: 91.140.30.21] on December 03, 2007 09:06 PM
Actually it's a lot simpler for desktop usage. First of all you should make the swap space the first partition of your disk in order to have higher access times. Concerning size: Swap 2 * RAM but NOT greater than 2GB. This means, if you have 1 GB ram, your swap partition should be 2 GB. But if you have more than 2GB Ram your swap partition should STILL be 2GB. In your case then your swap should be 2GB :)

#

Swap partition position

Posted by: Anonymous [ip: 89.180.80.55] on December 05, 2007 12:00 PM
It is not that easy... I recommend <a href="http://www.linuxquestions.org/questions/slackware-installation-40/should-i-put-the-swap-partition-at-the-beginning-or-the-end-of-the-drive-365793/">this discussion</a> on the subject.

#

Re: How much swap do you need?

Posted by: Anonymous [ip: 61.247.251.158] on December 04, 2007 09:33 AM
Keep it twice the physical memory or 1 GB MAX

#

A question for guru

Posted by: Anonymous [ip: 76.105.92.252] on December 04, 2007 02:21 AM
If I understand correctly, the idea of having the swap space is to create a virtual memory large enough for efficient operation for systems with limited RAM.

The question is: will one ever use up both RAM and swap space? If so, what happen then? System freezes?

#

Re: A question for guru

Posted by: Anonymous [ip: 61.247.251.158] on December 04, 2007 09:37 AM
In windows , a swap file will get created in a such a situation, in linux i have no idea. I think memory management in linux is so good that such a situation will never happen

#

Re(1): A question for guru

Posted by: Anonymous [ip: 10.100.209.150] on December 04, 2007 10:17 AM
No, it will happen in linux, but the last resort, the OOM killer, will usually save the system.

The swap file is always present in Windows, but normally grows dynamically when more swap is needed unless the user
has set a fixed swap file size.


- Peder



(I guess you could modify it, anonymous... /peder)
[Modified by: Anonymous on December 05, 2007 02:32 PM]

#

Re: A question for guru

Posted by: Anonymous [ip: 10.100.209.150] on December 04, 2007 10:13 AM
Normally the kernels OOM (OutOfMemory) killer will kick in and try to kill "the right process" and thereby freeing up memory.

It does a reasonably good job at finding that but sometimes it kills the wrong process, like X.

If it, for some reason, fails alltogether you'll have a freeze.



- Peder

#

Re(1): Memory management

Posted by: Anonymous [ip: 76.105.92.252] on December 04, 2007 03:30 PM
Thanks for the comment.

Your comment reminds me that I used to install Cache or Cache XP under Windows to help recover RAM when the it became low at certain level or to recover RAM periodically at a certain interval, usually 60 minutes.

I have been using Linux for quite a few years now, rarely boot into Windows any more, but this certainly remind me of that piece of application for RAM and cache management. Under Windows, I remember the system became quite unresponsive when RAM is low. However, I have not experienced unresponsiveness under Linux yet. I had a few time doing a hard reset because the system just froze up in Linux, but very few times that happen.

The first thing I learn when I started playing with Linux installation was that the general rule of thumb for setting the size of the swap file or partition was 2 times the size of physical RAM. I kept this rule until most of my PCs were upgraded to 1GB of RAM, then I set the swap size to 1GB. My logic was that I have 2GB of virtual memory. 2GB! That should be enough for normal use. My PCs used to have less than that (1GB) under Windows, so it's got be better with 1GB + 1GB swap under Linux.

#

Re: A question for guru

Posted by: Anonymous [ip: 10.1.0.66] on December 05, 2007 08:49 AM
If swap is up system freezes. I got it when I used rsync on a 1Tb (disc) machine. rsync writes all his file data in memory before it begins to copy, so I got a memory and swap overflow.

pol@kbr.be

#

All about Linux swap space

Posted by: Anonymous [ip: 63.196.84.93] on December 04, 2007 03:21 AM
But still haven't answered eternal unanswered question of swap: How much slower is a swap file than a swap partition?

#

Re: All about Linux swap space (speed)

Posted by: Anonymous [ip: 10.100.209.150] on December 04, 2007 10:26 AM
I'd say marginally.

If the swap file is really fragmented it might be an issue and perhaps also depending on
where on the disk the file/partition resides. I'd imagine a file/partition on the outer rim of the disc is slightly faster
than on the inside.


- Peder

#

All about Linux swap space

Posted by: Anonymous [ip: 88.65.198.255] on December 04, 2007 08:38 AM
That really depends of what you do! I would also say twice the ram size, but if you render images with a 3d program then you need even more!

#

swap priority?

Posted by: Anonymous [ip: 58.174.146.149] on December 04, 2007 02:54 PM
I have 2 swap partitions. How do I set them to the same priority? The best I could do, using "swapon -ap", was to get both my partitions' priorities to '0'. Using negative numbers (I was going for -1) didn't work. Is "0" OK as priority?, If not, how do I change them both to -1?
Thanks.

#

Re: swap priority?

Posted by: Anonymous [ip: 212.123.159.163] on December 04, 2007 06:14 PM
you can do that in the /etc/fstab file

/dev/hda2 none swap sw,pri=-1 0 0

/dev/hdb2 none swap sw,pri=-1 0 0

#

Priority must be nonnegative.

Posted by: Anonymous [ip: 64.81.97.251] on December 04, 2007 09:11 PM
Negative priorities can give unexpected behavior. From the man page for swapon(8):

priority is a value between 0 and 32767. Higher numbers indicate higher priority.

#

WHAT is the MAX swappage size .......

Posted by: Anonymous [ip: 213.84.72.151] on December 05, 2007 08:48 AM
Apart from desktops and their reasons, servers sometimes tend to need more then 2GB (by applications demands or for other reasons) if the server is configured with say..... 16GB of memory.

In AIX/Solaris/HPUX I can create swapspaces (paging spaces) as much as I want, where I want but more important AS BIG AS NEEDED....... It seems to me (according to the Red hat documentation) that Linux is not capable of addressing more the 2GB for each swapspace. So in order to have 4GB in swapspace I need to create 2 swapspaces!!!

Can somebody confirm this or is this an err in the documentation?

Regards
TheFactory

#

Re: WHAT is the MAX swappage size .......

Posted by: Anonymous [ip: 10.100.209.150] on December 05, 2007 02:42 PM
On a side note, having multiple swap partitions can actually be a speed-up.

If you're not running a RAID system but have multiple hard drives, adding a separate
swap partition on each of them makes the swapping behave like raid0 (striping)
assuming they have the same priority (set in fstab)



- Peder
[Modified by: Anonymous on December 05, 2007 02:50 PM]

#

Re(1): WHAT is the MAX swappage size .......

Posted by: Anonymous [ip: 213.84.72.151] on December 07, 2007 12:21 PM
mmmmmm I know about spreading and optimizing, but lets keep it plain and simple 2 disks just mirrored for the OS and thats it, no striping. Swapspace must be big in order to fulfill install requirements of some software.
Your answer is clear but that does not answer my question. Is the limit 2GB per swapspace or not?

Best regards

#

All about Linux swap space

Posted by: Anonymous [ip: 138.253.184.200] on December 05, 2007 09:10 AM

I think the suggestion here is quite high. Always remember that when you are using swap like the main memory, the system crawls: it will stop responding to your keystrokes, mouse movements, etc. The real use of swap is that if you have a few programs started but for a long time having nothing to do (or allocates some RAM for which it won't touch at all for a long period of time), they can be put into swap, and their space is given back to the OS for caching frequently used disk content. So swap should make you *fast*, not *slow*. If swap ends up making you slow and eventually you reboot the machine, you lose.



What will happen if the system run out of swap? Some programs will be killed by the OOM killer. Most of the time, the sudden increase in RAM usage is due to a newly run program going funny, and what you actually see is not randomly dying programs, but instead that new program ends up saying "cannot fork" or some other messages that looks weird. If that won't happen often you have no reason to worry: you would be rebooting your system anyway even if you have the swap, since you need to wait for too long. Indeed, it is perhaps better that you don't have that much swap: having the bad program dying means that you don't have to reboot. If that happens even when you are not running "really bad" programs, you know you are due for a RAM upgrade (not a swap expansion).



I'd instead suggest a current desktop system (say, with 512MB or more RAM) to use no more than the same amount of RAM you've got, most likely just half of that amount is sufficient. In load-end/old laptops you might have slightly higher, e.g., I'd configure 192MB swap for a 128MB RAM laptop. But the "twice the RAM" is a figure that is far too much for Linux, where the system does not need to reserve a slot in the swap space for each physical memory page it has.



The amount to use for busy servers should be even less. If by "server" it really means "Apache servers", the real way to go is to carefully calculate the amount of RAM that each of the process/thread would be using, and configure the server to fork out that number of children right at the beginning, and to respawn whenever their VM load is quite a bit larger than what you expect. The swap required should really be minimal. This is needed because servers are not very tolerant to sudden drop in performance: when you get excessive load, swap starts to be used, the performance drops, the queue lengthens, more processes are waiting, more swap is used, more performance is lost, and the cycle continues until you eventually finds that you cannot even ssh into the box and the only thing you can do is to reboot. Better to let some of the connections waiting, or even randomly die.


#

All about Linux swap space

Posted by: Anonymous [ip: 161.85.127.139] on December 05, 2007 10:45 AM
Is it necessary to be able to suspend to disk that the swap space is twice the RAM size?


Or perhaps the regularly recommended swap size PLUS the RAM size, to be able to have both fit into the swap...?


Or is swap size == RAM size enough?


Or is it possible to have swap size < RAM size, and Linux will still manage to suspend to disk?


On a side note, I have tested disk performance with swap at the start and at the end, hdparm shows about 2x speed at the start of the drive (outer ring)... So indeed, if your swap partition gets used (not a lot of memory for the things you do with your machine, or you like to use suspend to disk), put it at the start of the drive.

#

All about Linux swap space

Posted by: Anonymous [ip: 213.84.147.226] on December 05, 2007 11:43 AM
For desktop usage also take at least the size of your RAM, so that suspend-to-disk will work.


PS. I can modify all comments... seems site admin should have a look.

PPS. The original poster is right, I just edited their comment, which was not my comment.
[Modified by: Anonymous on December 05, 2007 10:17 PM]

#

if there are some logs to show the swap usage status

Posted by: Anonymous [ip: 140.113.1.98] on December 05, 2007 12:10 PM
i wish i could view some logs or status that monitoring swap usage with MRTG or other tools.

my swap space always is seldom used, so that i think swap partition often waste disk space.

i always follow the suggestion:

Partition Scheme

http://www.linuxquestions.org/questions/debian-26/partition-scheme-253754/

---

/swap --2X RAM or 500MB whichever is smaller, i.e., there is no reason to have a lot of swap space unless you really use your system in relatively extreme ways. The old 2X RAM rule is just that--an old rule. Now that most modern machines have plenty of RAM, you don't need swap very often at all. You certainly don't need GBs of it as some like to do--that is just a waste of hard drive space.

---

so, my max swap size is 500mb, maybe it's suitable to most environment.

#

Re: if there are some logs to show the swap usage status

Posted by: Anonymous [ip: 80.56.200.208] on December 07, 2007 10:51 PM
write a xinitd vmstat wrapper or measure memory and i/o and if mem > max and i/o high its swapping ;-)

#

Definitive Answers

Posted by: Anonymous [ip: 58.179.211.19] on December 05, 2007 12:51 PM
If Linux runs out of memory and swap space, it does not crash. It creates a swap file (or, at least, finds some space on /) and adds it to the swap pool. This causes major disk thrashing, but at least the system is still running. I know; I used to have Ubuntu on an old iMac with 128 megs of RAM and 122 megs of swap, and both of those were full on startup ;-)

Unless you are doing some seriously intensive stuff, you do not need more than 512 megs of swap. I have 1 gig of RAM and a 600 meg swap file, and the most swap that is ever used is 33 megabytes with plenty of RAM space still available. I once ran a test with The Gimp where I opened a huge number of large images, but my memory usage + swap usage still didn't come close to my actual RAM capacity.

If you find that your swap gets almost nil usage, then do yourself a favour and comment it out in /etc/fstab, then reformat the partition and use it as /tmp or something.

#

Re: Definitive Answers (Not)

Posted by: Anonymous [ip: 10.100.209.150] on December 05, 2007 02:39 PM
It creates a swap file (or, at least, finds some space on /) and adds it to the swap pool.


Not any distro I know about.

Is there any documentation of this?


- Peder

#

Re(1): Definitive Answers (Not)

Posted by: Anonymous [ip: 76.105.92.252] on December 05, 2007 05:31 PM
I find this hard to believe too without some official document to backup. After all, wouldn't the kernel guys know?

If Linux were capable of fixing itself, so to speak, why would we even bother creating swap space in the first place?

#

All about Linux swap space

Posted by: Anonymous [ip: 89.136.186.184] on December 06, 2007 01:49 AM
There's one neat trick you can use to take advantage of multiple swaps. Use the "rd" kernel module to create a swapfile in a ramdisk and give it a higher priority than the swap on HDD. This way when you're only swapping occasionally you can get away with minimal performance decrease, whereas when you really need to swap you still got the HDD available.

But you'll have to determine for yourself how big to make the ramdisk swapfile. It depends on many things, such as your application usage patterns and how much RAM you have. It would be useful to log the output of "free" to a file every N seconds or monitor it with rrdtool to see where the limit between "casual" and "heavy" swap usage lays for you.

I have 768 MB of RAM, 512 MB of HDD swap and 32 MB of ramdisk swapfile. It seems to cover regular desktop usage (Firefox, OpenOffice, email, Pidgin etc.)

#

Re: All about Linux swap space

Posted by: Anonymous [ip: 10.100.209.150] on December 06, 2007 07:27 AM
So you're using RAM to have a place to swap to when the RAM gets full? Not a very good idea IMHO.

I'd rather suggest trying to avoid unnecessary swapping by adjusting the swappiness (/proc/sys/vm/swappiness).

See this for some discussions: <a href="http://kerneltrap.org/node/3000">http://kerneltrap.org/node/3000</a>


However, making a ram disk and using as /tmp might be a good speedup in some cases


- Peder

#

All about Linux swap space

Posted by: Anonymous [ip: 71.175.86.110] on December 06, 2007 08:42 PM
Using 2 gigs RAM, I run the highly-addictive XOSVIEW in the corner of my screen, which graphically alerts you to hardware functioning, including SWAP.
I have only seen activity on the Swap areas once that I can remember in 3 years.

Great little applet which will calm your worries about RAMage, etc.

#

Don't swap get more RAM

Posted by: Anonymous [ip: 80.56.200.208] on December 07, 2007 10:48 PM
Swapping on a busy server e.g. a webserver is rather pointless. Don't let your servers swap !

ps all about swapping, nothing about vmstat ?

#

All about Linux swap space

Posted by: Anonymous [ip: 59.101.29.253] on December 07, 2007 11:09 PM
Re. swapping being interleaved when there are swap partitions on two separate HDDs: a long time ago an AIX tuning guru told me that if you have to interleave your swapping to improve performance, then your *real* problem is that insufficient RAM is leading to such high levels of swapping in the first place. The correct fix for the problem is to add more RAM. (If you have a second HDD you are better off mirroring with mdadm or LVM for reliability; this can also lead to performance improvements depending on system configuration and workload - typically mirrored disc writes are a little slower, whereas mirrored disc reads are a little faster).

With regards to the old chestnut 'how much swap is enough?', be aware that the rule of thumb '1.5 to 2 times the size of physical memory' dates back to when systems typically had less physical memory than they do now, so if you have a large amount of memory you can get away with a proportionally smaller swap partition. The correct answer to the question is 'it depends ...' (on the size of physical memory, number of competing processes, degree to which code is shared between active processes, number of users, database requirements [for example Oracle's SGA is locked in memory for performance reasons], and so forth). Personally, unless I am aware of a particular issue or requirement, I stick with the default amount of swap as at installation and monitor usage from time to time (this satisfies the I.T. maxim 'keep it vanilla and keep it simple'). I also set 'swappiness' to '0' in order to favour code over data; if I needed more caching, I would add more physical RAM.
[Modified by: Anonymous on December 07, 2007 11:27 PM]

#

All about Linux swap space

Posted by: Anonymous [ip: 96.4.122.190] on December 11, 2007 06:01 PM
hey i have a question, i have 2 computers one is my main with 2gigs of ram and ubuntu gave me 5gigs of swap partiton, on my secondary computer it only has 384mbs of ram, and runs xp, its slower than what i was use to it being (really slow). But i have a virtual machine on my main computer with the 2gigs ram + 5gigs swap, and i set the virtual ram for it to only about 160mbs, most of the time i'm only running 1 program on the virtual machine and same goes for my secondary computer, but the VM with 1/3 the ram of my secondary computer runs awesome fast, why is this?

Computer RAM Swap Speed
Main 2gigs 5gigs super fast
secondary 384mbs none super slow
VM (in main pc) 160mbs none super fast



#

Weird, all that about "N gigabytes is the Right Amount for your use"...

Posted by: Anonymous [ip: 99.240.152.84] on January 10, 2008 09:13 PM
The ONLY objectively valid way to know what the right amount of RAM+Swap is, for a given use, is to run that use on a system with more-than that amount of total RAM+Swap, and run it through even-heavier use than what is normal, and SEE what RAM+SWAP usage REALLY is, not theoretically-calculated-to-be, and then. . .

Get RAM up to above-that if possible, and if not, then add Swap to top up to somewhere beyond that level.

Even with 4GB of RAM, this machine, the way I use it, hits swap sometimes, and sometimes up to 2GB ( yes, the machine crashed more than once due to out-of-memory, when some program went bananas ).

According to http://www.novell.com/linux/techspecs.html Swap can be *64* GB in size, and one can have 32 swap-partitions!!

( check the Kernel Limits tab on that page )

All this goes to show clearly, that the optimal way to set up a system is to prototype!

Set it up with too-big a /, /tmp, /var, /opt, /usr, /home etc. & waaay too big a Swap, then. . .

install EVERYTHING you're going to need, then. . .

run EVERYthing, all at once, with as many tabs/windows/files open at once, & keep it up for a good 48 hours, then. . .

look at total RAM+SWAP & see what one needs to do, & also see what the /opt and /usr filesystems really need ( about 2x what is actually-used, so future apps have somewhere to be, and future bloated updates & add-ons do too: OpenClipArt anyone? )

THEN. . .

reconfig the partitions, & re-install everything for the actually-working-machine. eXtremeProgramming's *prototype-first* is right, in this case, completely.

#

8 GiB swap recommended

Posted by: Anonymous [ip: 172.16.1.157] on January 14, 2008 06:24 PM
I have struggled to run an Ubuntu system using Firefox, OpenOffice, Gaim/Pidgin, and other desktop applications with only 2 GiB of swap. After a couple weeks the swap fills up and the system freezes. (This was with 384 MiB RAM, but similarly difficult on a 2 GiB RAM machine.)
One solution is to monitor swap and start killing and restarting processes once swap gets up over 80%.
Another solution is to have more swap. I now recommend 8 GiB swap for a desktop system.
(This is also based on the idea that a user should not have to either reboot or restart their applications. I'd rather have more swap than have to restart Firefox or reboot.)

#

All about Linux swap space

Posted by: Anonymous [ip: 90.134.246.11] on January 24, 2008 05:11 PM
Is there a methods to prevent that a certin process is swaped out at all?
I run a low memory system here (64MB, Upgrade not possible :( ) where most processes are not reaction time critical. However, one is and it frequently gets swapped out because it is mostly idle wating for requests over network. When swapped out it causes a really annoying delay of multiple seconds on requests.

#

All about Linux swap space

Posted by: Anonymous [ip: 66.186.253.75] on February 14, 2008 03:12 PM
The swapless system will NOT crash if it runs out of memory. This is why OOM killer is for.

#

This story has been archived. Comments can no longer be posted.


 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya