Allow but Discourage swap on Ubuntu [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite













This question already has an answer here:



  • How do I configure swappiness?

    1 answer



There are copious posts on disabling Ubuntu swap completely. Is it possible to tell Ubuntu to allow but discourage swap usage?



I've installed Xubuntu on a laptop with 1Gb ram and a small SSD, turning it into a Samba server. In a worst case scenario free memory still can fit all data from a swap file:



~$ free -m
total used free shared buffers cached
Mem: 991 696 294 17 66 175
-/+ buffers/cache: 454 536
Swap: 1952 107 1845


I want to discourage discourage swap when free memory is available, because swap does a lot of IO writes that degrade SSD quickly.



Is it possible to prioritize RAM over swap or the choice is limited to "swap on/off"? What side effects if any does it cause?




Thank you for pointing out existing answers they are relevant but hard to find. User must know 90% of the answer to search for "how to configure swappiness".
Question answered. Hope this question header helps indexing.







share|improve this question














marked as duplicate by user535733, karel, Fabby, Kevin Bowen, Terrance May 29 at 21:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Search for "swappiness" on askubuntu
    – Sebastian Stark
    May 29 at 16:27














up vote
1
down vote

favorite













This question already has an answer here:



  • How do I configure swappiness?

    1 answer



There are copious posts on disabling Ubuntu swap completely. Is it possible to tell Ubuntu to allow but discourage swap usage?



I've installed Xubuntu on a laptop with 1Gb ram and a small SSD, turning it into a Samba server. In a worst case scenario free memory still can fit all data from a swap file:



~$ free -m
total used free shared buffers cached
Mem: 991 696 294 17 66 175
-/+ buffers/cache: 454 536
Swap: 1952 107 1845


I want to discourage discourage swap when free memory is available, because swap does a lot of IO writes that degrade SSD quickly.



Is it possible to prioritize RAM over swap or the choice is limited to "swap on/off"? What side effects if any does it cause?




Thank you for pointing out existing answers they are relevant but hard to find. User must know 90% of the answer to search for "how to configure swappiness".
Question answered. Hope this question header helps indexing.







share|improve this question














marked as duplicate by user535733, karel, Fabby, Kevin Bowen, Terrance May 29 at 21:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Search for "swappiness" on askubuntu
    – Sebastian Stark
    May 29 at 16:27












up vote
1
down vote

favorite









up vote
1
down vote

favorite












This question already has an answer here:



  • How do I configure swappiness?

    1 answer



There are copious posts on disabling Ubuntu swap completely. Is it possible to tell Ubuntu to allow but discourage swap usage?



I've installed Xubuntu on a laptop with 1Gb ram and a small SSD, turning it into a Samba server. In a worst case scenario free memory still can fit all data from a swap file:



~$ free -m
total used free shared buffers cached
Mem: 991 696 294 17 66 175
-/+ buffers/cache: 454 536
Swap: 1952 107 1845


I want to discourage discourage swap when free memory is available, because swap does a lot of IO writes that degrade SSD quickly.



Is it possible to prioritize RAM over swap or the choice is limited to "swap on/off"? What side effects if any does it cause?




Thank you for pointing out existing answers they are relevant but hard to find. User must know 90% of the answer to search for "how to configure swappiness".
Question answered. Hope this question header helps indexing.







share|improve this question















This question already has an answer here:



  • How do I configure swappiness?

    1 answer



There are copious posts on disabling Ubuntu swap completely. Is it possible to tell Ubuntu to allow but discourage swap usage?



I've installed Xubuntu on a laptop with 1Gb ram and a small SSD, turning it into a Samba server. In a worst case scenario free memory still can fit all data from a swap file:



~$ free -m
total used free shared buffers cached
Mem: 991 696 294 17 66 175
-/+ buffers/cache: 454 536
Swap: 1952 107 1845


I want to discourage discourage swap when free memory is available, because swap does a lot of IO writes that degrade SSD quickly.



Is it possible to prioritize RAM over swap or the choice is limited to "swap on/off"? What side effects if any does it cause?




Thank you for pointing out existing answers they are relevant but hard to find. User must know 90% of the answer to search for "how to configure swappiness".
Question answered. Hope this question header helps indexing.





This question already has an answer here:



  • How do I configure swappiness?

    1 answer









share|improve this question













share|improve this question




share|improve this question








edited May 29 at 19:01

























asked May 29 at 16:18









Stepan

19319




19319




marked as duplicate by user535733, karel, Fabby, Kevin Bowen, Terrance May 29 at 21:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by user535733, karel, Fabby, Kevin Bowen, Terrance May 29 at 21:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2




    Search for "swappiness" on askubuntu
    – Sebastian Stark
    May 29 at 16:27












  • 2




    Search for "swappiness" on askubuntu
    – Sebastian Stark
    May 29 at 16:27







2




2




Search for "swappiness" on askubuntu
– Sebastian Stark
May 29 at 16:27




Search for "swappiness" on askubuntu
– Sebastian Stark
May 29 at 16:27










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Unless you have a pretty old SSD, halfway modern SSDs can handle lots of writes, so you don’t really need to do anything if you have a halfway modern SSD.



If you still want to reduce swapping, reduce swappiness (minimum value on modern Linux is 1, not 0, if you want to go all out, though 10 is the recommended minimum and 60 is the Ubuntu default). This can slow things down greatly (to the point that the system can freeze up for quite a while if under heavy memory pressure) when swapping finally begins, since little to nothing will be swapped out ahead of time.



To set swappiness, replace 10 below with the swappiness you want, 1 to 100, where lower values swap less frequently. Open a terminal (press Ctrl+Alt+T), and run:



sudo sysctl vm.swappiness=10
sudo nano /etc/sysctl.conf


Now, add a line to the bottom (or if there’s already a vm.swappiness line, edit that):



vm.swappiness = 10


Press Ctrl+O to save. Press Ctrl+X to exit nano. Close the terminal window.






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Unless you have a pretty old SSD, halfway modern SSDs can handle lots of writes, so you don’t really need to do anything if you have a halfway modern SSD.



    If you still want to reduce swapping, reduce swappiness (minimum value on modern Linux is 1, not 0, if you want to go all out, though 10 is the recommended minimum and 60 is the Ubuntu default). This can slow things down greatly (to the point that the system can freeze up for quite a while if under heavy memory pressure) when swapping finally begins, since little to nothing will be swapped out ahead of time.



    To set swappiness, replace 10 below with the swappiness you want, 1 to 100, where lower values swap less frequently. Open a terminal (press Ctrl+Alt+T), and run:



    sudo sysctl vm.swappiness=10
    sudo nano /etc/sysctl.conf


    Now, add a line to the bottom (or if there’s already a vm.swappiness line, edit that):



    vm.swappiness = 10


    Press Ctrl+O to save. Press Ctrl+X to exit nano. Close the terminal window.






    share|improve this answer


























      up vote
      2
      down vote



      accepted










      Unless you have a pretty old SSD, halfway modern SSDs can handle lots of writes, so you don’t really need to do anything if you have a halfway modern SSD.



      If you still want to reduce swapping, reduce swappiness (minimum value on modern Linux is 1, not 0, if you want to go all out, though 10 is the recommended minimum and 60 is the Ubuntu default). This can slow things down greatly (to the point that the system can freeze up for quite a while if under heavy memory pressure) when swapping finally begins, since little to nothing will be swapped out ahead of time.



      To set swappiness, replace 10 below with the swappiness you want, 1 to 100, where lower values swap less frequently. Open a terminal (press Ctrl+Alt+T), and run:



      sudo sysctl vm.swappiness=10
      sudo nano /etc/sysctl.conf


      Now, add a line to the bottom (or if there’s already a vm.swappiness line, edit that):



      vm.swappiness = 10


      Press Ctrl+O to save. Press Ctrl+X to exit nano. Close the terminal window.






      share|improve this answer
























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Unless you have a pretty old SSD, halfway modern SSDs can handle lots of writes, so you don’t really need to do anything if you have a halfway modern SSD.



        If you still want to reduce swapping, reduce swappiness (minimum value on modern Linux is 1, not 0, if you want to go all out, though 10 is the recommended minimum and 60 is the Ubuntu default). This can slow things down greatly (to the point that the system can freeze up for quite a while if under heavy memory pressure) when swapping finally begins, since little to nothing will be swapped out ahead of time.



        To set swappiness, replace 10 below with the swappiness you want, 1 to 100, where lower values swap less frequently. Open a terminal (press Ctrl+Alt+T), and run:



        sudo sysctl vm.swappiness=10
        sudo nano /etc/sysctl.conf


        Now, add a line to the bottom (or if there’s already a vm.swappiness line, edit that):



        vm.swappiness = 10


        Press Ctrl+O to save. Press Ctrl+X to exit nano. Close the terminal window.






        share|improve this answer














        Unless you have a pretty old SSD, halfway modern SSDs can handle lots of writes, so you don’t really need to do anything if you have a halfway modern SSD.



        If you still want to reduce swapping, reduce swappiness (minimum value on modern Linux is 1, not 0, if you want to go all out, though 10 is the recommended minimum and 60 is the Ubuntu default). This can slow things down greatly (to the point that the system can freeze up for quite a while if under heavy memory pressure) when swapping finally begins, since little to nothing will be swapped out ahead of time.



        To set swappiness, replace 10 below with the swappiness you want, 1 to 100, where lower values swap less frequently. Open a terminal (press Ctrl+Alt+T), and run:



        sudo sysctl vm.swappiness=10
        sudo nano /etc/sysctl.conf


        Now, add a line to the bottom (or if there’s already a vm.swappiness line, edit that):



        vm.swappiness = 10


        Press Ctrl+O to save. Press Ctrl+X to exit nano. Close the terminal window.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 29 at 17:05

























        answered May 29 at 16:42









        Chai T. Rex

        3,45611132




        3,45611132












            Popular posts from this blog

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error

            How do I move numbers in filenames, in a batch renaming operation?