how disable use swap partition by processes , only if its really need

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











up vote
1
down vote

favorite












My embedded system has 2 GB RAM and 100 MB swap partition.
I recognize, after continues monitoring that average memory usage of RAM is ~50 %.
For some reason system start use SWAP memory and use almost 40 % of it (40 MB).
I want prevent such thing because my device flash has a big problem with number of writes and I need it for ~10 years of use.
After run these set of commands I get to list of processes that use SWAP :



for file in /proc/*/status ; do awk '/VmSwap|Name/printf $2 " " $3END print ""' $file; done | sort -k 2 -n -r | less​


My system file /etc/sysctl.conf confiured with parameter : vm.swappiness=1 , so according articles I read it should use SWAP only if it really need.
(I investigated the results with vm.sappiness=0, but didn't have results yet.)



I know that there is a way to prevent from specific processes use swap, but what is a correct one?







share|improve this question






















  • This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
    – ilkkachu
    Nov 6 '17 at 14:56










  • This sounds like a job for the nice family... ionice nice renice
    – RubberStamp
    Nov 6 '17 at 15:03










  • You may also want to decrease verbosity level of logs in rsyslog configuration.
    – Jaroslav Kucera
    Nov 6 '17 at 15:36










  • my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
    – Sergey Meerovich
    Nov 7 '17 at 12:15














up vote
1
down vote

favorite












My embedded system has 2 GB RAM and 100 MB swap partition.
I recognize, after continues monitoring that average memory usage of RAM is ~50 %.
For some reason system start use SWAP memory and use almost 40 % of it (40 MB).
I want prevent such thing because my device flash has a big problem with number of writes and I need it for ~10 years of use.
After run these set of commands I get to list of processes that use SWAP :



for file in /proc/*/status ; do awk '/VmSwap|Name/printf $2 " " $3END print ""' $file; done | sort -k 2 -n -r | less​


My system file /etc/sysctl.conf confiured with parameter : vm.swappiness=1 , so according articles I read it should use SWAP only if it really need.
(I investigated the results with vm.sappiness=0, but didn't have results yet.)



I know that there is a way to prevent from specific processes use swap, but what is a correct one?







share|improve this question






















  • This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
    – ilkkachu
    Nov 6 '17 at 14:56










  • This sounds like a job for the nice family... ionice nice renice
    – RubberStamp
    Nov 6 '17 at 15:03










  • You may also want to decrease verbosity level of logs in rsyslog configuration.
    – Jaroslav Kucera
    Nov 6 '17 at 15:36










  • my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
    – Sergey Meerovich
    Nov 7 '17 at 12:15












up vote
1
down vote

favorite









up vote
1
down vote

favorite











My embedded system has 2 GB RAM and 100 MB swap partition.
I recognize, after continues monitoring that average memory usage of RAM is ~50 %.
For some reason system start use SWAP memory and use almost 40 % of it (40 MB).
I want prevent such thing because my device flash has a big problem with number of writes and I need it for ~10 years of use.
After run these set of commands I get to list of processes that use SWAP :



for file in /proc/*/status ; do awk '/VmSwap|Name/printf $2 " " $3END print ""' $file; done | sort -k 2 -n -r | less​


My system file /etc/sysctl.conf confiured with parameter : vm.swappiness=1 , so according articles I read it should use SWAP only if it really need.
(I investigated the results with vm.sappiness=0, but didn't have results yet.)



I know that there is a way to prevent from specific processes use swap, but what is a correct one?







share|improve this question














My embedded system has 2 GB RAM and 100 MB swap partition.
I recognize, after continues monitoring that average memory usage of RAM is ~50 %.
For some reason system start use SWAP memory and use almost 40 % of it (40 MB).
I want prevent such thing because my device flash has a big problem with number of writes and I need it for ~10 years of use.
After run these set of commands I get to list of processes that use SWAP :



for file in /proc/*/status ; do awk '/VmSwap|Name/printf $2 " " $3END print ""' $file; done | sort -k 2 -n -r | less​


My system file /etc/sysctl.conf confiured with parameter : vm.swappiness=1 , so according articles I read it should use SWAP only if it really need.
(I investigated the results with vm.sappiness=0, but didn't have results yet.)



I know that there is a way to prevent from specific processes use swap, but what is a correct one?









share|improve this question













share|improve this question




share|improve this question








edited Nov 6 '17 at 14:52









ilkkachu

50.5k677138




50.5k677138










asked Nov 6 '17 at 14:31









Sergey Meerovich

263




263











  • This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
    – ilkkachu
    Nov 6 '17 at 14:56










  • This sounds like a job for the nice family... ionice nice renice
    – RubberStamp
    Nov 6 '17 at 15:03










  • You may also want to decrease verbosity level of logs in rsyslog configuration.
    – Jaroslav Kucera
    Nov 6 '17 at 15:36










  • my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
    – Sergey Meerovich
    Nov 7 '17 at 12:15
















  • This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
    – ilkkachu
    Nov 6 '17 at 14:56










  • This sounds like a job for the nice family... ionice nice renice
    – RubberStamp
    Nov 6 '17 at 15:03










  • You may also want to decrease verbosity level of logs in rsyslog configuration.
    – Jaroslav Kucera
    Nov 6 '17 at 15:36










  • my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
    – Sergey Meerovich
    Nov 7 '17 at 12:15















This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
– ilkkachu
Nov 6 '17 at 14:56




This doesn't answer your question, but with that setup, do you need the swap in the first place? 100 MB isn't that much on a 2 GB machine, so you could probably do without it, and avoid this issue too. Also, the amount of swap in use at one time doesn't tell how much writes go to the swap: some rarely-if-ever used data might end up in swap the first the memory is full, and if it's never modified, there are no further writes.
– ilkkachu
Nov 6 '17 at 14:56












This sounds like a job for the nice family... ionice nice renice
– RubberStamp
Nov 6 '17 at 15:03




This sounds like a job for the nice family... ionice nice renice
– RubberStamp
Nov 6 '17 at 15:03












You may also want to decrease verbosity level of logs in rsyslog configuration.
– Jaroslav Kucera
Nov 6 '17 at 15:36




You may also want to decrease verbosity level of logs in rsyslog configuration.
– Jaroslav Kucera
Nov 6 '17 at 15:36












my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
– Sergey Meerovich
Nov 7 '17 at 12:15




my system is embedded base very shrink Debian 8 based system , that has problem with number of writes/read per-block on his flash drive, but it run an application that use pretty more resources. This is a reason why we declare swap partition if system get to critical point it will use swap partition.
– Sergey Meerovich
Nov 7 '17 at 12:15










2 Answers
2






active

oldest

votes

















up vote
4
down vote













You can set swappiness per process with cgroups



echo 0 > /sys/fs/cgroup/<your custom group>/memory.swappiness


Anyway my advice is to use zram for compressed swapping in ram.






share|improve this answer






















  • Just to add, this can also be achieved with the libcgroup and the cgset command.
    – Raman Sailopal
    Nov 6 '17 at 15:28

















up vote
0
down vote













I test on two systems , where I detect previously use of 40% of SWAP option of :



vm.swappiness=0


This option really helped . I didn't see any use of swap for last 4 days






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402841%2fhow-disable-use-swap-partition-by-processes-only-if-its-really-need%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    You can set swappiness per process with cgroups



    echo 0 > /sys/fs/cgroup/<your custom group>/memory.swappiness


    Anyway my advice is to use zram for compressed swapping in ram.






    share|improve this answer






















    • Just to add, this can also be achieved with the libcgroup and the cgset command.
      – Raman Sailopal
      Nov 6 '17 at 15:28














    up vote
    4
    down vote













    You can set swappiness per process with cgroups



    echo 0 > /sys/fs/cgroup/<your custom group>/memory.swappiness


    Anyway my advice is to use zram for compressed swapping in ram.






    share|improve this answer






















    • Just to add, this can also be achieved with the libcgroup and the cgset command.
      – Raman Sailopal
      Nov 6 '17 at 15:28












    up vote
    4
    down vote










    up vote
    4
    down vote









    You can set swappiness per process with cgroups



    echo 0 > /sys/fs/cgroup/<your custom group>/memory.swappiness


    Anyway my advice is to use zram for compressed swapping in ram.






    share|improve this answer














    You can set swappiness per process with cgroups



    echo 0 > /sys/fs/cgroup/<your custom group>/memory.swappiness


    Anyway my advice is to use zram for compressed swapping in ram.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 6 '17 at 15:20

























    answered Nov 6 '17 at 15:13









    Ipor Sircer

    8,8921920




    8,8921920











    • Just to add, this can also be achieved with the libcgroup and the cgset command.
      – Raman Sailopal
      Nov 6 '17 at 15:28
















    • Just to add, this can also be achieved with the libcgroup and the cgset command.
      – Raman Sailopal
      Nov 6 '17 at 15:28















    Just to add, this can also be achieved with the libcgroup and the cgset command.
    – Raman Sailopal
    Nov 6 '17 at 15:28




    Just to add, this can also be achieved with the libcgroup and the cgset command.
    – Raman Sailopal
    Nov 6 '17 at 15:28












    up vote
    0
    down vote













    I test on two systems , where I detect previously use of 40% of SWAP option of :



    vm.swappiness=0


    This option really helped . I didn't see any use of swap for last 4 days






    share|improve this answer
























      up vote
      0
      down vote













      I test on two systems , where I detect previously use of 40% of SWAP option of :



      vm.swappiness=0


      This option really helped . I didn't see any use of swap for last 4 days






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        I test on two systems , where I detect previously use of 40% of SWAP option of :



        vm.swappiness=0


        This option really helped . I didn't see any use of swap for last 4 days






        share|improve this answer












        I test on two systems , where I detect previously use of 40% of SWAP option of :



        vm.swappiness=0


        This option really helped . I didn't see any use of swap for last 4 days







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 '17 at 8:11









        Sergey Meerovich

        263




        263



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402841%2fhow-disable-use-swap-partition-by-processes-only-if-its-really-need%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay