LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices



Reply
 
Search this Thread
Old 07-10-2009, 01:03 PM   #1
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 362

Rep: Reputation: 38
What is the recommended swap space for 32 bit Linux


I have a 32 bit version of Linux (any distro) running with 4GB of RAM. What would be the maximum recommended swap space?
 
Old 07-10-2009, 01:21 PM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
Depends on what you are going to be doing. If you're doing heavy video editing with your 4GB of RAM, I'd use another 4GB swap. If you're just doing general computing with some gaming and whatnot, you can probably get by with 1GB or less.
 
Old 07-10-2009, 01:35 PM   #3
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 362

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by pljvaldez View Post
Depends on what you are going to be doing. If you're doing heavy video editing with your 4GB of RAM, I'd use another 4GB swap. If you're just doing general computing with some gaming and whatnot, you can probably get by with 1GB or less.
But anything over 4GB of swap space would be a waste, isn't it? As this is a 32 bit OS.
 
Old 07-10-2009, 01:38 PM   #4
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by pljvaldez View Post
Depends on what you are going to be doing.
Absolutely.

Quote:
If you're doing heavy video editing with your 4GB of RAM, I'd use another 4GB swap.
I don't understand that one. We're talking about 32 bit. "heavy" video editing is still likely to be just one big process. If there is only one big process you have no need for 4GB of swap on top of 4GB of ram.

Maybe you hope to leave some enormous video recompression task running in low priority all day while you intermittently use the system for other activities, so you think it can swap out when other tasks need that ram. Unfortunately, Linux doesn't really prioritize ram use, just CPU use. If that video recompression task needs its max 3GB of ram, it will probably make the whole system crawl even if you set its priority low and have room that it could have swapped out. If it needs far less than 3GB of ram, then it didn't need the room to swap out. Either way 4GB of swap won't help it.

Quote:
If you're just doing general computing with some gaming and whatnot, you can probably get by with 1GB or less.
I agree.

If you are running major background processes, such as multiple copies of a database server, or any long running low priority memory intensive tasks, you want enough swap space to let all the anonymous memory of all your background jobs get swapped out when you are running some big foreground job that should make better use of the ram for file caching.

Or maybe you plan to switch away from some monster spreadsheet in Open Office Calc (which is very wasteful of virtual memory) while you do some other task in the foreground (rather than close the spreadsheet and reopen it when you want to work on it again).

But there is no general rule. How should we have any clue what the total size of anonymous memory in all your background jobs is. You didn't give us any clue what background jobs you're even going to run.

With 4GB on a 32 bit system, we can be pretty sure the foreground task (whatever program you're actively using at any moment) doesn't need any swap space. Maybe you have a better guess what programs will be left open but inactive and how big they will be.

Quote:
Originally Posted by the_gripmaster View Post
But anything over 4GB of swap space would be a waste, isn't it? As this is a 32 bit OS.
I've read a lot of contradictory stuff about what swap space can be used (vs. you need multiple swap partitions instead of one big one). I'm not sure, but I think that whole issue is obsolete. I think even 32 bit Linux can use giant swap partitions if you leave enough large processes open (stalled unless you want the whole system to crawl) that you have some use for that swap space.

Last edited by johnsfine; 07-10-2009 at 01:55 PM.
 
Old 07-12-2009, 03:23 PM   #5
NeddySeagoon
Gentoo support team
 
Registered: May 2009
Location: 56N 3W
Distribution: Gentoo
Posts: 178

Rep: Reputation: 40
the_gripmaster,

A 4G swap will allow you to hibernate to swap. You can't actually use 4G RAM on a 32 bit install, unless you use PAE, as some of it must be remapped above the BIOS, the memory mapped I/O space and the PCI space.
On many systems you loose about 800Mb.

As swap is only used for dynamically allocated RAM, if you don't need to hibernate, 1G should be plenty.
If you need that much swap, you really need a 64bit install and more RAM.
 
Old 07-12-2009, 03:48 PM   #6
corbintechboy
Member
 
Registered: Sep 2003
Location: Kentucky
Posts: 480
Blog Entries: 1

Rep: Reputation: 51
I have 4 gigs of ram to. Drive space is so cheap nowadays and I always use 2.1 gigs for swap. This kinda puts me middle road and I actually have never touched that much swap.
 
Old 07-12-2009, 04:49 PM   #7
Zarniwoop79
Member
 
Registered: Jul 2009
Location: Göteborg, Sweden
Distribution: Mandriva
Posts: 31

Rep: Reputation: 3
Max 2GB with 32 bits OS

Hello!

I see the discussion above, and although I'm not sure about the swapspace, the problem is that a 32-bit OS can't address more than 2gb of memory, so there is not much use to have more than 2gb of memory unless you use a 64-bit OS.

Regards,

Zarniwoop
 
Old 07-12-2009, 06:31 PM   #8
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
Quote:
Originally Posted by the_gripmaster View Post
... the [B]maximum recommended swap space?
That seems like an odd question; if I scour round the internet looking for odd recommendations I'm sure that I can find some that are insanely large; 32G or more.

Under no circumstances would that seem like a good suggestion for an ordinary user, so I wouldn't recommend that you do it (but it would be the answer to the question that you asked, whether its what you wanted to know, or not).

For the more normal case, 1 or 2 G would seem adequate (but, I'll repeat, just because it would be sensible in the normal case doesn't make it the answer to your question).

Suspend to disk seems to need more, but whether 4 G guarantees that it will work is possibly open; sensibly, I doubt it will fail.

Quote:
I think even 32 bit Linux can use giant swap partitions
I'd like to see definitive information on this; I saw what purported to be definitive information, but on re-reading it carefully I couldn't make out whether it was only early kernels that had this limitation, or not. In any case, even if this does still apply, it only means that you have to use multiple swap partitions (...or files...) in order to get to the required size, which isn't much of a pain. Well, which isn't really a pain at all at install time, it may be a pain if you decide that you need more swap later, for some reason. In that case, one swap partition plus a swap file to meet he requirement?

Quote:
32-bit OS can't address more than 2gb of memory, so there is not much use to have more than 2gb of memory unless you use a 64-bit OS.
I can see what you are getting at, but you get the details wrong.
firstly, with a 32 bit address space, the limitation is, as was already stated, 4G minus some bits, which is usually around 3.2 G, not 2.

Additionally, there is PAE, which is a 32 bit system, and that can address way more than 4 G (but there is a limitation of a 4 G address space per process, which for most use cases for which 32 bit is in contention isn't a real limitation). Although I wouldn't suggest that PAE is a sensible solution for other than marginal cases around 4+ G, and I really suspect that you ought to be strongly considering a true 64 bit system if you want much more.
 
Old 07-12-2009, 11:08 PM   #9
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
It seems everybody got the information about using 4 GB of RAM on a 32-bit OS and swap memory wrong. A 32-bit OS can handle 4 GB with out any problems. PAE comes in and takes the fun out of it, so close to a gigabyte of RAM is used to help address the memory. PAE is not necessary to handle 4 GB of RAM on a 32-bit setup. PAE is used to handle pass 4 GB of RAM, but PAE is not required for setups up to 4 GB of memory. Unfortunately, PAE can not be turned off.

Swap memory can be any size. It has no limits of size and quantity. There are limits, but you will not ever get close to them. The size and quantity depends on the matter of preference and use. If you see that you need more swap, you can always add more by fly swapping. The advantages of a fixed swap memory size and fly swapping is a whole another topic.

My swap memory load with 2 GB of RAM is no more than 10 MB even during playing games. It might be a little more, but that is about it.
 
Old 07-13-2009, 08:33 AM   #10
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by Electro View Post
PAE comes in and takes the fun out of it,
Meaning what?

Quote:
so close to a gigabyte of RAM is used to help address the memory.
??

PAE (or 64 bit mode), at the hardware mapping level, requires more than one page of overhead per 512 pages used. (vs. non PAE 32 bit mode, which requires more than one page of overhead per 1024 pages used).

Normal memory use won't make optimal use of the mapping, so it may take significantly more than one per 512. Also the Linux kernel adds significant software data structures, I'm pretty sure those are at least as big as the hardware data structures, so overhead must exceed one page in 256.

But we're still talking a very small fraction of total ram dedicated to the mapping overhead. A gigabyte of overhead is an absurd estimate for any ordinary system.

There are also various kinds of time overhead in the mapping. The time overhead of PAE will be about double the time overhead of non PAE 32 bit, and the time overhead of 64 bit will be slightly higher than PAE. But again, we are talking about tiny numbers. Even though that overhead in 64 bit is more than double what it is in non PAE 32 bit, that difference is generally not noticeable, because the quantity being doubled started as a small fraction of one percent of total CPU time.

Quote:
PAE is not necessary to handle 4 GB of RAM on a 32-bit setup.
False. Without PAE, a 32 bit kernel can use up to 3 point something GB of ram (the exact value depends on BIOS details, but 3.25GB is a common value).

Quote:
PAE is used to handle pass 4 GB of RAM, but PAE is not required for setups up to 4 GB of memory.
PAE is needed to pass 4GB of physical address space. But 4GB of ram requires more than 4GB of physical address space.

Quote:
Unfortunately, PAE can not be turned off.
Meaning what?

A 32 bit Windows kernel can decide at load time whether to use PAE. If you want to turn PAE on or off (reverse what was chosen on the last boot) you need to reboot.

A 32 bit Linux kernel has that decision made at the time the kernel is built. If you want to turn PAE on and off, you need to have two different kernels and switch which one you select on reboot.

Most 32 bit copies of Windows have a license restriction to 4GB of physical address space, so even when you turn on PAE, you still get only 3 point something GB of ram.

PAE in Windows also enables execution protection, which is used to defend against certain kinds of malware. I'm not sure about that detail in Linux.
The type of malware that defends against usually depends on the user surfing the net with root privileges and on the user running exactly the build of the browser or some plug-in that the malware author designed for (vs. some recompile of open source done by some distribution maintainer). Those things are less likely to be true in Linux, so the malware would probably fail anyway, even in non PAE 32 bit.

Quote:
My swap memory load with 2 GB of RAM is no more than 10 MB even during playing games. It might be a little more, but that is about it.
I don't think this thread is about swap or memory use on a typical system. The OP has at least implied it is about unusually high swap use.

It isn't surprising that your 2GB system is lightly loaded enough that it has no significant use of swap. But it also isn't relevant.
 
Old 07-13-2009, 05:48 PM   #11
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
johnsfine, for someone that is smart can be stupid like some others. PAE is used to address pass 4 GB of RAM. It is programmers counting for all the contingencies that users will do during upgrading their computer. An 80386 can handle 4 GB of physical RAM because the manual says so. Back before PAE is implemented and during the transition to PAE, some motherboard manufactures includes an option to completely turn off PAE.

The reason why I said that using PAE takes the fun out of it is because basically it turns 4 GB and more of memory for 32-bit operating systems into virtual memory instead of physical memory. Physical memory and virtual memory are completely different. A computer accessing physical memory has no performance penalty while virtual memory has a performance penalty. Also virtual memory consumes memory for addressing. The penalty is caused by the addressing the memory.

The reason why I stated that close one gigabyte is used for PAE is actually the truth although if you want to get technical it is about 896 MB of RAM that is used. Since PAE turns physical RAM into virtual memory, it is basically 1 GB of RAM that you can not use. It makes it worst for every 4 GB of RAM that is installed. Also Linux is a virtual memory operating system, so two layers of virtual memory is used and this penalizes the computer. Linux virtual memory mapping is either 1 to 3, 2 to 2, and 1 to 3. This ratio is related to user space and kernel space. PAE only lets a 32-bit processor or a 32-bit operating system to use past 4 GB, but only in 4 GB chunks with a cost of flip-flopping between user space data and kernel or database data.

PAE has nothing do with protection. The protection that you are explaining about is the NX bit or Enhanced Virus Protection which double checks if the program will have buffer over flows. Hackers uses buffer over flows as one of their techniques to gain entrance into computers. This feature helps somewhat, but a real fix is better which will take a long time from the processor manufacture and programmer to implement. The NX bit is an easy work around for the many or several thousand bugs of 80x86. However the NX bit requires PAE because PAE provides information where data is stored.

About swap memory size and quantity is completely a matter of preference and use. A computer with 128 MB of RAM and using KDE as the desktop/window manager of choice, swap should be at the least double the amount of RAM. A computer with 4 GB of RAM and using KDE. Swap space is not necessary. I say start with around 256 MB of swap space for a setup that has 4 GB. If see that you need more, add swap space with fly swapping. If using a lot of fly swapping, then you have to re-think about your swap space size. Also optimizing Linux's virtual memory settings can help reduce thrashing to swap space during use.
 
Old 07-13-2009, 06:39 PM   #12
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Here's the wiki on PAE. NOTE that with PAE, "The x86 processor hardware is augmented with additional address lines used to select the additional memory, so physical address size is increased from 32 bits to 36 bits. This increases maximum physical memory size from 4 GB to 64 GB." That's 36 bits of addressing, not 64. There is a discussion of the differences in how the Page Table is used.

http://en.wikipedia.org/wiki/Physical_Address_Extension
 
Old 07-13-2009, 08:06 PM   #13
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by Electro View Post
for someone that is smart can be stupid like some others.
I didn't expect to convince you of anything. I was bothered that the incorrect things you are saying would confuse other people reading this thread. I thought I should try to balance that.

At least for this thread, we're way past the point of diminishing returns. My apologies to anyone who is reading this thread and wants the correct information and doesn't know which to believe.

I've read a bunch of your posts, where you are talking about things I'm interested in but don't really know, such as the "TDP" of CPUs. In those you really sound like you know what you are talking about. So first that makes me worry that to someone who doesn't know this topic, you will sound like you know what you're talking about and you'll spread a lot of confusion. Second I worry that I'm trusting you in those threads (obviously not this one) where it sounds to me like you know what you're talking about and I'm accepting misinformation.

I disagree with almost everything in your last post, but it is obviously pointless to try to refute it detail by detail.

Quote:
Originally Posted by Quakeboy02 View Post
This increases maximum physical memory size from 4 GB
Wikipedia is a great resource, very informative and usually correct. In this case it is unfortunate that someone chose to over simplify by using that phrase "physical memory size".

People who actually put a full 4GB of ram in systems that only support 4GB of physical address space constantly ask why they can't use all their memory. All the places on the net that incorrectly say or imply you can use a full 4GB of ram without PAE are just confusing people. The bottom line, when you actually try it, is you can't. Some of your 4GB of ram must be either lost or mapped beyond the first 4GB of physical address space.

An x86 CPU manufacturer is free to say you can have a full 4GB of ram without PAE, because you could design a computer with that same CPU that can support a full 4GB of ram (if it does all its I/O some other way that doesn't tie up address space and it doesn't try to be compatible with any of the PC bus or bios standards). But no one would design such a computer and if they did, it wouldn't run Windows nor any existing Linux distribution. In PC compatible computers, a significant chunk of the first 4GB of physical address space must be tied up by things other than memory.

Last edited by johnsfine; 07-13-2009 at 08:34 PM.
 
Old 07-13-2009, 11:49 PM   #14
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Quote:
Wikipedia is a great resource, very informative and usually correct. In this case it is unfortunate that someone chose to over simplify by using that phrase "physical memory size".
Bad turn of phrase, I guess. I believe the point they're trying to make is that the physical memory footprint for 32 bits is 4GB, not that 4GB of RAM will be completely used. To be honest, when I put in 4GB for the first time, it took me a while to realize that there was memory mapped IO and probably lots of other stuff I didn't think about that had to be accounted for and which was occupying a lot of that memory space. To further compound the issue, I had a memory mapped on-board video, and I still don't know for sure how that interacted with memory. The BIOS was configurable, but Linux, or perhaps the video chip, used something else.

It's all good, John.
 
Old 07-14-2009, 05:51 AM   #15
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
johnsfine, If you think I am providing misinformation of what I type than you are wrong.

PAE or Physical Address Extension is basically virtual memory. Any 80x86 processor since 80386 has support for virtual memory. PAE works simply by dividing up memory into user space and system space. Since a 32-bit processor can only see 4 GB of RAM, PAE sets up as a viewer for the processor. PAE lets the processor view all installed memory by showing only 4 GB of RAM at a time, but at a price of taking up memory for logging user space memory into system space. The reason why I said that it can take up to 1 gigabyte of memory is related to the amount of hardware that the computer has connected. More hardware, more memory is being taken up.

PAE can be turned off by changing a certain register bit to off. Also PAE have to be turned off in software. Sure the NX bit will not work but do not need it if the system is running software that is not written sloppy which can cause buffer over flows.

Saying that an 32-bit x86 processor can not handle 4 GB of RAM with out any facts is completely wrong. A 32-bit x86 processor can handle 4 GB of RAM. The amount of memory used is dependent on the amount of hardware that is installed and drivers does not have to be loaded to see the effects. This happens on any setup.

TDP has no standard definition, so that is why it is confusing. Basically, TDP is a mean value spec which means no relation to true power total power consumption. A 65 watt TDP processor's true TDP can be close to 160 watts.
 
  


Reply

Tags
ram, swap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting swap space in linux linuxguy08 Linux - Server 3 12-11-2008 04:07 PM
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 04:20 AM
How to disable swap space entry for a process (Sticky bit?) Pandamatak Linux - General 3 09-25-2006 07:17 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 02:23 AM
using windows swap space in linux jayakrishnan Linux - General 9 02-19-2003 03:52 AM


All times are GMT -5. The time now is 10:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration