tmpfs does not overflow to swap

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












3















I've configured tmp in /etc/fstab like this:



tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 2


The problem is that now /tmp is limited to half of the machine's memory, and when it reaches that limit I'm getting "no space left on device" error.



I'd like to make it "unlimited", i.e. grow to the size of the disk.










share|improve this question


























    3















    I've configured tmp in /etc/fstab like this:



    tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 2


    The problem is that now /tmp is limited to half of the machine's memory, and when it reaches that limit I'm getting "no space left on device" error.



    I'd like to make it "unlimited", i.e. grow to the size of the disk.










    share|improve this question
























      3












      3








      3


      0






      I've configured tmp in /etc/fstab like this:



      tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 2


      The problem is that now /tmp is limited to half of the machine's memory, and when it reaches that limit I'm getting "no space left on device" error.



      I'd like to make it "unlimited", i.e. grow to the size of the disk.










      share|improve this question














      I've configured tmp in /etc/fstab like this:



      tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 2


      The problem is that now /tmp is limited to half of the machine's memory, and when it reaches that limit I'm getting "no space left on device" error.



      I'd like to make it "unlimited", i.e. grow to the size of the disk.







      ubuntu tmp tmpfs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 16 '17 at 0:46









      m33lkym33lky

      6924919




      6924919




















          2 Answers
          2






          active

          oldest

          votes


















          9














          I get the impression you have a few misconceptions regarding tmpfs. You might find it useful to read the kernel documentation on the topic; I’ll attempt to clarify things for you here.



          Your question’s title “tmpfs does not overflow to swap” doesn’t seem to reflect the actual contents of your question, but in any case tmpfs does use swap, although arguably it doesn’t overflow to swap. tmpfs is fundamentally a (virtual) memory-based file system; its contents live in memory only, but since they’re swappable the kernel can store them in swap instead of physical memory if necessary. Nevertheless tmpfs file systems can’t be larger than the total amount of virtual memory available, i.e. physical RAM and swap, as indicated e.g. by free -h.



          By default tmpfs file systems have a maximum size equal to half the amount of physical memory available. You can increase this using the size parameter, but again it can’t ever be more than the available physical memory and swap (although that limit isn’t enforced at mount time). Once the file system reaches its maximum size (or rather, contains files occupying that much space), it reports that it’s run out of space, as you found out. tmpfs itself doesn’t support overflowing anywhere when it runs out of space.



          If you need temporary storage space for large files, you should use /var/tmp rather than /tmp. You really don’t want a very large tmpfs file system, that’s a recipe for disaster when it fills up (the kernel’s usual ways of recovering memory don’t work in a tmpfs).



          (If you have lots of RAM of course, a large tmpfs can work. I run a few systems with build tmpfs file systems sized at 75% of RAM, out of 32GiB, 64GiB or even more.)






          share|improve this answer

























          • Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

            – jesjimher
            Jan 30 at 12:22











          • @jesjimher I’m not aware of anything like that.

            – Stephen Kitt
            Jan 31 at 7:53


















          0














          You could use something like aufs. It let's you "merge" two different mounts inside a single directory. So, in this case you could mount both a tmpfs volume somewhere and a conventional directory on disk, and then unify them using aufs as /tmp. You can even assign priorities, so tmpfs would be used first, and disk would only be used when tmpfs runs out of space.



          It's not a perfect solution, though, because aufs works as a per file basis. So, if some process creates a file that starts growing slowly beyond tmpfs size, it won't "switch" volumes when tmpfs is full. It'll just get out of space (or some generic I/O error, since technically there's still space left in /tmp). But in a lot of scenarios it might do the trick of having /tmp in memory, and just fall back to disk when it grows too much.






          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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f365291%2ftmpfs-does-not-overflow-to-swap%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            9














            I get the impression you have a few misconceptions regarding tmpfs. You might find it useful to read the kernel documentation on the topic; I’ll attempt to clarify things for you here.



            Your question’s title “tmpfs does not overflow to swap” doesn’t seem to reflect the actual contents of your question, but in any case tmpfs does use swap, although arguably it doesn’t overflow to swap. tmpfs is fundamentally a (virtual) memory-based file system; its contents live in memory only, but since they’re swappable the kernel can store them in swap instead of physical memory if necessary. Nevertheless tmpfs file systems can’t be larger than the total amount of virtual memory available, i.e. physical RAM and swap, as indicated e.g. by free -h.



            By default tmpfs file systems have a maximum size equal to half the amount of physical memory available. You can increase this using the size parameter, but again it can’t ever be more than the available physical memory and swap (although that limit isn’t enforced at mount time). Once the file system reaches its maximum size (or rather, contains files occupying that much space), it reports that it’s run out of space, as you found out. tmpfs itself doesn’t support overflowing anywhere when it runs out of space.



            If you need temporary storage space for large files, you should use /var/tmp rather than /tmp. You really don’t want a very large tmpfs file system, that’s a recipe for disaster when it fills up (the kernel’s usual ways of recovering memory don’t work in a tmpfs).



            (If you have lots of RAM of course, a large tmpfs can work. I run a few systems with build tmpfs file systems sized at 75% of RAM, out of 32GiB, 64GiB or even more.)






            share|improve this answer

























            • Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

              – jesjimher
              Jan 30 at 12:22











            • @jesjimher I’m not aware of anything like that.

              – Stephen Kitt
              Jan 31 at 7:53















            9














            I get the impression you have a few misconceptions regarding tmpfs. You might find it useful to read the kernel documentation on the topic; I’ll attempt to clarify things for you here.



            Your question’s title “tmpfs does not overflow to swap” doesn’t seem to reflect the actual contents of your question, but in any case tmpfs does use swap, although arguably it doesn’t overflow to swap. tmpfs is fundamentally a (virtual) memory-based file system; its contents live in memory only, but since they’re swappable the kernel can store them in swap instead of physical memory if necessary. Nevertheless tmpfs file systems can’t be larger than the total amount of virtual memory available, i.e. physical RAM and swap, as indicated e.g. by free -h.



            By default tmpfs file systems have a maximum size equal to half the amount of physical memory available. You can increase this using the size parameter, but again it can’t ever be more than the available physical memory and swap (although that limit isn’t enforced at mount time). Once the file system reaches its maximum size (or rather, contains files occupying that much space), it reports that it’s run out of space, as you found out. tmpfs itself doesn’t support overflowing anywhere when it runs out of space.



            If you need temporary storage space for large files, you should use /var/tmp rather than /tmp. You really don’t want a very large tmpfs file system, that’s a recipe for disaster when it fills up (the kernel’s usual ways of recovering memory don’t work in a tmpfs).



            (If you have lots of RAM of course, a large tmpfs can work. I run a few systems with build tmpfs file systems sized at 75% of RAM, out of 32GiB, 64GiB or even more.)






            share|improve this answer

























            • Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

              – jesjimher
              Jan 30 at 12:22











            • @jesjimher I’m not aware of anything like that.

              – Stephen Kitt
              Jan 31 at 7:53













            9












            9








            9







            I get the impression you have a few misconceptions regarding tmpfs. You might find it useful to read the kernel documentation on the topic; I’ll attempt to clarify things for you here.



            Your question’s title “tmpfs does not overflow to swap” doesn’t seem to reflect the actual contents of your question, but in any case tmpfs does use swap, although arguably it doesn’t overflow to swap. tmpfs is fundamentally a (virtual) memory-based file system; its contents live in memory only, but since they’re swappable the kernel can store them in swap instead of physical memory if necessary. Nevertheless tmpfs file systems can’t be larger than the total amount of virtual memory available, i.e. physical RAM and swap, as indicated e.g. by free -h.



            By default tmpfs file systems have a maximum size equal to half the amount of physical memory available. You can increase this using the size parameter, but again it can’t ever be more than the available physical memory and swap (although that limit isn’t enforced at mount time). Once the file system reaches its maximum size (or rather, contains files occupying that much space), it reports that it’s run out of space, as you found out. tmpfs itself doesn’t support overflowing anywhere when it runs out of space.



            If you need temporary storage space for large files, you should use /var/tmp rather than /tmp. You really don’t want a very large tmpfs file system, that’s a recipe for disaster when it fills up (the kernel’s usual ways of recovering memory don’t work in a tmpfs).



            (If you have lots of RAM of course, a large tmpfs can work. I run a few systems with build tmpfs file systems sized at 75% of RAM, out of 32GiB, 64GiB or even more.)






            share|improve this answer















            I get the impression you have a few misconceptions regarding tmpfs. You might find it useful to read the kernel documentation on the topic; I’ll attempt to clarify things for you here.



            Your question’s title “tmpfs does not overflow to swap” doesn’t seem to reflect the actual contents of your question, but in any case tmpfs does use swap, although arguably it doesn’t overflow to swap. tmpfs is fundamentally a (virtual) memory-based file system; its contents live in memory only, but since they’re swappable the kernel can store them in swap instead of physical memory if necessary. Nevertheless tmpfs file systems can’t be larger than the total amount of virtual memory available, i.e. physical RAM and swap, as indicated e.g. by free -h.



            By default tmpfs file systems have a maximum size equal to half the amount of physical memory available. You can increase this using the size parameter, but again it can’t ever be more than the available physical memory and swap (although that limit isn’t enforced at mount time). Once the file system reaches its maximum size (or rather, contains files occupying that much space), it reports that it’s run out of space, as you found out. tmpfs itself doesn’t support overflowing anywhere when it runs out of space.



            If you need temporary storage space for large files, you should use /var/tmp rather than /tmp. You really don’t want a very large tmpfs file system, that’s a recipe for disaster when it fills up (the kernel’s usual ways of recovering memory don’t work in a tmpfs).



            (If you have lots of RAM of course, a large tmpfs can work. I run a few systems with build tmpfs file systems sized at 75% of RAM, out of 32GiB, 64GiB or even more.)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 16 '17 at 6:20

























            answered May 16 '17 at 4:59









            Stephen KittStephen Kitt

            173k24393468




            173k24393468












            • Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

              – jesjimher
              Jan 30 at 12:22











            • @jesjimher I’m not aware of anything like that.

              – Stephen Kitt
              Jan 31 at 7:53

















            • Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

              – jesjimher
              Jan 30 at 12:22











            • @jesjimher I’m not aware of anything like that.

              – Stephen Kitt
              Jan 31 at 7:53
















            Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

            – jesjimher
            Jan 30 at 12:22





            Isn't there any mechanism for adding a secondary tmp? For example, having a main tmpfs for /tmp, and then another /tmp2, in a conventional disk, that might be used only if /tmp is full.

            – jesjimher
            Jan 30 at 12:22













            @jesjimher I’m not aware of anything like that.

            – Stephen Kitt
            Jan 31 at 7:53





            @jesjimher I’m not aware of anything like that.

            – Stephen Kitt
            Jan 31 at 7:53













            0














            You could use something like aufs. It let's you "merge" two different mounts inside a single directory. So, in this case you could mount both a tmpfs volume somewhere and a conventional directory on disk, and then unify them using aufs as /tmp. You can even assign priorities, so tmpfs would be used first, and disk would only be used when tmpfs runs out of space.



            It's not a perfect solution, though, because aufs works as a per file basis. So, if some process creates a file that starts growing slowly beyond tmpfs size, it won't "switch" volumes when tmpfs is full. It'll just get out of space (or some generic I/O error, since technically there's still space left in /tmp). But in a lot of scenarios it might do the trick of having /tmp in memory, and just fall back to disk when it grows too much.






            share|improve this answer



























              0














              You could use something like aufs. It let's you "merge" two different mounts inside a single directory. So, in this case you could mount both a tmpfs volume somewhere and a conventional directory on disk, and then unify them using aufs as /tmp. You can even assign priorities, so tmpfs would be used first, and disk would only be used when tmpfs runs out of space.



              It's not a perfect solution, though, because aufs works as a per file basis. So, if some process creates a file that starts growing slowly beyond tmpfs size, it won't "switch" volumes when tmpfs is full. It'll just get out of space (or some generic I/O error, since technically there's still space left in /tmp). But in a lot of scenarios it might do the trick of having /tmp in memory, and just fall back to disk when it grows too much.






              share|improve this answer

























                0












                0








                0







                You could use something like aufs. It let's you "merge" two different mounts inside a single directory. So, in this case you could mount both a tmpfs volume somewhere and a conventional directory on disk, and then unify them using aufs as /tmp. You can even assign priorities, so tmpfs would be used first, and disk would only be used when tmpfs runs out of space.



                It's not a perfect solution, though, because aufs works as a per file basis. So, if some process creates a file that starts growing slowly beyond tmpfs size, it won't "switch" volumes when tmpfs is full. It'll just get out of space (or some generic I/O error, since technically there's still space left in /tmp). But in a lot of scenarios it might do the trick of having /tmp in memory, and just fall back to disk when it grows too much.






                share|improve this answer













                You could use something like aufs. It let's you "merge" two different mounts inside a single directory. So, in this case you could mount both a tmpfs volume somewhere and a conventional directory on disk, and then unify them using aufs as /tmp. You can even assign priorities, so tmpfs would be used first, and disk would only be used when tmpfs runs out of space.



                It's not a perfect solution, though, because aufs works as a per file basis. So, if some process creates a file that starts growing slowly beyond tmpfs size, it won't "switch" volumes when tmpfs is full. It'll just get out of space (or some generic I/O error, since technically there's still space left in /tmp). But in a lot of scenarios it might do the trick of having /tmp in memory, and just fall back to disk when it grows too much.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 1 at 8:14









                jesjimherjesjimher

                1112




                1112



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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%2funix.stackexchange.com%2fquestions%2f365291%2ftmpfs-does-not-overflow-to-swap%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

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

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay