[SOLVED] Yet another SWAP question: Should I resize?
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.
I know this topic has been disucssed to death and that there is no one truly optimal SWAP size for any case, but hear me out.
I have nearly 3gb RAM and a 250gb hard disk on my Lenovo laptop, running Ubuntu 10.04 LTS. Being a newbie, I chose the default install option, and the installer set up an 8gb SWAP space. That's nearly 3xRAM.
I am asking because I've been reading that in the old days, when RAM was more scarce, the swap should be 2xRAM, but currently I believe I have plenty of RAM and that the SWAP should be 2xRAM at best.
Since I will be switching operating systems in few weeks (Fedora LXDE or Xfce) and possibly pre-partioning for dual boot, should I choose my own SWAP size? Or should I trust the automatic installer?
Is there a likely gain from choosing SWAP of, say, 5gb?
The 2xRAM rule of thumb is way outdated. If you would need so much RAM that it would need 6GB (or even the 8GB given to you by the installer) of swap to run your workload the machine would be slow as hell. On a normal desktop machine (which includes laptops) 1-2GB should be more than sufficient, unless you want to use hibernate. In that case the swap partition should be at least the size of your physical RAM.
6 or more GB would simply be a waste of space.
Do you use Hibernation? The usual size of swap is the same as RAM so yours could be 3Gb, Even when it shows a lot of RAM in use there is a lot cached too so all good and there is no swap in use at all! How about your partitions space? Are things getting too big and space too small?
a 250gb hard disk
...
Is there a likely gain from choosing SWAP of, say, 5gb?
The maximum gain is that making SWAP 3GB smaller allows you to make some other partition 3GB larger.
How important is that to you? Do you have a 250GB drive because you need that much? Or do you need much less than that and have it because that is what was convenient to buy? Or do you need more than that and upgrading is inconvenient and you frequently move things to offline storage because you are out of space?
Next question, what is the downside of reducing swap from 8GB to 5GB. That amount of swap is basically insurance. In case of software memory leak, things slow down smoothly and let the problem be more easily diagnosed, rather than failing sooner in a harder to diagnose way. In case you start running certain unlikely large tasks, your system can handle it (maybe slowly) rather than fail. All very unlikely.
I don't know how you use your system. For ordinary use with your system specs the upside of reducing your swap size is small and the downside smaller. Basically, don't care.
@ TobiSGD
I never use hibernation and I'm just a regular desktop user, so clearly I'm wasting space here. Just hoping it's not affecting the performance.
@ ukiuki
Are you saying that my SWAP could be 3gb even though free -m shows 8gb?
I only have the SWAP and the root partition, and I haven't noticed anything unusual, yet.
The maximum gain is that making SWAP 3GB smaller allows you to make some other partition 3GB larger.
How important is that to you? Do you have a 250GB drive because you need that much? Or do you need much less than that and have it because that is what was convenient to buy? Or do you need more than that and upgrading is inconvenient and you frequently move things to offline storage because you are out of space?
Next question, what is the downside of reducing swap from 8GB to 5GB. That amount of swap is basically insurance. In case of software memory leak, things slow down smoothly and let the problem be more easily diagnosed, rather than failing sooner in a harder to diagnose way. In case you start running certain unlikely large tasks, your system can handle it (maybe slowly) rather than fail. All very unlikely.
I don't know how you use your system. For ordinary use with your system specs the upside of reducing your swap size is small and the downside smaller. Basically, don't care.
I'm actually only using about 30% of the hard drive, trying rather to keep large stuff on my external device. This is mainly because I just don't like having much stuff on my internal disk, not because of space scarcity.
But it's good to know that excessive SWAP only means less storage and not decreasing performance. Then I won't be losing much sleep because of this.
But I'm still wondering why Ubuntu installer would assign so much SWAP in the first place.
But I'm still wondering why Ubuntu installer would assign so much SWAP in the first place.
My guess is that you have 4GB of physical ram installed and either a BIOS misconfiguration or not using the PAE kernel (or maybe a limitation of the hardware) prevents you from using a significant chunk of ram.
I'm guessing the Ubuntu installer looked at how much ram is physically present, rather than how much ram the about to be installed kernel would be able to use, then it applied the stupid old rule of 2xRAM for swap. Always was a stupid rule, even stupider now, but lacking any non stupid rule, what is a distribution install supposed to default to.
BTW, my guesses tend to be pretty good, but I wouldn't have said "guess" if this post had the level of confidence of my typical answers.
The less generally known fact that went into those guesses is that DMI information about how much ram is physically present is easy to read and totally independent of how much ram the motherboard or BIOS or kernel actually allow you to use.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.