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.
A question to the more enlightened than I. I know you can create swap space under Linux, I also know you can create a swap file. However in terms of performance is there an advantage to using swap space or a swap file, or is there no advantage at all? Just curious really.
Most modern desktop systems have so much physical memory that I hardly notice any swap usage anyway. I would guess the exclusive swap partition would be a better approach as it's a fixed location on the hard disk.
It's really up to you. Swap space is used very little these days. If you're just running a single disk-drive it really makes very little difference how you configure it.
Linux is probably the only system left that commonly uses swap-partitions. Both Windows and OS/X use swap-files.
Most computers these days have so much RAM ("chips are cheap") that swapping doesn't happen much. It's not nearly as critical as it used to be.
As qouted already by senior memebers in this thread. Swap space is not much used these days unless its a Oracle database box. If you want to really speed up the things, I would suggest you to use /dev/shm for your programs.. this can give you blitzering speed since shm is an interfacing shared memory segment device to RAM. Hence any transaction, like temporary file generation etc...on this tmpfs filesystem can greatly improve performance without affecting the CPU time at all. It also removes the I/O calls to hard-drive which in comparison to RAM is much slower.
If you are looking at doing hibernation kinds of things you'll want a swap partition intead of a swap file, otherwise 6 in one hand, half a dozen in the other.
if for nothing else it gives you the option of using suspend to disk
(if it ever gets working right)
not only do newer systems have larger RAMs but they have larger HDDs
so it's not that much of a sacrifice to give up 2x the size of your
ram for swap partition (on the outside tracks of your HDD)
this is a case where it's better to have it and not need it
than it is to need it and not have it
it's also not easy to go back and get it if you didn't start out with it
Swap will run faster if it is contiguous. If you create a swap partition then it will be contiguous. If you create a swap file it might be fragmented. So I recommend that you use a swap partition, not a swap file.
on the outside tracks of the hard drive
this is much faster than on the innermost tracks
witch is where most swap partitions end up being put
I thought it was already established that swap is mostly used for suspend (if it ever gets working) these days. So, why would swap need to be on the faster portion? Seriously, if you're swapping, you probably need to spend a couple bucks on more memory. It's cheap and fast.
NOTE: Large commercial servers may have different swap system needs than home desktops/servers.
If you need to use it much, would it be more important for it to be on outside tracks that are faster (and for it to be simple/contiguous as a partition), or for it to be near the files you are accessing when you need it, to cut down seek time? I don't know.
Obviously, a partition on a different hard drive than the files you would be accessing is even better. But normally that's not an option.
If you won't be accessing it much, wouldn't it be best to be a partition on the innermost tracks (highest logical numbers) to get it out of the way.
I never really understood the Linux "over commit" logic. But I expect sometimes Linux doesn't over commit enough. That may be an extra reason for a generous amount of swap space, even if it won't actually get used. Simple case: A big chunk of memory is allocated "copy on write". Linux requires some fraction of the total be available in either physical memory or swap space in order to permit the allocation. In fact (for my example) a much smaller fraction will actually get written and need physical space. With a big swap space, the operation succeeds and the swap space is never used. Without the big swap space the same operation fails.
I've seen that sort of failure (an operation needs a lot of swap space to avoid failing even though it never actually uses the swap space) fairly often in Windows, not Linux. But that may be because the things I've done in Windows are more likely (vs. the things I've done in Linux) to trigger that flaw, rather than just because the Linux need for swap space (as a consequence of imperfect memory management) isn't as stupid as Windows.
I thought it was already established that swap is mostly used for suspend (if it ever gets working) these days. So, why would swap need to be on the faster portion? Seriously, if you're swapping, you probably need to spend a couple bucks on more memory. It's cheap and fast.
NOTE: Large commercial servers may have different swap system needs than home desktops/servers.
you would want the fastest suspend to disk and resume from hibernation that you can get
the out side tracks read and write much faster the data moves under the heads faster and the tracke are larger
hard drive controllers work on just one drive at a time so for another hard drive to help you would need anther and another controller
even with 2Gigs of ram doing silly things like running 2 or 3 X servers each with KDE at once will dip into swap
I some times do this showing off linux to windoze geeks
(at times like this the last thing I want is for the system to thrash around looking for swap space)
my laptop is maxed out on the amount of ram that can be plunged in
so pugging in more ram isn't always an option
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.