User Tools

Site Tools


ubuntu:swap:clear_swap

Ubuntu - Swap - Clear swap

Check your swap usage

free -m
 
                    total       used       free     shared    buffers     cached
 
Mem:          1024        157        866          0         11         48
 
-/+ buffers/cache:         97        926
 
Swap:          127         95         32

where

  • -m is for the value to be listed in megabytes.

To clear the swap

sync && /sbin/sysctl vm.drop_caches=3 && swapoff -a && swapon -a 

where

  • sync is to force changed blocks to disk and update the super block;
  • sysctl vm.drop_caches=3 is to free pagecache, dentries and inodes;
  • swapoff is to turn off swap;
  • swapon is to turn swap back on.

Check the swap again

free -m
 
                    total       used       free     shared    buffers     cached
 
Mem:          1024        157        866          0         11         48
 
-/+ buffers/cache:         97        926
 
Swap:          127         0         127
ubuntu/swap/clear_swap.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki