6

I have a weird problem with turning off the swap. The server has 192 GB of memory, 154 GB free.

It's a Hypervisor running a number of Linux KVM Virtual Machines.

When trying to:

# swapoff -a
swapoff: /dev/sda2: swapoff failed: Cannot allocate memory

but memory is free:

# cat /proc/meminfo
MemTotal:       197805748 kB
MemFree:        162274264 kB
MemAvailable:   162388912 kB
Buffers:             432 kB
Cached:           353524 kB
SwapCached:       221828 kB
Active:         28253440 kB
Inactive:        5349056 kB
Active(anon):   28159204 kB
Inactive(anon):  5289320 kB
Active(file):      94236 kB
Inactive(file):    59736 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      124999676 kB
SwapFree:       124534724 kB
Dirty:               796 kB
Writeback:             0 kB
AnonPages:      33063024 kB
Mapped:            59236 kB
Shmem:            199984 kB
Slab:             313264 kB
SReclaimable:     206596 kB
SUnreclaim:       106668 kB
KernelStack:       10784 kB
PageTables:        94012 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    223902548 kB
Committed_AS:   43094824 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      794656 kB
VmallocChunk:   34358685284 kB
HardwareCorrupted:     0 kB
AnonHugePages:  32186368 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      136564 kB
DirectMap2M:     8136704 kB
DirectMap1G:    195035136 kB

Does anyone has any idea what could be the cause ?

  • would you be able to umount it after dropping caches, e.g. echo 1 > /proc/sys/vm/drop_caches? – Rui F Ribeiro Nov 7 '16 at 16:58
  • 1
    @RuiFRibeiro Tried 3, 2 and 1, neither helped removing the swap file unfortunately. – Dom Nov 7 '16 at 17:06
  • 1
    Is there any clue in the kernel logs? – Gilles Nov 7 '16 at 22:41
  • @Gilles nothing unfortunately, it does not even attempt to perform the operation. – Dom Nov 8 '16 at 9:23
  • fwiw, on FreeBSD the message is swapoff: <device path>: Cannot allocate memory – myrdd Sep 3 '18 at 9:32
1

Try it:

sync ; echo 3 > /proc/sys/vm/drop_caches

and then

swapoff

Or temporary add new swap file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.