LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 05:35 AM   #1
samstar
Member
 
Registered: Apr 2007
Distribution: suse 10.2
Posts: 324

Rep: Reputation: 31
Is swap partition necessary?


Hi all,

I'm building a new computer for some multimedia applications, including Mythtv (as a backend and frontend). It'll have a small window manager like fluxbox, and runs an AMD X2 64bit processor. In the past, I've never had a computer with more than 512MB of memory. No programs I've run have ever taken up all the memory, and that goes for the swap partition too.

Now I'm installing no less than 1GB of memory on the system, and I don't expect to use hibernation at all. Is making a swap partition really necessary? Could not adding one break compatibility if the system or programs check for a swap and can't find one?

I'm asking this because I want to free as much space on my hard disk as possible. Oh, I will be installing the latest Gentoo on it as well.

Thanks,
Sam
 
Old 06-01-2007, 06:01 AM   #2
xp_newbie
Member
 
Registered: Nov 2006
Posts: 86

Rep: Reputation: 16
IIRC, it is possible to run Linux without a swap partition (unlike Windows which requires a minimum of 2MB), but if you do so, you have to make sure that you will never need even a single byte more that the amount of physical memory you have...

Can you guarantee that? Even so, why would you want to limit yourself like that? Nowadays disk space is cheap and you can easily afford "waisting" 2GB on a swap partition.

BTW, I have 3GB RAM in my Ubuntu 6 workstation, and I am still dedicating a 2GB swap partition (unused by the system most of the time).

HTH,
Alex
 
Old 06-01-2007, 06:04 AM   #3
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
No you should be fine without. Just keep in mind that if you do run out of physical RAM the kernel will start killing processes, if this happens you know what's gone wrong
Another option would be to at first use a file as your swap space instead of a seperate partition. This way you could easily remove it, although beware that it gets much worse performance if it ever does have to swap to that file.

It shouldn't cause any compatability problems, memory is managed by the kernel so no application should ever be trying to read or write to swap directly AFAIK
 
Old 06-01-2007, 06:05 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Linux will run fine without swap.
Until it needs it. Then death can swift and ugly.

Is it worth it for a bit of (extremely) cheap disk ???.
 
Old 06-01-2007, 06:07 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by tkedwards
... although beware that it gets much worse performance if it ever does have to swap to that file.
Hasn't been true for a long time.
If the OP is going to be using Gentoo, he'll surely be using a 2.6 kernel. There will be no performance penalty.
 
Old 06-01-2007, 06:12 AM   #6
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
IIRC, it is possible to run Linux without a swap partition (unlike Windows which requires a minimum of 2MB), but if you do so, you have to make sure that you will never need even a single byte more that the amount of physical memory you have...
I always thought Windows uses swap file and not a partition. In Linux you can also use a swap file instead of a swap partition, though the regular way to go is to have a partition. Like said, nowadays when disks are already going to hundreds of gigabytes, having a 0,5-2 gigs for swap isn't much (I have 512M swap, it's too big for what I need).
 
Old 06-01-2007, 06:17 AM   #7
samstar
Member
 
Registered: Apr 2007
Distribution: suse 10.2
Posts: 324

Original Poster
Rep: Reputation: 31
Thank you all for the replies.

Quote:
Linux will run fine without swap.
Until it needs it. Then death can swift and ugly.
Quote:
if you do run out of physical RAM the kernel will start killing processes
Well, what happens if you run out of both RAM and swap space? Doesn't the same thing happen? Personally, I think 1GB memory is a real overkill for a desktop workstation. Don't take it the wrong way, I still value your advice, and am contemplating making a backup swap partition anyway. If I do so, will the computer use it, even if the physical memory isn't used up yet?

As well as saving space, I'm making this setup because, since it'll be a multimedia system, I'm trying to limit hard disk access plus the hard disk access noise.

I appreciate the feedback,
Sam
 
Old 06-01-2007, 06:50 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by samstar
Well, what happens if you run out of both RAM and swap space? Doesn't the same thing happen?
Yes ...
Maybe.

As things start getting ugly, kswapd can use the swap as "elbow-room" - tends to smooth out any problems. And hopefully you'll see it happening and (attempt to) fix the problem.
But yes, if it all fills, the oom_killer will come into play. And you can bet it'll kill the biggest user; the one you *really* don't want killed.
Always seems to happen.

Swap has the added benefit of becoming a repository of idle anonymous pages. Freeing up (real) RAM - so you wind up with more to use. The swap-out tends to be very slow - average a couple of pages an hour maybe - so you shouldn't notice it.
 
Old 06-01-2007, 07:08 AM   #9
lakris
Member
 
Registered: Sep 2004
Location: Stockholm, Sweden
Distribution: Ubuntu, RedHat, SuSe, Debian, Slax
Posts: 102

Rep: Reputation: 15
Quote:
Originally Posted by samstar
Thank you all for the replies.
Well, what happens if you run out of both RAM and swap space? Doesn't the same thing happen? Personally, I think 1GB memory is a real overkill for a desktop workstation. Don't take it the wrong way, I still value your advice, and am contemplating making a backup swap partition anyway. If I do so, will the computer use it, even if the physical memory isn't used up yet?

As well as saving space, I'm making this setup because, since it'll be a multimedia system, I'm trying to limit hard disk access plus the hard disk access noise.

I appreciate the feedback,
Sam
Same thing, the kernel wont start any processes if there isn't enough memory. Doesn't matter if it's in RAM or on disc. What happens if You do have a swap partition is that the kernel WILL use it and MAYBE it will affect Your performance. By default the kernel prioritice disk caching, and prefers to swap out data and code to swap instead of decreasing the disk cache allocation. So You may have a situation where this policy creates bad performance for your application, even though it wasn't really needed, ie there was enough ram. Sometimes with k2.4 I had to decrease swap space to force the kernel to use ram in preference to swap for my specific application.
I recommend having a swap partition because you may need it sooner or later. And experiment with swapon -a and swapoff -a to see if it really matters. 1GB RAM should be good enough for almost anything and maybe You wont need swap.
If You use k2.6 You can also modify this policy by changing the value in /proc/sys/vm/swappiness, see for example http://gentoo-wiki.com/FAQ_Linux_Memory_Management.
 
Old 06-01-2007, 07:09 AM   #10
samstar
Member
 
Registered: Apr 2007
Distribution: suse 10.2
Posts: 324

Original Poster
Rep: Reputation: 31
Ok, I guess it wouldn't hurt to experiment with it. I can always re-install gentoo if I don't like it (Kidding). I'll probably start with just a small swap, maybe 256, or 512MB, just as a buffer, kinda.

Quote:
Originally Posted by syg00
I always presume you have a verified B-A-C-K-U-P before taking any advice given.
Worry not! I'll back up my swap just in case

Sam
 
Old 06-01-2007, 08:01 AM   #11
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
I would actually make a case for using some form of swap, especially on Gentoo. You will be doing lots of compiling - the liveCD didn't allow me to install anything from it so it is the first thing you'll be doing - and the fastest way of doing so is by loading the process (partly) into RAM - which leaves less RAM for you to use while the system is working away. Having some swap available could be pretty valuable in such cases.

Last edited by jay73; 06-01-2007 at 08:03 AM.
 
Old 06-01-2007, 08:01 AM   #12
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Swap is most definitely NOT necessary. Most of my computers have no swap--they're diskless so there isn't even any place to put swap. None of them have 1gig of RAM; one of them only has 48megs of RAM.

For a multi-media computer with a lightweight WM like fluxbox, you're never going to come close to running up against 1gig of RAM usage. Just go ahead and install without swap. You'll never regret it.
 
Old 06-01-2007, 10:44 AM   #13
Red Barchetta
Member
 
Registered: Mar 2007
Distribution: Mandriva Free
Posts: 41

Rep: Reputation: 15
As far as I know, NO OS really NEEDS swap space, but not using it CAN GREATLY reduce performance, especially on machines with low amounts of RAM.

As a general rule, again with any OS providing it, I try to set swap space to 2.5 times the physical RAM on that machine, but can be adjusted in either direction.

BTW - Not sure who was talking about it, but yes Windoze dose use a swap file instead of a swap partition (at least up to XP, Vista I have not used at all yet, so no clue there), but it CAN be set to a size of zero. In general that OS dose not like this at all, but if you have a large amount of RAM, it will function fine.
 
Old 06-01-2007, 06:50 PM   #14
samstar
Member
 
Registered: Apr 2007
Distribution: suse 10.2
Posts: 324

Original Poster
Rep: Reputation: 31
Thanks again guys, I didn't expect so many divers replies.

Remember, guys, I'm talking about 1GB physical memory, I've never had so much memory (including swap space) in a computer before, and I don't think I've ever used up my memory on those systems. So there's one bit still confusing me.

Red Barchetta, you mentioned that swap should be 2.5x the physical memory. But I heard that swap partitions cannot exceed 2GB in size. Is this true? How can the "swap space = 2x physical ram" rule still hold true when people are using >1GB memory nowadays?

Sam
 
Old 06-01-2007, 07:10 PM   #15
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
No matter how much swap you put on it, if you start swapping with 1GB (or more) of RAM in a system, you probably won't like it much. Lately I've just been suggesting 1GB swap space so that people won't argue with me about it.
 
  


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 01:08 PM.

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