Solved

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

Posted on 2014-09-19
9
117 Views
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!
0
Comment
Question by:Icetoad
  • 4
  • 2
9 Comments
 
LVL 9

Accepted Solution

by:
nattygreg 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
0
 
LVL 61

Assisted Solution

by:gheist
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.
0
 
LVL 8

Author Comment

by:Icetoad
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.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly‚ÄĒanytime, anywhere. Grab this deal now before it disappears!

 
LVL 61

Expert Comment

by:gheist
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.
0
 
LVL 61

Expert Comment

by:gheist
ID: 41713511
Please split between all participants since we were asked for opinions....
0
 
LVL 8

Assisted Solution

by:Icetoad
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.
0
 
LVL 61

Expert Comment

by:gheist
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)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now