Ubuntu swap partition size when using it as a hypervisor ( KVM in this case ).

Posted on 2014-09-19
Medium Priority
Last Modified: 2016-07-22
I am in the middle of a medium sized virtual deployment of a virtual environment.  Currently i have Ubuntu 12.04 LTS installed on a bunch of servers with dual 6 core procs and 96GB of ram.

The age old question in linux is... Do i need the swap partition?  From what i know, for ubuntu desktops with anything over 6GB, its a no.  But my issue here is that we are looking at a hypervisor role.  I have another small cluster of 5 hosts and 70 VMs running on VMWare ESXi, it doesnt use swap as far as i can tell.  Those machines are booted off 8GB USB drives with no local storage and 128GB of ram, so hence my assumption there is no swap.

Anyhow, i was researching the question on the web and the only definitive thing i can find is this red hat document saying that the KVM hypervisor running on redhat needs 16GB of swap space for machines with more than 64GB of memory.  https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.4/html/Installation_Guide/Storage_Requirements.html  

To further muddy the waters, we are using raid 1 SSDs for OS install on these servers, so i really wonder if 16GB is a must.  To me, wasting 16GB of hard drive space on SSDs is just bad form.  On the other hand, having virtual machines crash because they ran out of Memory is a no go.  It seems Red Hat is saying that its for safety, which of course would mean that it should be done when talking about a production environment.  

So with everything said, do we really need the swap, could we get away with smaller or should we just adhere to what Redhat is saying in their guide?  Please dont answer with a simple yes/no, explain in as much detail as possible your answer.  Examples/experiences welcome!

The next question goes hand and hand with this.  If we are spinning up virtual Ubuntu 12.04 servers on top of this, do they need swap files as well?  Most of those servers will have 2-8GB memory assigned.  In my vmware environment, i let the virtual slackware machines have their swap, but just because i have been doing it that way, doesnt mean its right.  So again, can i do a small swap file for the virtuals, elminate it or must i stick with the standard recommendation for the swap?  As before, please dont answer with a simple yes/no, explain in as much detail as possible your answer.  Examples/experiences welcome!
Question by:Brent
  • 4
  • 2
LVL 14

Accepted Solution

Natty Greg earned 1000 total points
ID: 40333987
I run Ubuntu and I always do a swap partition, makes everything run smooth without any hiccups. next thing is that you can have the swap partition on another drive you do not want to use up 16 gig of the SSD. However I prefer to run the swap on the same drive.

Always use a swap it is 100% recommended
LVL 62

Assisted Solution

gheist earned 1000 total points
ID: 40335023
You should always have swap as an indication that you run short on VM memory.
It can be zram if your disks are low grade, but 1GB swap partition will not hurt even a laptop disk.

Author Comment

ID: 40361456
Not exactly the answers i was looking for....   more detail is desired( per the original question).  Looking for experience with servers and virtualization in the linux realm.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 62

Expert Comment

ID: 40361580
Why you ask us if you think we are so short-brained?

Best use of SSD is all sorts of flash cache while real data is on something slower.
LVL 62

Expert Comment

ID: 41713511
Please split between all participants since we were asked for opinions....

Assisted Solution

Brent earned 0 total points
ID: 41713585
That would be fine as i didn't mean to offend.  I was looking more at do i need the size to be 16GB ( really that size? )  or could it be smaller, like say 1GB, even if i have 48GB of memory.  Wondering if anyone had tried this in production or test and if the servers tended to crash or go unstable.  Also, if not 1GB, would 4GB work?  Basically, if as it seems, the swap is necessary, then what would be the minimum required(or suggested) for stability?

For the time being, i have left the swap partitions in place.  Its just annoying to waste the space when with VMWare you dont need to waste space on a swap partition.  With my setup, this is a pretty large caveat for using KVM instead of VMWare.

Most of the instances are disposable, which is why all the OSs are loaded locally instead of from a central SAN/NAS unit.
LVL 62

Expert Comment

ID: 41724206
Swap is used to save kernel memory dumps (thats where the idea of SWAP==RAM comes from)
Then it is used for hibernation of laptops.
For use as a general purpose RAM it is way too slow (or SSD wearing where it iss faster)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cron is one of the most popular and basic utilities found on Unix systems. Combined with other tools, cron makes it exceptionally easy to automate a broad range of tasks on your server.
This article explains how to use the rsync command to create backups and sync data across hosts. Rsync is a very useful command that is often used to copy data, make backups, migrate hosts, and bridge the gap between site staging and production envi…
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question