swapoff failed: Cannot allocate memory
9,089
You do not have enough RAM. Your machine is surviving because you use a swap file (i.e. using your hard drive for extra pseudo-RAM) but that is not supported by Kubernetes so it tried to turn that off which failed because you don't have enough RAM.
Author by
user533509
Updated on December 12, 2022Comments
-
user533509 over 1 year
Server's Output shows the following:
# free -h total used free shared buffers cached Mem: 7.7G 7.6G 123M 156K 1.8M 248M -/+ buffers/cache: 7.3G 373M Swap: 9G 4.9G 5.1G
I tried to turn off the swap but unable to do so!
#swapoff /dev/dm-1 swapoff: /dev/dm-1: swapoff failed: Cannot allocate memory
Then, to resolve this problem, I did:
Step 1: I tried to create a new swap file: /home/swap of 2G Size:# dd if=/dev/zero of=/home/swap bs=1024 count=2097152 # mkswap /home/swap # swapon /home/swap
**Step 2:**I tried to disable main swap since I have created a new swap file: /home/swap (But again getting error)
# swapoff /dev/dm-1 swapoff: /dev/dm-1: swapoff failed: Cannot allocate memory
When I tried to look whether new swap file created is actually using swap: It showed nothing! why??
# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 8388604 5129864 -1 /home/swap file 2097148 0 -2
Any solution to the above problem?
-
Admin almost 5 yearsOn your swap partition 4.9 GB are used. How do you suppose those 4.9 GB should fit in the 123 MB memory or 2 GB swap file you created? Why do you want to turn off the swap partition in the first place? The solution would be to add more ram or to reduce the load.
-