Does Ubuntu support dynamic swap file sizing?











up vote
11
down vote

favorite
1












I can't imagine why a swap file needs to be fixed size. Why not let it resize dynamically, like the hard drive image file for a virtual box?










share|improve this question






















  • Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
    – David Foerster
    Apr 18 '17 at 11:28










  • Does Mac support dynamic swap?
    – Tom Mercer
    Apr 19 '17 at 3:39










  • I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
    – David Foerster
    Apr 19 '17 at 8:44

















up vote
11
down vote

favorite
1












I can't imagine why a swap file needs to be fixed size. Why not let it resize dynamically, like the hard drive image file for a virtual box?










share|improve this question






















  • Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
    – David Foerster
    Apr 18 '17 at 11:28










  • Does Mac support dynamic swap?
    – Tom Mercer
    Apr 19 '17 at 3:39










  • I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
    – David Foerster
    Apr 19 '17 at 8:44















up vote
11
down vote

favorite
1









up vote
11
down vote

favorite
1






1





I can't imagine why a swap file needs to be fixed size. Why not let it resize dynamically, like the hard drive image file for a virtual box?










share|improve this question













I can't imagine why a swap file needs to be fixed size. Why not let it resize dynamically, like the hard drive image file for a virtual box?







swap 17.04






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 17 '17 at 5:25









Tom Mercer

6111624




6111624












  • Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
    – David Foerster
    Apr 18 '17 at 11:28










  • Does Mac support dynamic swap?
    – Tom Mercer
    Apr 19 '17 at 3:39










  • I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
    – David Foerster
    Apr 19 '17 at 8:44




















  • Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
    – David Foerster
    Apr 18 '17 at 11:28










  • Does Mac support dynamic swap?
    – Tom Mercer
    Apr 19 '17 at 3:39










  • I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
    – David Foerster
    Apr 19 '17 at 8:44


















Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
– David Foerster
Apr 18 '17 at 11:28




Linux doesn't support dynamic swap space sizes unless you count the option to add and remove entire swap spaces at run time. (Neither does Windows btw., not even the latter.)
– David Foerster
Apr 18 '17 at 11:28












Does Mac support dynamic swap?
– Tom Mercer
Apr 19 '17 at 3:39




Does Mac support dynamic swap?
– Tom Mercer
Apr 19 '17 at 3:39












I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
– David Foerster
Apr 19 '17 at 8:44






I have no idea. It's an entirely different kernel which I didn't study. Chances are it's similar to swap space in Linux. Anyway, could you please open a new question Unix & Linux or Ask Different if you have a new or follow-up question about the Darwin kernel of OS X? The comment section is not suitable or meant for new questions or extended discussion. :-) Thanks.
– David Foerster
Apr 19 '17 at 8:44












4 Answers
4






active

oldest

votes

















up vote
10
down vote













It doesn't look like Linux supports dynamic swap file sizing (at any rate, I couldn't get it to detect that a swap file had changed size without a swapoff/swapon).



Presumably it is easier to assume that a swap file doesn't change file size dynamically when writing code for supporting it. I don't see any great use for it either. Since you can use multiple swap files, nothing's preventing you from creating more swap files as needed.



Also note this paragraph from the swapon manpage:



The  swap file implementation in the kernel expects to be able to write
to the file directly, without the assistance of the filesystem. This
is a problem on preallocated files (e.g. fallocate(1)) on filesystems
like XFS or ext4, and on copy-on-write filesystems like btrfs.


I'd think the same problem would apply to a dynamically-sized swap file.






share|improve this answer





















  • Looks like this is true, and swapspace doesn't even dynamically resize swap.
    – Tom Mercer
    Apr 17 '17 at 18:11




















up vote
3
down vote













SwapSpace is a utility that will allow you to make dynamically sized swap if that is what you are looking for. I do believe it is available in Ubuntu.






share|improve this answer























  • While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
    – muru
    Apr 17 '17 at 9:18










  • I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
    – user231695
    Apr 17 '17 at 9:21










  • I still vote your answer up as it is just as simple to create new space.
    – user231695
    Apr 17 '17 at 9:26










  • I will give this a try, and report back.
    – Tom Mercer
    Apr 17 '17 at 18:12










  • @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
    – Tom Mercer
    Apr 17 '17 at 18:13


















up vote
0
down vote













Swap space can be added to a running system by using the swapon command. It needs an existing (unused) swapfile/partition. To create one, use the dd command to allocate a contiguous file, and then mkswap to add the correct control information to the file / partition.



To remove a swapfile, use swapoff; the file can then be deleted.



I suspect that is what SwapSpace dæmon that @user231695 mentioned does.



Note that swapoff can be a slow operation if the swapfile is in use; all the data has to be transferred to another swap area.






share|improve this answer




























    up vote
    0
    down vote













    I know it is late, but I think the best solution for dynamic swap is to:



    sudo apt install dphys-swapfile
    sudo update-rc.d dphys-swapfile enable


    then setting CONF_SWAPFACTOR=2 in /etc/dphys-swapfile and finally



    sudo service dphys-swapfile start





    share|improve this answer





















    • It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
      – Tom Mercer
      Nov 30 at 19:09










    • Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
      – Denis Pitzalis
      Dec 2 at 18:54












    • Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
      – Tom Mercer
      Dec 3 at 19:14











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f905668%2fdoes-ubuntu-support-dynamic-swap-file-sizing%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    10
    down vote













    It doesn't look like Linux supports dynamic swap file sizing (at any rate, I couldn't get it to detect that a swap file had changed size without a swapoff/swapon).



    Presumably it is easier to assume that a swap file doesn't change file size dynamically when writing code for supporting it. I don't see any great use for it either. Since you can use multiple swap files, nothing's preventing you from creating more swap files as needed.



    Also note this paragraph from the swapon manpage:



    The  swap file implementation in the kernel expects to be able to write
    to the file directly, without the assistance of the filesystem. This
    is a problem on preallocated files (e.g. fallocate(1)) on filesystems
    like XFS or ext4, and on copy-on-write filesystems like btrfs.


    I'd think the same problem would apply to a dynamically-sized swap file.






    share|improve this answer





















    • Looks like this is true, and swapspace doesn't even dynamically resize swap.
      – Tom Mercer
      Apr 17 '17 at 18:11

















    up vote
    10
    down vote













    It doesn't look like Linux supports dynamic swap file sizing (at any rate, I couldn't get it to detect that a swap file had changed size without a swapoff/swapon).



    Presumably it is easier to assume that a swap file doesn't change file size dynamically when writing code for supporting it. I don't see any great use for it either. Since you can use multiple swap files, nothing's preventing you from creating more swap files as needed.



    Also note this paragraph from the swapon manpage:



    The  swap file implementation in the kernel expects to be able to write
    to the file directly, without the assistance of the filesystem. This
    is a problem on preallocated files (e.g. fallocate(1)) on filesystems
    like XFS or ext4, and on copy-on-write filesystems like btrfs.


    I'd think the same problem would apply to a dynamically-sized swap file.






    share|improve this answer





















    • Looks like this is true, and swapspace doesn't even dynamically resize swap.
      – Tom Mercer
      Apr 17 '17 at 18:11















    up vote
    10
    down vote










    up vote
    10
    down vote









    It doesn't look like Linux supports dynamic swap file sizing (at any rate, I couldn't get it to detect that a swap file had changed size without a swapoff/swapon).



    Presumably it is easier to assume that a swap file doesn't change file size dynamically when writing code for supporting it. I don't see any great use for it either. Since you can use multiple swap files, nothing's preventing you from creating more swap files as needed.



    Also note this paragraph from the swapon manpage:



    The  swap file implementation in the kernel expects to be able to write
    to the file directly, without the assistance of the filesystem. This
    is a problem on preallocated files (e.g. fallocate(1)) on filesystems
    like XFS or ext4, and on copy-on-write filesystems like btrfs.


    I'd think the same problem would apply to a dynamically-sized swap file.






    share|improve this answer












    It doesn't look like Linux supports dynamic swap file sizing (at any rate, I couldn't get it to detect that a swap file had changed size without a swapoff/swapon).



    Presumably it is easier to assume that a swap file doesn't change file size dynamically when writing code for supporting it. I don't see any great use for it either. Since you can use multiple swap files, nothing's preventing you from creating more swap files as needed.



    Also note this paragraph from the swapon manpage:



    The  swap file implementation in the kernel expects to be able to write
    to the file directly, without the assistance of the filesystem. This
    is a problem on preallocated files (e.g. fallocate(1)) on filesystems
    like XFS or ext4, and on copy-on-write filesystems like btrfs.


    I'd think the same problem would apply to a dynamically-sized swap file.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 17 '17 at 5:45









    muru

    135k19286485




    135k19286485












    • Looks like this is true, and swapspace doesn't even dynamically resize swap.
      – Tom Mercer
      Apr 17 '17 at 18:11




















    • Looks like this is true, and swapspace doesn't even dynamically resize swap.
      – Tom Mercer
      Apr 17 '17 at 18:11


















    Looks like this is true, and swapspace doesn't even dynamically resize swap.
    – Tom Mercer
    Apr 17 '17 at 18:11






    Looks like this is true, and swapspace doesn't even dynamically resize swap.
    – Tom Mercer
    Apr 17 '17 at 18:11














    up vote
    3
    down vote













    SwapSpace is a utility that will allow you to make dynamically sized swap if that is what you are looking for. I do believe it is available in Ubuntu.






    share|improve this answer























    • While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
      – muru
      Apr 17 '17 at 9:18










    • I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
      – user231695
      Apr 17 '17 at 9:21










    • I still vote your answer up as it is just as simple to create new space.
      – user231695
      Apr 17 '17 at 9:26










    • I will give this a try, and report back.
      – Tom Mercer
      Apr 17 '17 at 18:12










    • @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
      – Tom Mercer
      Apr 17 '17 at 18:13















    up vote
    3
    down vote













    SwapSpace is a utility that will allow you to make dynamically sized swap if that is what you are looking for. I do believe it is available in Ubuntu.






    share|improve this answer























    • While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
      – muru
      Apr 17 '17 at 9:18










    • I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
      – user231695
      Apr 17 '17 at 9:21










    • I still vote your answer up as it is just as simple to create new space.
      – user231695
      Apr 17 '17 at 9:26










    • I will give this a try, and report back.
      – Tom Mercer
      Apr 17 '17 at 18:12










    • @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
      – Tom Mercer
      Apr 17 '17 at 18:13













    up vote
    3
    down vote










    up vote
    3
    down vote









    SwapSpace is a utility that will allow you to make dynamically sized swap if that is what you are looking for. I do believe it is available in Ubuntu.






    share|improve this answer














    SwapSpace is a utility that will allow you to make dynamically sized swap if that is what you are looking for. I do believe it is available in Ubuntu.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 17 '17 at 9:18









    muru

    135k19286485




    135k19286485










    answered Apr 17 '17 at 9:11









    user231695

    392




    392












    • While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
      – muru
      Apr 17 '17 at 9:18










    • I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
      – user231695
      Apr 17 '17 at 9:21










    • I still vote your answer up as it is just as simple to create new space.
      – user231695
      Apr 17 '17 at 9:26










    • I will give this a try, and report back.
      – Tom Mercer
      Apr 17 '17 at 18:12










    • @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
      – Tom Mercer
      Apr 17 '17 at 18:13


















    • While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
      – muru
      Apr 17 '17 at 9:18










    • I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
      – user231695
      Apr 17 '17 at 9:21










    • I still vote your answer up as it is just as simple to create new space.
      – user231695
      Apr 17 '17 at 9:26










    • I will give this a try, and report back.
      – Tom Mercer
      Apr 17 '17 at 18:12










    • @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
      – Tom Mercer
      Apr 17 '17 at 18:13
















    While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
    – muru
    Apr 17 '17 at 9:18




    While it had a new release 2 years ago, the versions packaged for Ubuntu all seem to be ancient. How well does it work?
    – muru
    Apr 17 '17 at 9:18












    I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
    – user231695
    Apr 17 '17 at 9:21




    I cannot imagine that the method used to write the swap file has changed but I could not say for sure. Works fine on debian.
    – user231695
    Apr 17 '17 at 9:21












    I still vote your answer up as it is just as simple to create new space.
    – user231695
    Apr 17 '17 at 9:26




    I still vote your answer up as it is just as simple to create new space.
    – user231695
    Apr 17 '17 at 9:26












    I will give this a try, and report back.
    – Tom Mercer
    Apr 17 '17 at 18:12




    I will give this a try, and report back.
    – Tom Mercer
    Apr 17 '17 at 18:12












    @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
    – Tom Mercer
    Apr 17 '17 at 18:13




    @user231695 while it's simple to create a new swap space, it's horrendously inconvenient, and possibly completely unworkable as a solution. The only time a user wants to add a new swap space is the very moment when existing swap is full. Hence my question for dynamic sizing of swap file.
    – Tom Mercer
    Apr 17 '17 at 18:13










    up vote
    0
    down vote













    Swap space can be added to a running system by using the swapon command. It needs an existing (unused) swapfile/partition. To create one, use the dd command to allocate a contiguous file, and then mkswap to add the correct control information to the file / partition.



    To remove a swapfile, use swapoff; the file can then be deleted.



    I suspect that is what SwapSpace dæmon that @user231695 mentioned does.



    Note that swapoff can be a slow operation if the swapfile is in use; all the data has to be transferred to another swap area.






    share|improve this answer

























      up vote
      0
      down vote













      Swap space can be added to a running system by using the swapon command. It needs an existing (unused) swapfile/partition. To create one, use the dd command to allocate a contiguous file, and then mkswap to add the correct control information to the file / partition.



      To remove a swapfile, use swapoff; the file can then be deleted.



      I suspect that is what SwapSpace dæmon that @user231695 mentioned does.



      Note that swapoff can be a slow operation if the swapfile is in use; all the data has to be transferred to another swap area.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Swap space can be added to a running system by using the swapon command. It needs an existing (unused) swapfile/partition. To create one, use the dd command to allocate a contiguous file, and then mkswap to add the correct control information to the file / partition.



        To remove a swapfile, use swapoff; the file can then be deleted.



        I suspect that is what SwapSpace dæmon that @user231695 mentioned does.



        Note that swapoff can be a slow operation if the swapfile is in use; all the data has to be transferred to another swap area.






        share|improve this answer












        Swap space can be added to a running system by using the swapon command. It needs an existing (unused) swapfile/partition. To create one, use the dd command to allocate a contiguous file, and then mkswap to add the correct control information to the file / partition.



        To remove a swapfile, use swapoff; the file can then be deleted.



        I suspect that is what SwapSpace dæmon that @user231695 mentioned does.



        Note that swapoff can be a slow operation if the swapfile is in use; all the data has to be transferred to another swap area.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 17 '17 at 13:16









        CSM

        1912




        1912






















            up vote
            0
            down vote













            I know it is late, but I think the best solution for dynamic swap is to:



            sudo apt install dphys-swapfile
            sudo update-rc.d dphys-swapfile enable


            then setting CONF_SWAPFACTOR=2 in /etc/dphys-swapfile and finally



            sudo service dphys-swapfile start





            share|improve this answer





















            • It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
              – Tom Mercer
              Nov 30 at 19:09










            • Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
              – Denis Pitzalis
              Dec 2 at 18:54












            • Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
              – Tom Mercer
              Dec 3 at 19:14















            up vote
            0
            down vote













            I know it is late, but I think the best solution for dynamic swap is to:



            sudo apt install dphys-swapfile
            sudo update-rc.d dphys-swapfile enable


            then setting CONF_SWAPFACTOR=2 in /etc/dphys-swapfile and finally



            sudo service dphys-swapfile start





            share|improve this answer





















            • It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
              – Tom Mercer
              Nov 30 at 19:09










            • Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
              – Denis Pitzalis
              Dec 2 at 18:54












            • Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
              – Tom Mercer
              Dec 3 at 19:14













            up vote
            0
            down vote










            up vote
            0
            down vote









            I know it is late, but I think the best solution for dynamic swap is to:



            sudo apt install dphys-swapfile
            sudo update-rc.d dphys-swapfile enable


            then setting CONF_SWAPFACTOR=2 in /etc/dphys-swapfile and finally



            sudo service dphys-swapfile start





            share|improve this answer












            I know it is late, but I think the best solution for dynamic swap is to:



            sudo apt install dphys-swapfile
            sudo update-rc.d dphys-swapfile enable


            then setting CONF_SWAPFACTOR=2 in /etc/dphys-swapfile and finally



            sudo service dphys-swapfile start






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 26 at 10:30









            Denis Pitzalis

            1033




            1033












            • It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
              – Tom Mercer
              Nov 30 at 19:09










            • Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
              – Denis Pitzalis
              Dec 2 at 18:54












            • Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
              – Tom Mercer
              Dec 3 at 19:14


















            • It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
              – Tom Mercer
              Nov 30 at 19:09










            • Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
              – Denis Pitzalis
              Dec 2 at 18:54












            • Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
              – Tom Mercer
              Dec 3 at 19:14
















            It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
            – Tom Mercer
            Nov 30 at 19:09




            It doesn't appear to dynamically resize swap. Looks like a script to initialize a swapfile of certain size that defaults to 2x RAM capacity.
            – Tom Mercer
            Nov 30 at 19:09












            Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
            – Denis Pitzalis
            Dec 2 at 18:54






            Hi @TomMercer setting swapfactor and maxswap, according to comments in the file: "# set size to computed value, this times RAM size, dynamically adapts, guarantees that there is enough swap without wasting disk space on excess" . "dynamically adapts" seems what you are looking for. Best
            – Denis Pitzalis
            Dec 2 at 18:54














            Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
            – Tom Mercer
            Dec 3 at 19:14




            Does it make my swapfile vary in size between, say, 1KB and 16GB, while I'm using the OS and filling up RAM? That's what "dynamically resizing" swap means. Creating a swapfile that's a multiple of RAM size is not dynamic. There's no point in having a swapfile at all until RAM is full, and then you want the swapfile to be exactly the size of VRAM you're using. If you close the tabs or huge image you're working on, the swapfile should dynamically resize back down. Swapfile should always be exactly 100% full by dynamically resizing itself.
            – Tom Mercer
            Dec 3 at 19:14


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f905668%2fdoes-ubuntu-support-dynamic-swap-file-sizing%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Ellipse (mathématiques)

            Quarter-circle Tiles

            Mont Emei