For systems with really large amounts of RAM more than 32 GB you can likely get away with a smaller swap partition around 1x, or less, of physical RAM. File systems and LVM2 volumes assigned as swap space cannot be in use when being modified. For example, no system processes can be assigned the swap space, as well as no amount of swap should be allocated and used by the kernel.
The best way to achieve swap space modifications is to boot your system in rescue mode, and then follow the instructions for each scenario in the remainder of this chapter. When prompted to mount the file system, select Skip. What is Swap Space? If you need hibernation, a swap of the size of RAM becomes necessary for Ubuntu.
I know it is confusing. This is why I have created this table that will give you the Ubuntu recommended swap size based on your RAM size and hibernation need. The answer is never simple. As I stated earlier, for a long time, swap has been recommended to be of double the size of RAM.
Also a movie buff with a soft corner for film noir. Great Article but You should have mentioned the table more adding maxiumuim section to it in this shape it will look like. I had 32g swap as a match to my 32g ram but it would freeze a lot when I changed it to 7. Maybe some programs are intended to use swap.
Maybe you could change the swapiness value to experiment if you want. Excellent article, thanks. Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
Recommended Read Swap files allow you to create and use swap space on the fly in Linux. Learn About Swap Files in Linux. Like what you read? Please share it with others.
Great Article but You should have mentioned the table more adding maxiumuim section to it in this shape it will look like RAM GB No hibernation With Hibernation Maximum 1 1 2 2 2 1 3 4 3 2 5 6 4 2 6 8 5 2 7 10 6 2 8 12 8 3 11 16 12 3 15 24 16 4 20 32 24 5 29 48 32 6 38 64 64 8 72 11 I use a swapfile instead, which can grow dynamically.
My swapfile is mounted on my root partition, which I have given 64GB to. Of course, I never go that high, probably the most resource-intensive thing I ever run on my computer it's not even a computer, it's just a crappy tablet with a keyboard from my school with 4GB RAM is Android Studio.
Suspend to RAM is sufficient and works really well. Interesting article. I now know that I have 2G of Swap on Ubuntu Is that too little?
I have since using Windows XP, disabled swap, never used it because I knew how to manage memory, Linux, gosh it never needed because it was so efficient at handling the memory, thus some of our friends point out under 8GB, and yeah maybe, those browsers are very memory hungry but I ran small Nix servers that use no more than Mb, sometimes growing to Mb, thus I feel if you sysadmin your machines correctly you can get away with very little ram and never even think of swap.
Some feel in the Microsoft world you need to enable swap to allow kernel swapping and some page functions require it Now for the non sysadmin and technical people, leave the swap on, let the system manage it for them because really life is busy enough, though the security issues that are associated with it sometimes cause more issues, in today it's a security nightmare since the average Joe will not enable encryption or flush the swap file at each reboot. Anyway my 2 cents.
If you already have swap space assigned and need more, it's easy enough to add another partition. The proper swappiness setting eliminates any thrashing.
As Pierre suggested, I reset system swappiness to a more reasonable value than the default of Pierre uses 1. Setting it to 0 effectively shuts off swapping. I usually use 10, but YMMV. I haven't used MS Windows in almost 20 years but, when I did, I set up a swap partition instead of a file.
Today, with all the SSDs commonly found in new systems, you could avoid trouble by placing the partition on a standard HDD instead of the SSD, as many systems come with or can be upgraded to one of each.
Thank you, David Both, for a well-written post that clears up some confusion that many beginners and even some old-timers have about swap space. I have often checked and I have never seen any swap in use.
Based on that I think 0. That sounds good, but then we want a rule linking swap space to workload, or better, linking RAM size to workload. The reasoning would be that your swap space should be big enough to handle the maximum possible demand, whereas the amount of memory is linked to your 'working set size'. A reasonable measure is to look at your uptime run queue length. If that is 20 long-term average fior a system with infinite RAM that means your working set is 20 threads and you would also need that number of processor cores.
A first approximation would be to figure out what programs those threads might belong to, and the amount of memory they need and install roughly that amount of RAM. A better approach takes the size of those programs and the task switching frequency into account. Or simper:: just shrink the RAM to the point where the effective throughput and response-time is the required level, for instance, half the performance of a machine with unlimited RAM. With SSDs, you would install rather less RAM than with magnetic discs, because the latency of your swap device is so much lower.
A simple rule of thumb is that you need at least the amount of RAM for swap space in order to store a crash dump. When you start any significant swapping things usually so down so much it appears your app has "hung".
Maybe for a server not running interactive code, but for me when sitting at the keyboard using swap is death.
Why would I possibly want to have virtual memory that puts additional wear on my SSD? I believe that the memory pages for executable code are "backed" on "disk" by the actual executable file. So there is "some" virtual memory pages already. But read only, not putting wear on the SSD. My rationale is this: RAM is cheap so use enough that you don't need a swap.
I work almost exclusively from a laptop which is usually hibernated, rebooting preferably only once every few months usually for kernel upgrades due to security concerns. This makes swap requirements very different from someone who never hibernates and reboots every day.
After a week or two of run time, Chromium web browser can easily hit GB of memory usage by itself. Add in Firefox with lots of tabs , a couple of active virtual machines, some bioinformatics analysis code running in background these often make poor use of memory , two or three active IDE's like Rstudio, PyCharm or if I'm feeling particularly masochistic , Eclipse, and I am well past the 32 GB of RAM on my laptop.
There is little to no swapping going on because while some of the software I use is well written and very efficient with it's use of memory, other programs are not, eating lots of storage because they keep things in memory that they no longer have any use for. This means I need lots of swap space for storing the "junk" that these programs keep lying around and thrashing usually isn't an issue. I currently have configured 48 GB of swap to go with my 32 GB of RAM to allow for hibernation and "junk", but with my increasing encounters with memory wasting code, 64 GB of swap may be more appropriate.
In my experience, it's all about the purpose of the box. What app you are running should tell you what you need and if you're using to much swap , you probably need more ram. I was managing some OpenStack servers and when they started using any swap above a baseline, it was time to reboot them because they would always be slower after that happened.
Then they'd be good for another month or 2. Swap was useful as a canary. With cloud, you should have multiple VMs and compute nodes. In that case, no swap on the VMs, ever. I agree with the rational mentioned above that RAM is cheap Anyhow it strongly depends on the machine and its use. For my production machine never hibernates , the swap is zero. If it starts to swap then the performance drops drastically. It is better that the application is killed due to insufficient memory and I am forced to find a solution rather than running at lower speed without noticing.
I find that on my personal laptop system, I do not have numerous parallel tasks going on at the same time, chewing up resources and I seldom consume even half of available memory, so under these circumstances, swap is optional unless I care about suspend or hibernation operations. I usually allow 1 to 2 times system memory to account for suspend or hibernate; otherwise I let virtual memory manage matters, and since neither disk or memory are issues, I do create swap, "just in case".
In practice, with moderate utilization and applications regularly changed, I don't usually have a lot of processes chewing up memory. The guidelines are only general and do not necessarily represent all situations, certainly not my typical usage scenarios on home equipment. These rules of thumb need to differentiate between workstations and servers and backend storage. No one hibernates a server. For my personal desktop or laptop, I allocate enough swap to cover my hibernation needs.
I don't want them to every use swap and impact the other servers on the same SAN. I'll first say, laptops are an exception due to the needs of hibernation. In server environments, I run with none or minimal swap. Since the ESX host box already had a decent sized swap, I found that I could reduce swap or page file for Windows on my guests. My theory here was that only the Host OS knows the real hardware situation.
Swap is really a function of hardware - limited RAM to be exact. That's my brief explanation. Nice write up!
0コメント