Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
With a swap partition one can choose where on the disk it resides and place it where the disk throughput is highest.
Yes, but I would place it where the disk throughput is lowest!
In a modern system, swap is there for insurance, not for heavy use. Let files that really get used have the beginning (faster) part of the disk.
If you have too little ram for the active portion of the anonymous data in use by your programs, then swap speed is critical. With swap in the fastest position on disk, you could have a really slow system instead of a really incredibly slow system. But I don't think that is the situation for anyone asking current questions about swap. If you have too little ram for your workload, get more ram.
The concept that there is a speed advantage in placement on disk is another hoary old chestnut that should be discarded. The I/O elevator(s) in use on almost all systems negate that premise completely.
Not to mention disk caching - and yes, swap now uses (compressed) cache to reduce any meagre physical I/O that does actually occur.
Yes, but I would place it where the disk throughput is lowest!
In a modern system, swap is there for insurance, not for heavy use. Let files that really get used have the beginning (faster) part of the disk.
If you have too little ram for the active portion of the anonymous data in use by your programs, then swap speed is critical. With swap in the fastest position on disk, you could have a really slow system instead of a really incredibly slow system. But I don't think that is the situation for anyone asking current questions about swap. If you have too little ram for your workload, get more ram.
If i have understand well, and it is true what you all say, then it is better a swap file: you can put it in the first part of disk, it is more easy and more fast its access, it garantees more performance and it is more easy to manage (you can resize it how you want). May be a little difference only what file system you want to use and by its performance depend the performance of the swap.
Last edited by zemir; 08-19-2011 at 06:08 AM.
Reason: error typing
About systems with swap or without swap, today i have found some tests that i have made on my old desktop some years ago: it had 512mb of ram and slackware with 2.4 kernel. Without swap some applications does not works well and it often did crash during startup, example openoffice or gimp (in this case, i think, the memory is not workload at 100%, but kernel use swap); as well as did not work correctly some small applications and utilities that did resident in memory, they often did freeze. The situation did change completly with swap, file or partition; the same ram size or its double seems to be a good solution. I do not know you, but i do not trust of a system without swap.
Last edited by zemir; 08-19-2011 at 11:41 AM.
Reason: error typing of the ram value
On a desktop system, where the chance of actually using swap space is relatively small anyhow, a swap-file probably works just fine and it is perhaps somewhat easier to manage. Many operating systems use this technique by-default. The impact of one strategy vs. another can be expected to be "negligible" because the predicted use of swap is also, "negligible." RAM is now plentiful and cheap. (The "buck-a-meg" pricing model that was once contemplated by Japanese silicon manufacturers fortunately blew up in their faces.)
@syg00
(magnetic) disk drive is a lot faster at outer sectors.
there is one disadvantage with swap partition, you use up one of four primary partitions. now, it is possible to put swap on extended/logical partition, but it could produce some errors (at least it did in my case).
perhaps fragmentation might be problem when using swap file.
I think that the main linux distros should have in theirs install process the choice between swap file or partition; it seems to be more better first or second, it depend by the different cases.
However there are not never very important differences in performance, may be a bit more better a swap file in a first primary partition.
I think the swap file is not very common choice, from now and in the future these posts should have the effect to change the opinion and the habitudes of a lot of you ;-)
Even in a desktop system you have several processes accessing
disk at the same time, so the discussion about where to put
which files is pretty mote - most of the time spent will be
head movement of the disk, not on sequential reads from one
region of disk; more so in server class machines.
And while swap may not be heavily used in desktop system
with loads of RAM to spare the kernel paging out unused
or less used files may still make a noticeable performance
improvement by using the freed up RAM for caching of actually
heavily used bits.
I don't think that having swap, and swap in a separate
partition, is obsolete just because RAM is cheap. Even
on a box w/ 4GB I saw free RAM dwindling, and SWAP growing
ever so fast when e.g., using calibre to convert HTML docu
to epub for easy reading on an android pad. W/o swap the
OOM killer would have struck.
Even in a desktop system you have several processes accessing disk at the same time, so the discussion about where to put which files is pretty mote - most of the time spent will be head movement of the disk, not on sequential reads from one region of disk; more so in server class machines.
s/mote/moot/
This is precisely the point. And the I/O elevators delay and consolidate I/O's to better utilise the disk. You have no say in the matter in a normal setup. And yes, swap does get included.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.