I do the following steps in order to increase the swap size

but when I start with swapoff /dev/mapper/rootvg-swap , then its stuck for along time and not return the prompt

why we can do to solve this

 swapoff /dev/mapper/rootvg-swap
 lvresize -L +5g  /dev/mapper/rootvg-swap
 mkswap /dev/mapper/rootvg-swap
 swapon /dev/mapper/rootvg-swap


 vmstat 1
 procs -----------memory---------- ---swap-- -----io---- --system-- ----- cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0 2027848 127788  28804 18490972  105   38   180   211   25   59 17  6 64 13  0
 1  0 2027848 126944  28812 18490972    0    0     0   124 1073 1491 16  1  82  1  0
 0  0 2027848 126076  28828 18490956    0    0     0   104  727 1236  6  0    94  0  0
 0  0 2027848 126076  28828 18491008    0    0     0     0  452  979  2  0 98  0  0
 1  0 2027696 130960  28828 18486500  480    0   480    92  985 1415 21  4 69  5  0
 0  0 2027696 130984  28844 18486572    0    0     0    43  421  984  1  0 98  1  0
  • How long time? Btw. using 10+GB as swap isn't a good choice. – Ipor Sircer Nov 23 '16 at 7:36
  • more then 2-3 min , I stop it with CNTR-C – King David Nov 23 '16 at 7:37
  • 1
    What would expect? if you using this laaarge amount of swap it need some time to free it. run vmstat 1 and watch the decreasing swap. – Ipor Sircer Nov 23 '16 at 7:44
  • see my update ( the problem is swapoff /dev/mapper/rootvg-swap take more then 3 min and not sure if it will return prompt even after 10 min ) – King David Nov 23 '16 at 7:56
  • vmstat clearly says that you don't have enough free memory for copying the whole swap. – Ipor Sircer Nov 23 '16 at 7:58
up vote 4 down vote accepted

The swapoff command needs to flush all of the swapped memory from the swap file (/dev/mapper/rootvg-swap) back to main memory (or perhaps somewhere else) before it can disable the swap file. This can take time to complete and you may not have sufficient free memory.

You can increase the amount of free swap space that you have by adding more swap files

  • create a swap file/LV depending on what you have available
  • use mkswap to configure it
  • use swapon to enable it

The swapon man page contains more information about multiple swap files that may be helpful in particualar look at priorites.

The safest way to solve your problem is likely to reboot to single user mode and carry out the porcess you outline when the system is not under memory pressure.

The best solution is to size your system appropriately for its workload and to add more memory.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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