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 03-17-2009, 08:49 PM   #1
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31
Not using swap?


What are the consequences of running a linux box without a swap partition? I ask because I want to install linux (probably slackware) onto compactflash, which, as a solid state disk, has a limited number of writes before starting to go bad. Specifically, this would be a wireless router/dns/dhcp box.

Are there specific attacks/etc that exploit such a set up? What exactly is supposed to happen when you run out of memory and you have no swap, and how do embedded systems handle this situation?
 
Old 03-17-2009, 09:55 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, it's entirely possible to run Linux (embedded or desktop) without swap. In fact, I'll bet most Linux desktop users have enough RAM and run few enough apps that, strictly, speaking, they don't even *need* swap.

No, there aren't any special exploits you need to worry about.

And yes, if you don't have swap ... and a process needs more memory than it can get ... it will either crash (best case) ... or keep on going (probably corrupting the memory that it does have, until it eventually crashes).
 
Old 03-17-2009, 09:55 PM   #3
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Nothing would really happen, the system would just get very slow.

If you have enough RAM there is no need for swap. Older kernels did actually require there be a swap partition, even if it never used it, but that went away some time ago.

You need to look at what the expected load of this device will be, and how much RAM you can get into it in terms of your budget and the board's physical capacity. Get as much RAM as you can into it, and don't worry about it.
 
Old 03-17-2009, 09:58 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Ms3fgx -
Quote:
Nothing would really happen, the system would just get very slow.
I respectfully disagree. I believe that the "get very slow" part occurs when you *have* swap ... and RAM gets tight enough that you start using it.
 
Old 03-17-2009, 11:03 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
AFAIK, when a process is inactive for a long time, it's memory is swapped in. If it isn't needed again, or rarely, such as a startup program, this will free up regular memory for the system & your programs to use. However, you are right that you don't want to use swap when you only have flash or an SSD instead of a hard drive. You also want to disable the updating of access times.

The Asus eee pc also goes further by using the unionfs mount the system partition read-only to protect it with a writable partition over it to allow editing. ( I don't have a eee pc. It is possible to have a cache ram filesystem overlayed over the flash, but I don't think that the eee pc goes this far. ) The unionfs isn't a part of the official kernel yet (AFAIK) but with the eee pc using it, the development may have accelerated and it may be adopted in the future.
 
Old 03-17-2009, 11:05 PM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by paulsm4 View Post
Ms3fgx -

I respectfully disagree. I believe that the "get very slow" part occurs when you *have* swap ... and RAM gets tight enough that you start using it.
True. But, can you present a case where 4GB of RAM isn't equivalent (and faster under load) to 2GB RAM plus 2GB swap. This is my personal opinion, but considering all the parts of your system (extremely fast CPUs and fast modern hard disks) I don't think the difference in how long it takes an OS to crash will be remarkably different (or useful) between pure RAM and the equivalent of RAM plus swap. Sure, disk is cheap enough these days that adding a couple GB of swap makes absolutely no difference in the amount of disk storage available, but how long would it really take to churn through 2GB of swap with a leaky program?

In the case of the original post, Go For It! Monitor your memory load for awhile, and if you never actually reach a high percentage of memory used, then you have nothing to worry about. Another thing for you to consider: If you were to hit the reset button on this new machine, while in use, would there be any consequence other than aggravation? IOW, would there be any data loss? That's generally the determining factor in my eyes.

Have fun!
 
Old 03-18-2009, 03:23 AM   #7
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by abolishtheun View Post
What exactly is supposed to happen when you run out of memory and you have no swap, and how do embedded systems handle this situation?
  • Supposed to close down 'non-mission-critcal' stuff...I've never actually seen this work succesfully, so I don't know if that's worthwhile.
  • Most embedded systems won't have virtual memory at all, so swapping won't be a possibility. Of course, in the case of most embedded systems, you don't add extra programs and the manufacturer can do worst-case testing to ensure that the amount of memory in the box is always adequate (note that this isn't a statement that they always get this right).
 
  


Reply



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 - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 12:47 PM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 12:57 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

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

All times are GMT -5. The time now is 04:03 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