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

Posted on 2014-09-19
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.  

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:Icetoad
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 12

Accepted Solution

Natty Greg earned 250 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 250 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.
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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

Icetoad 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Zimbra on Amazon Linux help 7 110
Linux MD5 Hash 7 61
Understanding ping command in Ubuntu 5 30
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Teach the user how to join ESXi hosts to Active Directory domains Open vSphere Client: Join ESXi host to AD domain: Verify ESXi computer account in AD: Configure permissions for domain user in ESXi: Test domain user login to ESXi host:
This Micro Tutorial steps you through the configuration steps to configure your ESXi host Management Network settings and test the management network, ensure the host is recognized by the DNS Server, configure a new password, and the troubleshooting…

756 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