Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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).
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.