LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-01-2007, 07:27 PM   #16
lakris
Member
 
Registered: Sep 2004
Location: Stockholm, Sweden
Distribution: Ubuntu, RedHat, SuSe, Debian, Slax
Posts: 102

Rep: Reputation: 15

Well, need arise if You want to run programs that wont fit in RAM. It is very simple. With swap You can run programs that You otherwise couldn't because of RAM limitation. Of course there is a performance hit because the OS must write out and read in pages from disc and this makes performance sluggish. The alternative is to NOT be able to run those programs.

The OS in itself run very fine on a few meg and doesn't need swap. In an initial state with swap there is a certain amount of stuff that is "sleeping" a lot and can be swapped out and free RAM for caching which will improve performance for running applications. But it is a guessswork done by the kernel and it doesn't always get it right.

There is NO rule that says "swap should be n times RAM". It all depends on what You expect to be running on it. A non-interactive server that just *does* some none time-critical stuff in a closet somewhere, well it can have lots of swap just to be able to do those large calculations and it doesn't matter to You when it is done, just that it is done, sooner or later. But I would hate to have a desktop or laptop that depends on swap to run an application. A small amount could be fine because there are always idle processes, but I'd rather buy some more RAM. I also think that 1GB should be more than enough for "normal" work, You would have to be doing some serious sound and movie editing to need more than that.

A recommendation: Run without swap for a while and see if You notice any difference. Depending on Your configuration and work it may go faster. When You hit Your head on the roof, You will notice.
Run with swap for a while and use the command free to see if it is actually used. xosview is another nice program that gives a good view of how memory is used. There are others of course.
Just allocate 1 or 2 Gigs for a swap. Or even just 512MB. You never know when it will come in handy and it doesn't really cost much in HD-space. But You don't want to be dependant on swap to run a time-critical and responsive (web-server, media-editing, file-server) machine.
 
Old 06-01-2007, 07:34 PM   #17
slackhack
Senior Member
 
Registered: Jun 2004
Distribution: Arch, Debian, Slack
Posts: 1,016

Rep: Reputation: 47
i would recommend at least swap equal to ram. the system is designed to use swap if it ever needs it for some reason. since you can't foresee all possible outcomes or events, it just doesn't make sense not to allocate some swap, imho. especially with multimedia operations, are you kidding me? my systems have hardly ever used swap, but the times they have, some kind of multimedia -- mplayer, video encoding, etc. -- invariably has been involved. i would use a gig.
 
Old 06-02-2007, 03:52 AM   #18
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
I'm not the OP, but let me ask you a question related to the swap partition usage.

My understanding is that a 32-bit OS can only access up to 4GB memory at once, physical or virtual. Does that mean that if you have 4GB physical RAM, the OS will never in theory be able to use the swap partition?

Thanks,
Dai
 
Old 06-02-2007, 04:17 AM   #19
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by daihard
My understanding is that a 32-bit OS can only access up to 4GB memory at once, physical or virtual.
Nope.
Processes are limited to to 4 Gig of virtual - with PAE, (x86) Linux can handle 64 Gig real.
Quote:
Does that mean that if you have 4GB physical RAM, the OS will never in theory be able to use the swap partition?
Nope.
Don't confuse process limits with kernel. Last I looked you could allocate 32 swap extents of 2 Gig each (x86).
 
Old 06-02-2007, 04:43 AM   #20
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by syg00
Nope.
Processes are limited to to 4 Gig of virtual - with PAE, (x86) Linux can handle 64 Gig real.Nope.
Don't confuse process limits with kernel. Last I looked you could allocate 32 swap extents of 2 Gig each (x86).
Thanks for the info!

Do you have any good reference to kernel and process limits that I can read up on?

Thanks again,
Dai
 
Old 06-02-2007, 12:34 PM   #21
marsm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 15
Why not simply just give yourself 1-1.5 GB and see how it goes? Better safe than sorry!

I gave my Ubuntu/GNOME 500MB swap to complement the 512MB RAM on my laptop and it kept crashing more than Windows ever did. Now with 1.5GB it's fine.

I guess you can always simply shrink/remove your swap partition if you really don't need it.
 
Old 06-02-2007, 01:02 PM   #22
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
Well, there is some room for variation here. The swap partition can be created now but it can also be set up only later, either as a simple swap file (the windows way) or as a separate partition.
 
Old 06-02-2007, 03:25 PM   #23
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by jay73
Well, there is some room for variation here. The swap partition can be created now but it can also be set up only later, either as a simple swap file (the windows way) or as a separate partition.
My personal concern is that if you have a swap partition, the OS may use it even when there's still unused physical memory available, which degrades performance. By not having a swap partition, you can force the OS to only use physical RAM... provided that you have plenty of it (like 4GB). Or are today's OSs smart enough that they never use swap unless they run out of physical RAM?
 
Old 06-02-2007, 05:05 PM   #24
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Or are today's OSs smart enough that they never use swap unless they run out of physical RAM?
Yes. Read about swappiness here: http://gentoo-wiki.com/FAQ_Linux_Mem...2.6_kernels.29

Read the argument here: http://kerneltrap.org/node/3000
 
Old 06-02-2007, 06:04 PM   #25
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
I think it's been established that:
- It is recommended that you have swap, but that it is not required.
- There is no hard rule that says how much swap you must have.
- For performance reasons, sleeping processes and latent memory data may be moved to the swap space for faster active processing.
- I'm awesome, and you can't do anything about it ...

As others have already stated, you should consider your memory (RAM and swap) configuration depending on what types of processes you are running. For instance, if you're just running a desktop for web browsing and word processing, you can get by with a general config, whereas if you're processing live and DV video that requires fast disk and memory access, you may want to boost your RAM amount to allow more of your memory to run in RAM, rather than swap, and you may also want to consider running your swap on a completely separate drive from your DV drive for even faster drive access.

Some here are stating that there's no real performance impact when the machine begins to swap to disk. But I can tell you from experience, that when you've greatly exceeded your RAM's ability to handle your stuff, and the hard drive begins heavily thrashing on swap, you'll see that performance drop.
 
Old 06-02-2007, 09:27 PM   #26
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by Quakeboy02
Yes. Read about swappiness here: http://gentoo-wiki.com/FAQ_Linux_Mem...2.6_kernels.29

Read the argument here: http://kerneltrap.org/node/3000
Thanks! Looks like sysctl is included in Fedora Core, which I use. That's certainly good news.

Let me just make sure I understand it correctly. The page states that a value of 100 in /proc/sys/vm/swappiness means "the kernel will always prefer to find inactive pages and swap them out." Is it the same as saying the kernel will never use the (hard-disk) swap partition? Or the other way around?

Thanks again,
Dai
 
Old 06-02-2007, 10:35 PM   #27
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Let me just make sure I understand it correctly. The page states that a value of 100 in /proc/sys/vm/swappiness means "the kernel will always prefer to find inactive pages and swap them out." Is it the same as saying the kernel will never use the (hard-disk) swap partition? Or the other way around?
I haven't experimented with this very much. The only reason I even encountered it was because I noticed the difference in memory usage when going from Sarge 2.4 to Sarge 2.6 and tracked it down. I believe that the 100 will very aggressively use swap space - perhaps to your detriment. IOW, nothing stays in memory unless it's active. I just use the default 60 and don't worry about it. The Gnome System Monitor rarely shows memory usage above about 350MB, but I don't do anything serious like AV editing on it. Like I stated before: if my 2GB system starts swapping, I'm not going to be a very happy user. Hell, I'd be unhappy with it way before it started swapping, just due to bus and CPU load issues. I only reason I have 2GB of memory because I Can.
 
  


Reply

Tags
partitioning, swap



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
swap partition dismas Slackware 1 10-07-2005 03:09 PM
Swap partition Mojojo Linux - Hardware 10 01-20-2005 05:12 PM
Can I have more than 1 Swap partition? Geeky_Kid Linux - Newbie 5 12-26-2003 01:26 AM
Newbie Installing Debian3 on m68k w/250M Partition Needs help creating swap partition AppleMac Linux - Newbie 2 11-01-2002 08:45 AM
swap.partition anoop_chandran Linux - General 3 12-28-2001 09:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:30 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
Open Source Consulting | Domain Registration