View previous topic :: View next topic |
Author |
Message |
Spanik Veteran

Joined: 12 Dec 2003 Posts: 1014 Location: Belgium
|
Posted: Sat Aug 21, 2021 12:47 pm Post subject: (solved) swap size? |
|
|
I just started a new install on the desktop. Reading the handbook, I still come accross:
Code: | /dev/sda2 (swap) RAM size * 2 Swap partition |
Do I really need 128GB swap? That is half of the nvme OS partition.... Maybe this needs an update. _________________ Expert in non-working solutions
Last edited by Spanik on Sun Aug 22, 2021 2:50 pm; edited 1 time in total |
|
Back to top |
|
 |
Jaglover Watchman


Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
 |
Ionen Developer


Joined: 06 Dec 2018 Posts: 2899
|
Posted: Sat Aug 21, 2021 1:00 pm Post subject: |
|
|
It still makes some sense if you have some low'ish amount like 1-2GB, but I agree it's a bit of a crude rule by modern standards.
fwiw if you want to do suspend-to-disk you could, in theory, need up to RAM * 1 = 64GB (that's only if you're currently using as much ram, and I imagine it's gonna be pretty slow).
Doesn't hurt to have a little bit of slow swap as a buffer before the OOM killer start killing things either way (even with large amounts of RAM, it's cheap to have a some small 2-6+GB). |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Sat Aug 21, 2021 2:26 pm Post subject: |
|
|
If you have 64GB of RAM, you probably won't need any swap space at all.
I haven't had swap on any of my machines for more than 10 years - and I have never missed it.
A swap partition Swap space of at least the size of your RAM is required if you want to use the sleep state 'hibernation'. Do you want to use 'hibernation'?
Last edited by mike155 on Sat Aug 21, 2021 3:36 pm; edited 1 time in total |
|
Back to top |
|
 |
Jaglover Watchman


Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
Posted: Sat Aug 21, 2021 3:00 pm Post subject: |
|
|
mike155 wrote: | A swap partition of at least the size of your RAM is required if you want to use the sleep state 'hibernation'. Do you want to use 'hibernation'? |
Swap partition is not required for hibernation, swap space is. It can be a file. Also, some allege swap files are slower, not true. I maintain using swap file(s) is much more flexible than partition(s). With files you can change your mind any time and increase/decrease swap space. Once I saw my box running out of swap space building chromium, I managed to create and activate an additional 2 GiB of swap before OOM killer kicked in.
OTOH, having 64 GB of RAM is terribly excessive, it will never be used during normal operation of a desktop machine. To add 128 GB of swap to it is in harmony. _________________ My Gentoo installation notes.
Please learn how to denote units correctly! |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Sat Aug 21, 2021 3:41 pm Post subject: |
|
|
Jaglover wrote: | mike155 wrote: | A swap partition of at least the size of your RAM is required if you want to use the sleep state 'hibernation'. Do you want to use 'hibernation'? |
Swap partition is not required for hibernation, swap space is. |
You're right. I changed my post above.
Quote: | OTOH, having 64 GB of RAM is terribly excessive, it will never be used during normal operation of a desktop machine. |
Be careful! Do not make the same mistake as Bill Gates.  |
|
Back to top |
|
 |
steve_v Guru

Joined: 20 Jun 2004 Posts: 416 Location: New Zealand
|
Posted: Sat Aug 21, 2021 6:32 pm Post subject: Re: swap size? |
|
|
Spanik wrote: | Do I really need 128GB swap? | Lol. No, no you do not. At least not for any sane desktop configuration.
To quote the RHEL manual (yes, blasphemy I know, but them's reasonable numbers):
Code: |
Amount of RAM in the system Recommended swap space Recommended swap space if allowing for hibernation
⩽ 2 GB 2 times the amount of RAM 3 times the amount of RAM
2 GB – 8 GB Equal to the amount of RAM 2 times the amount of RAM
8 GB – 64 GB At least 4 GB 1.5 times the amount of RAM
> 64 GB At least 4 GB Hibernation not recommended
|
Jaglover wrote: | some allege swap files are slower, not true. |
It kinda was true, once. It really doesn't matter on solid-state storage though. _________________ Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy. |
|
Back to top |
|
 |
Spanik Veteran

Joined: 12 Dec 2003 Posts: 1014 Location: Belgium
|
Posted: Sat Aug 21, 2021 6:40 pm Post subject: |
|
|
Jaglover wrote: |
OTOH, having 64 GB of RAM is terribly excessive, it will never be used during normal operation of a desktop machine. To add 128 GB of swap to it is in harmony. |
Having 8 ram slots on the motherboard that needs 4 of them populated and then finding only 16GB supported ram modules... you end up with 64GB. And now I even have only half the memory bandwidth!
steve_v wrote: | To quote the RHEL manual (yes, blasphemy I know, but them's reasonable numbers):
|
Looks more reasonable. I do not need hibernation. This is a desktop that is regulary shut down and powered down. _________________ Expert in non-working solutions |
|
Back to top |
|
 |
CooSee Veteran


Joined: 20 Nov 2004 Posts: 1522 Location: Earth
|
Posted: Sat Aug 21, 2021 6:49 pm Post subject: |
|
|
i never used 'swap' since i have 32GB RAM and no problems at all, even with big compiles like 'ungoogled-chromium', while watching stream and browsing through web.
suspend on a desktop system never made sense to me - if i don't use the computer i just shut down.
suspend only makes sense on a notebook.
just my two cents  _________________ " Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier " |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
|
Back to top |
|
 |
Hu Administrator

Joined: 06 Mar 2007 Posts: 23131
|
Posted: Sat Aug 21, 2021 7:12 pm Post subject: |
|
|
Both suspend and hibernate make great sense to me. When I don't need my system, I suspend it, so that everything is where I left it when I return. This is more convenient than trying to get every program I use to correctly remember its state and reopen itself on next boot, each with all their interactive per-instance history.
Hibernate is nice for cases where I would suspend, but I expect a thunderstorm to knock out power. Once hibernated, the system can survive a complete loss of wall power during the storm. After the storm passes, I can turn back on and again be where I was. |
|
Back to top |
|
 |
CooSee Veteran


Joined: 20 Nov 2004 Posts: 1522 Location: Earth
|
Posted: Sat Aug 21, 2021 7:16 pm Post subject: |
|
|
thanks @mike155
--
i hope it's ok to ask, but how Apple is handling or using 'suspend', because imho they do it perfectly on their devices. _________________ " Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier " |
|
Back to top |
|
 |
steve_v Guru

Joined: 20 Jun 2004 Posts: 416 Location: New Zealand
|
Posted: Sat Aug 21, 2021 7:43 pm Post subject: |
|
|
CooSee wrote: | i never used 'swap' since i have 32GB RAM and no problems at all |
It's not really needed on a machine with plenty of RAM, but it's still potentially beneficial if the kernel can page out cruft that hasn't been used in forever to free up RAM for cache and buffers.
Anecdotally, I've also found that having at least a little swap makes the system more likely to deal with an OOM situation gracefully if it ever does arise.
CooSee wrote: | suspend on a desktop system never made sense to me - if i don't use the computer i just shut down.
suspend only makes sense on a notebook. |
I just never shut anything down. That and I've had an UPS (the same UPS even) since 1996.
Power saving modes I get, and maybe even suspend... But yeah, hibernation is for laptops IMO. It's certainly not something I'm going to reserve a significant fraction of an SSD for in any case.
CooSee wrote: | just my two cents  |
Four cents is better than two, right?  _________________ Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy. |
|
Back to top |
|
 |
Goverp Advocate


Joined: 07 Mar 2007 Posts: 2209
|
Posted: Sun Aug 22, 2021 10:20 am Post subject: |
|
|
Hu wrote: | Both suspend and hibernate make great sense to me. When I don't need my system, I suspend it, so that everything is where I left it when I return. This is more convenient than trying to get every program I use to correctly remember its state and reopen itself on next boot, each with all their interactive per-instance history.
Hibernate is nice for cases where I would suspend, but I expect a thunderstorm to knock out power. Once hibernated, the system can survive a complete loss of wall power during the storm. After the storm passes, I can turn back on and again be where I was. |
Hibernate is, of course, also very useful for portable devices to save battery during travel. Or so I've heard - I can't get it to work on mine! (AMD no longer bother to test if their drivers will hibernate, and mine definitely doesn't.)
Don't forget there's the hybrid sleep (don't remember its real name) that does the IO to create a hibernate image, but then sleeps. If you open the box before the power goes off, it wakes from suspend. If the power goes off, when you reconnect it resumes from hibernate. _________________ Greybeard |
|
Back to top |
|
 |
Hu Administrator

Joined: 06 Mar 2007 Posts: 23131
|
Posted: Sun Aug 22, 2021 4:26 pm Post subject: |
|
|
Agreed, power-saving states (both suspend-to-ram and suspend-to-disk) are great for mobile devices, and suspend-to-disk is nice for any device where you know it will be off wall power for long enough that the extra seconds of resuming from disk are worth the battery time saved by not using suspend-to-ram. I was focusing on CooSee's comment that suspend didn't make sense on a desktop, but only made sense on a notebook. I wanted to present cases where suspend makes sense for any device that cannot, on its own, readily restore its state.
I've sometimes seen the hybrid mode referred to as suspend-to-both. That's how sys-power/suspend describes it (via the utility s2both). |
|
Back to top |
|
 |
Maffblaster Developer

Joined: 01 May 2007 Posts: 70 Location: Spokane, Washington, USA
|
|
Back to top |
|
 |
figueroa Advocate


Joined: 14 Aug 2005 Posts: 3008 Location: Edge of marsh USA
|
Posted: Sun Feb 18, 2024 5:53 am Post subject: |
|
|
I've been working my way down to setting aside less swap. My desktop has 16 GB or RAM and I currently set aside an 8 GB partition for swap on a secondary hard drive. I never see swap actively used, but the system currently has @ 32 MB or swap in -use. There are three large, internal hard drives, all spinning rust, so the disk space isn't much of a consideration.
My home server and home desktop both run 24/7. At night, they do housekeeping chores, including (most importantly) backups. These two computers only get turned off for hardware repair or changing of UPS batteries. However, I do normally shut down all application programs and log off at the end of each day. This leaves my system, the GUI in particular, in a sound, idle state for sane backups. Obviously I don't suspend or hibernate these two machines.
My old and humble notebook, when in use, just gets turned off when not in use, and I have to run backups manually. It only has 4 GB or RAM and a 4 GB swap partition. On the other hand, my wife's main computer is a laptop with 8 GB or RAM. She closes the lid when not in use, which eventually causes it to suspend but not hibernate. She finds it very handy that way. She has a small swap partition just for assurance that it's there when needed. Her backups are triggered by anacron, and she tells me that she doesn't really notice the extra load when backups are taking place. Backups are initially made to an always installed SD card, and then archived to the home server over NFS.
If one does suspend or hibernate (or turn off) their computer, extra consideration should be given to when and how backups are to be made, preferably automatically in some manner. _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 54921 Location: 56N 3W
|
Posted: Sun Feb 18, 2024 10:11 am Post subject: |
|
|
Swap space is not the kernels only mechanism for swapping.
The swap partition/file is only used as a temporary home for dynamically allocated RAM. That is, things that have no permanent home on storage.
Things like executable code, input data and even output data, can be dropped and reloaded.
Dirty (output) buffers must be flushed before they can be dropped.
This has some interesting side effects.
Programs that cannot be fitted into available RAM cam still be executed. Its OK to mmap the same pages of physical RAM to two (or more) pages of code.
They will be swapped as required. This is slow due the the page faults. But it works.
The same is true with input and output buffers, with the rider that data that is only in RAM must be flushed to disk first.
From the above it follows that not having a swap partition/file only puts pressure on the other 'swapping' mechanisms.
That does not mean that a swap partition/file is required but its a useful diagnostic tool. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
 |
Zucca Moderator


Joined: 14 Jun 2007 Posts: 3959 Location: Rasi, Finland
|
Posted: Sun Feb 18, 2024 10:40 am Post subject: |
|
|
Jaglover wrote: | Use swap file(s). You can create and activate them at your will, any time. But watch out, not all filesystems support swap. | Or if lvm is being used, swap partition (logical volume) can be added, removed and/or resized easily. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
 |
|