Question: Is swap partition mandatory in current day?
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
I don't remember a time when swap space was ever mandatory, although it was very convenient as recently as 10 years ago.
The only thing that comes to mind is, if you use "suspend to disk" and the tools were set up to make use of free swapspace for that purpose, then you'll have problems.
I keep a 1GB swap even though it never gets used. I work a lot with graphics and video, and I'd rather have it and not use it than need it and not have it there. I've been curious though, does a swap partition 'cost' anything besides disk space? Are any system resources used to manage it?
A swap partition is extra memory. In "normal" circumstances - browsing, writing letters, etc - you won't need a swap partition as you won't exceed your physical memory (I'm talking about computers with 1Gb or more of memory as most modern PCs do now). If you use things like Blender or animation programs or anything that is memory hungry, you will see that your swap pertition is used more and more.
I have 2G of ram and need a swap partition. Memory leaks mean that over time my memory usage goes up and I start eating into the swap partition. When this gets sufficiently bad (this particular box is on 24/7) I have to shutdown offending apps.
Now this may well be very unlike your situation and it may well be that a different cure would be better, but if you want your system to fail gracefully (slow down) when bad stuff happens rather than just hitting a wall, then a swap partition is a good idea.
It was never mandatory, but it's almost always a good idea to have one. I know when I open and edit large files, pictures, movies, the swap starts getting used a lot. I have 1 GB RAM, and about 1.8 GB swap.
I'd definitely say you should have swap unless you know what you are doing. Most people who have a decent amount of RAM (1GB+) should not need more than 512MB of swap ever unless they have special needs (some described above).
You should simply use as many resources as you would ever use at one time and check your swap usage. Give yourself some breathing room and set it accordingly.
With the cost of HDD in $/GB is low then why not have a swap. If your HDD is getting trashed with fluff then get rid of all that is not needed. Pack rats tend to keep everything, this is even true with files on a HDD.
"I've been curious though, does a swap partition 'cost' anything besides disk space?"
Yes. The memory manager tries to keep a certain amount of real RAM free; the exact details on how it makes decisions has changed over the years and is different between operating systems. Anyway, if a 'page' of memory has not been used for a long time (or at least not as frequently used as other pages) and the system needs a little more RAM, that page of RAM is written to disk and offered to whatever program requested more RAM. If the program that actually needed that swapped-out RAM then asks for it, a Segfault is generated and the memory manager attempts to read that information from disk, put it in RAM, and allow the program to continue running (possibly swapping out other pages to make room for this one). So you can imagine if all the software running requires much more RAM than is physically available, the entire computer will be slowed down waiting for data to be read/written on disk. For really heavy RAM users, the disk starts "thrashing" (constantly accessing data). This is very obvious on a toy OS like Win95 and Win98 in which the OS itself had huge memory leaks, and early releases of Win2K. Since then, MS seem to have discovered that memory leaks in an operating system is not a good thing.
Now, how much slower is Swap space vs real RAM? On disk it takes up to a few tens of milliseconds to place the read/write head in the correct position to fetch the data you want ('seek time'). How fast the data is read in depends on how fast the platter spins etc, but in either case is far slower than RAM - after all, the data is cached in RAM and possibly later transferred via 'direct memory access'. With the main RAM of computers, a 'read' or 'write' cycle takes, say, 60 nanoseconds. To transfer 4096 bytes (a typical 'page size'), that amounts to about 246 microseconds. This is a very conservative number; any number of tricks are used to transfer data at much higher rates when data is transferred in 'blocks'. Still, you're looking at about 12 milliseconds vs 246 microseconds - or roughly a factor of 48 for the 'best case' with the disk. Now this operation really forces the CPU to stop working for long periods because data must be transferred from system RAM to cache RAM. The cache is Static RAM and I've seen access times of about 5 nanoseconds for static RAM from decades ago; I have no idea how fast the CPU cache can run.
Some embedded systems use a kernel with the swap code completely removed. However, on a normal system you should always have at least a small amount of swap space available. The rules for how the kernel decides when to swap-out a page of memory are difficult to anticipate, and having no swap space avilable when the kernel expects it can lead to lock-ups. I ran without any swap for a very long time on both x86 and ppc machines before I finally was able to cause a lock-up -by compiling mozilla (with debugging code) on a ppc using ~512MB RAM. Having even a very small amount of swap space could save you from one of these lockups. Notice that the minimum amount of swap is just one page -4K.
If you don't want to 'waste' an additional partition, set up a swap file instead -you can always easily change the size of it to suit your needs.
With the cost of HDD in $/GB is low then why not have a swap. If your HDD is getting trashed with fluff then get rid of all that is not needed. Pack rats tend to keep everything, this is even true with files on a HDD.
I agree, I think the number of "pack rats" is growing exponentially with the size of hard drives. I have a 60 GB HDD and it's plenty of space for everything even with 1.8 GB swap which leaves 58 GB free for use. If it gets filled to about 8 GB free, then I clear out the crap, sort the rest where it needs to go, and if needed burn a backup DVD with stuff I don't use on a regular basis. No, that's not a good strategy for most people today, what they want in 4 x 1 TB drives in RAID0. Keep everything on there, and when one drive goes down it's game over, all your stuff is gone.
For my new computer, I'll be getting a meager 80 GB HDD. Why ? Because at one point I used to have a 160 GB HDD (on my desktop) and I never used most of the drive, there just wasn't enough junk to fill it
Yup, I brought up this question mainly because I am doing a fresh installation for my laptop. So just wanna listen to your guys opinions see whether the swap space is still necessary or not. So, I think it is still better to keep it for safe ;-p
And, my new installation have 2 GB of swap now + 4 GB of RAM, awesome...
And other cool thing is, although I am not in FBI wanted list, but I follow the README_crypt and built a fully encrypted file system now.
Oh Slackware, I love you so much~
I use one because I like to use hibernate feature on laptop and desktop. I also have 2GB RAM so if it wasn't for this I would probably try to do without one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.