How big should swap partition be?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
HappyLinux
Level 4
Level 4
Posts: 317
Joined: Wed May 30, 2012 3:48 am
Location: Earth

How big should swap partition be?

Post by HappyLinux »

I'll be building my new computer this weekend. A dual-boot between Windows 10 and Ubuntu 15.10. Ubuntu is only temporary until Mint 18 comes out.

When I come to install Linux on this system, how big should I make the swap partition?

The Hard drive is 1TB in size.
The physical memory is 16GB.

In my current system which has 8GB of physical memory, I set the swap to equal it at 8GB.

I don't use sleep or hibernate in dual-boot setups, whether in Windows or Linux. If it's a single operating system running on a computer, then yes.

How big do you think I should set it as?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Laurent85
Level 17
Level 17
Posts: 7081
Joined: Tue May 26, 2015 10:11 am

Re: How big should swap partition be?

Post by Laurent85 »

Sleep mode doesn't use swap. If you don't plan to use hibernation a few gig should suffice, say 2 gig. You may also change the swappiness to 10.

If using hibernation set swap size to ram size + 1 GB.
Image
Mute Ant

Re: How big should swap partition be?

Post by Mute Ant »

"I don't use sleep or hibernate" Nothing then. If 16GiB genuinely needs to swap you can add a swap-file such as Windows uses, but I doubt you will ever need it.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: How big should swap partition be?

Post by xenopeek »

The Ubuntu Swap FAQ gives some info on what swap would be used for and how much you'd need: https://help.ubuntu.com/community/SwapF ... ed_swap.3F. In your case, 4 GB swap would suffice.

Personally with 16 GB RAM and not using hibernate, I've installed with no swap at all. I've not seen any issue and regularly run very big programs (most of the day I have 4 to 6 virtual machines running, a few web browsers, a few media players, some LibreOffice applications and general text editors and terminals). I'm not convinced swap would do anything for me.
Image
HappyLinux
Level 4
Level 4
Posts: 317
Joined: Wed May 30, 2012 3:48 am
Location: Earth

Re: How big should swap partition be?

Post by HappyLinux »

When I was starting out with Linux, I was told to always setup a swap partition otherwise it would cause problem when running Linux.

If you're all basically saying that because I will have 16GB of memory, I either don't need a swap partition, or a small one at 2GB.

Shall I just create a swap partition of 2GB as a precaution?
Laurent85
Level 17
Level 17
Posts: 7081
Joined: Tue May 26, 2015 10:11 am

Re: How big should swap partition be?

Post by Laurent85 »

No. As Mute Ant said you can later on create a swap file if needed. I personally have no swap set on a 8GB ram laptop running Cinnamon for months without issue. But as a general rule it is still recommended to configure a swap. I would then recommend to customize the swappiness to a law value.
Last edited by Laurent85 on Wed Apr 06, 2016 2:06 pm, edited 1 time in total.
Image
LinuxJim

Re: How big should swap partition be?

Post by LinuxJim »

HappyLinux wrote:When I was starting out with Linux, I was told to always setup a swap partition otherwise it would cause problem when running Linux.
It will cause problems - if you run out of memory. The general consensus is that you are unlikely to run out of memory with 16GB.

Performance will be a little better without a swap file, but you do risk a crash & burn if you fill up the entire 16GB of RAM.

An 8-16GB swap file on a 1TB drive is almost invisible - and you can tune the performance with the swappiness parameter.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: How big should swap partition be?

Post by xenopeek »

I ran Linux for years on 2 GB RAM with no swap. No problems that I can recall. One would suspect there is something like a swap maffia; you better set up some swap, who knows what could happen if you didn't!
Image
LinuxJim

Re: How big should swap partition be?

Post by LinuxJim »

xenopeek wrote:I ran Linux for years on 2 GB RAM with no swap. No problems that I can recall. One would suspect there is something like a swap maffia; you better set up some swap, who knows what could happen if you didn't!
Nah, it's not that bad. ;)

If you don't push the limits, it's a non-issue.
HappyLinux
Level 4
Level 4
Posts: 317
Joined: Wed May 30, 2012 3:48 am
Location: Earth

Re: How big should swap partition be?

Post by HappyLinux »

I'll just create a 2GB swap to please both camps and help me feel comfortable.
Locked

Return to “Installation & Boot”