65
votes
Accepted
prevent system freeze/unresponsiveness due to swapping run away memory usage
TL;DR
Short answer
Easiest: Use a newer Linux release where systemd-oomd became part of systemd in the 2nd half of 2020.
Otherwise, have a smaller swap partition and avoid the kernel trying to live ...
34
votes
Accepted
Deleted a partition, now getting 'Gave up waiting for suspend/resume device' message during boot
I just encountered that same error message on Debian and a similar boot delay, with a slight variation: I knew that I had just voluntarily deleted my swap partition, and didn't plan to recreate it.
...
25
votes
How to create swapfile on ssd disk with btrfs
As mentioned above, since Linux 5.0 it is now possible to create swap files on BTRFS. But they should be non-compressed and NoCOW.
Here is how do you actually create such a file:
Create an empty file:...
20
votes
Accepted
Should I use a SSD or HDD for "swap" on an old computer
SSD is definitely a steroid to any system. Even machines already sentenced to scrap are revived by it.
On the other hand, factory specifications really state that their statistical lifetime is smaller ...
16
votes
Swapon failed: Invalid argument on a Linux system with Btrfs filesystem
In Linux kernel 5.0.0, btrfs natively supports swapfile now. (You must set it as no-COW)
Here's some information from kernel.org: https://btrfs.wiki.kernel.org/index.php/FAQ#...
16
votes
Is it possible to create a swap file for a Linux guest VM managed by Vagrant?
Simply add this line to your vagrant file
Vagrantfile
# Enable Dynamic Swap Space to prevent Out of Memory crashes
config.vm.provision "shell", inline: "sudo apt install swapspace -y"
And then ...
15
votes
Accepted
What kswapd is doing when there is no swap
Many processes have memory that is backed by a file. This data can be swapped to the file even if you don't have swap space.
See: AskUbuntu » Why is kswapd0 running on a computer with no swap?
15
votes
What is faster: Intel's Optane SSD or RAM?
1 s(second) = 1000 ms(millisecond)
1 ms(millisecond) = 1000 μs(microsecond)
1 μs(microsecond) = 1000 ns(nanosecond)
DRAM: 200 ns
3D Xpoint: 7 μs (7000 ns)
enterprise NVMe PCIe SSD: 30 μs (30,000 ...
15
votes
Deleted a partition, now getting 'Gave up waiting for suspend/resume device' message during boot
Because of the message
Gave up waiting for suspend/resume device
I suspect a problem with your swap partition. Check if your system uses swap by running swapon. Next run swapon -a and observe the ...
13
votes
Should I use a SSD or HDD for "swap" on an old computer
Your question states speed is not a factor, but resources are. In this case, HDDs give you far greater GBs for your money than any SSD on the market currently. If you're after pure resource, HDDs ...
11
votes
What is the exact difference between the parameters (pgpgin, pswpin) and (pswpout, pgpgout) in /proc/vmstat?
So old question and no correct answer so far.
First of all, memory is segmented by CPU and Kernel into so called pages. Size of page is given by architecture of CPU, many architectures support ...
11
votes
How to check Paging Memory on swap for Windows, via command line?
try this:
systeminfo | find "Virtual Memory"
this will return:
Virtual Memory: Max Size: 17.297 MB
Virtual Memory: Available: 7.186 MB
Virtual Memory: In Use: 10.111 MB
here is my powershell ...
11
votes
How to stop a Linux process for later execution swapping-out its memory
You might look into a technique called checkpoint/restore. This will allow you to take a running process and save its state to a set of files, then restore it at a later time.
To use it, start by ...
10
votes
Swapon failed: Invalid argument on a Linux system with Btrfs filesystem
I got the cryptic error now after an unclean shutdown. The only solution was to delete the old swapfile and recreate it.
As on btrfs, there are certain restrictions (e.g. copy-on-write has to be ...
9
votes
Accepted
How to create swapfile on ssd disk with btrfs
Status in 2019
The development of Btrfs and Linux kernel rendered my original answer obsolete. Please see this other answer.
Original answer from 2016
From btrfs FAQ:
Does btrfs support swap ...
8
votes
How to create swapfile on ssd disk with btrfs
Swap file support has been added to kernel version 5.0 as can be seen at commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7
...
7
votes
How permanently change Linux swap disk priority
It looks like the pri parameter set to -1 in /etc/fstab (default value by the way) doesn't affect the priority reported by swapon. To make it work, you have to change for a bigger number (like 1).
...
7
votes
How to create swapfile on ssd disk with btrfs
In Linux 5.0 or later:
file='/swapfile'
# create file
touch "$file"
# No Copy-on-Write
chattr +C "$file"
# Allocate 10 GB (much faster than dd)
fallocate -l 10G "$file"
#...
7
votes
Accepted
Check which processes are eating swap on Linux?
Run top
Press f to select displayed fields
Navigate down to SWAP using arrow keys
Hit Space - SWAP will become preceded by asterisk *
Press right arrow key - this will allow you to move SWAP to a ...
6
votes
How permanently change Linux swap disk priority
Yes, but trying to set a negative priority doesn't work; we are only allowed to use positive numbers. To tell the system to use a given swap partition or file before another one, assign a larger ...
6
votes
Modify Windows "Swappiness"
There's more to virtual memory than just "apps allocating RAM and when physical RAM runs out, something gets paged out to SWAP".
In Linux (and possibly UNIX at large), the system tries to keep pages ...
6
votes
Where does VIM (gvim/macvim) keep swap files for unsaved/unnamed buffers?
I work on Windows 10 and :recover didn't find a swap file. vim -r listed the swap file from the last edit session (also never saved) named _.swp. Recovering was possible with :recover _.
6
votes
Accepted
Is it safe to share a swap partition with more than one Linux OS?
Yes as long as you don't try anything weird such as hibernating one OS, then booting directly into another and expecting no issues. (One version of hibernation will save the ram directly into the swap ...
6
votes
Accepted
Force a process to only use swap memory?
So is there a way in Linux to force a single process to only use memory in swap space? (without having to implement a custom allocator)
No, this is not possible. The process cannot run on the swap; ...
5
votes
How do I quickly stop a process that is causing thrashing (due to excess memory allocation)?
What is the quickest way to regain control of a Linux system that has become nonresponsive or extremely sluggish due to excessive swapping?
Already answered above with Alt-SysRq-F
Is there ...
5
votes
Should I use a SSD or HDD for "swap" on an old computer
The big question is "Does this support AHCI" - which you'll need for maximum performance and things like trim to work. Even without it, an SSD is faster than a spinning rust drive - but its less of a ...
4
votes
Accepted
Is it possible to create a swap file for a Linux guest VM managed by Vagrant?
The memory setting you see is only used to configure the VM's RAM. However, the swap space definition is part of the disk image. This image is provided to you as part of the config.vm.box definition ...
4
votes
Accepted
swapoff failed: Invalid argument
swapoff tells you swapoff failed: Invalid argument when the device is already not being used for swap. Example:
deltik@node51 [~]$ sudo swapoff /dev/zero
swapoff: /dev/zero: swapoff failed: Invalid ...
4
votes
Accepted
Hibernation without swap enabled
Disabling swap when you already know that your system can get to the point when it won't have enough memory is a bad idea. Right at the moment when kernel doesn't have any memory to allocate your ...
4
votes
Explain `fstab` swap syntax
You can specify the priority in fstab:
/dev/sda2 none swap sw,pri=30 0 0
/dev/sdb2 none swap sw,pri=20 0 0
/dev/sdc2 none swap sw,pri=10 0 0
By default, each ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
swap × 361linux × 186
memory × 120
partitioning × 43
ubuntu × 33
windows-7 × 29
ssd × 29
windows × 26
virtual-memory × 23
pagefile × 22
swap-file × 22
hard-drive × 20
performance × 19
macos × 18
hibernate × 15
debian × 9
memory-management × 9
swappiness × 9
encryption × 8
virtualbox × 7
mount × 7
linux-mint × 7
mac × 6
filesystems × 6
fedora × 6