Is there a maximum size at which a swap file can function?

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








up vote
7
down vote

favorite
1












As far as I know, the theoretical limit for a swap file is insanely large depending on whether a 32bit or 64bit system is used.



I have made a 16GB swap file on a 4GB RAM 64bit system with otherwise low-average specs, because I have more than enough space on my 1TB internal HDD...



But does the large swap file actually make a difference in speed/performance?







share|improve this question


















  • 1




    Related: askubuntu.com/q/49109/367990
    – Byte Commander
    May 27 at 22:52






  • 2




    IMO if you are using swap you really need more RAM, not a larger swap file
    – Panther
    May 27 at 23:35






  • 1




    if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
    – phuclv
    May 28 at 6:00






  • 2




    Related: askubuntu.com/q/1017021/504066
    – PerlDuck
    May 28 at 9:49










  • As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
    – kasperd
    May 28 at 12:09














up vote
7
down vote

favorite
1












As far as I know, the theoretical limit for a swap file is insanely large depending on whether a 32bit or 64bit system is used.



I have made a 16GB swap file on a 4GB RAM 64bit system with otherwise low-average specs, because I have more than enough space on my 1TB internal HDD...



But does the large swap file actually make a difference in speed/performance?







share|improve this question


















  • 1




    Related: askubuntu.com/q/49109/367990
    – Byte Commander
    May 27 at 22:52






  • 2




    IMO if you are using swap you really need more RAM, not a larger swap file
    – Panther
    May 27 at 23:35






  • 1




    if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
    – phuclv
    May 28 at 6:00






  • 2




    Related: askubuntu.com/q/1017021/504066
    – PerlDuck
    May 28 at 9:49










  • As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
    – kasperd
    May 28 at 12:09












up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1





As far as I know, the theoretical limit for a swap file is insanely large depending on whether a 32bit or 64bit system is used.



I have made a 16GB swap file on a 4GB RAM 64bit system with otherwise low-average specs, because I have more than enough space on my 1TB internal HDD...



But does the large swap file actually make a difference in speed/performance?







share|improve this question














As far as I know, the theoretical limit for a swap file is insanely large depending on whether a 32bit or 64bit system is used.



I have made a 16GB swap file on a 4GB RAM 64bit system with otherwise low-average specs, because I have more than enough space on my 1TB internal HDD...



But does the large swap file actually make a difference in speed/performance?









share|improve this question













share|improve this question




share|improve this question








edited May 28 at 12:33









Zanna

47.8k13116226




47.8k13116226










asked May 27 at 22:43









Devon van Schoor

364




364







  • 1




    Related: askubuntu.com/q/49109/367990
    – Byte Commander
    May 27 at 22:52






  • 2




    IMO if you are using swap you really need more RAM, not a larger swap file
    – Panther
    May 27 at 23:35






  • 1




    if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
    – phuclv
    May 28 at 6:00






  • 2




    Related: askubuntu.com/q/1017021/504066
    – PerlDuck
    May 28 at 9:49










  • As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
    – kasperd
    May 28 at 12:09












  • 1




    Related: askubuntu.com/q/49109/367990
    – Byte Commander
    May 27 at 22:52






  • 2




    IMO if you are using swap you really need more RAM, not a larger swap file
    – Panther
    May 27 at 23:35






  • 1




    if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
    – phuclv
    May 28 at 6:00






  • 2




    Related: askubuntu.com/q/1017021/504066
    – PerlDuck
    May 28 at 9:49










  • As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
    – kasperd
    May 28 at 12:09







1




1




Related: askubuntu.com/q/49109/367990
– Byte Commander
May 27 at 22:52




Related: askubuntu.com/q/49109/367990
– Byte Commander
May 27 at 22:52




2




2




IMO if you are using swap you really need more RAM, not a larger swap file
– Panther
May 27 at 23:35




IMO if you are using swap you really need more RAM, not a larger swap file
– Panther
May 27 at 23:35




1




1




if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
– phuclv
May 28 at 6:00




if you're using HDDs then you should use zram instead and lower the priority of the HDD swaps. And such a big swap partition won't help, because by the type you use like 4GB swap your system had been slow to a crawl
– phuclv
May 28 at 6:00




2




2




Related: askubuntu.com/q/1017021/504066
– PerlDuck
May 28 at 9:49




Related: askubuntu.com/q/1017021/504066
– PerlDuck
May 28 at 9:49












As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
– kasperd
May 28 at 12:09




As far as I recall a swap file will consume some amount of physical RAM (I think less than 1% of the size of the swap file). So having an excessively large swap file could hurt performance due to that memory consumption. But for a reasonably sized swap file, that's not going to be a problem.
– kasperd
May 28 at 12:09










6 Answers
6






active

oldest

votes

















up vote
6
down vote













It makes no difference in terms of speed or performance. It just allows you to use up to 20 GB of virtual memory before the OOM killer starts killing processes to reclaim memory.



If you want better performance:



  • decrease swappiness if you don't use more than 4 GB that often

  • add RAM

  • switch to an SSD and put the swap file on it





share|improve this answer




















  • If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
    – Videonauth
    May 27 at 23:13






  • 10




    @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
    – AlexP
    May 28 at 0:30











  • If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
    – thomasrutter
    May 29 at 0:12







  • 1




    Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
    – thomasrutter
    May 29 at 0:14







  • 1




    Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
    – thomasrutter
    May 29 at 15:21


















up vote
5
down vote













You can have up to 32 swap areas (files or partitions) with up to ~4 billion (2^32) pages each, where a "page" is 4kB on a traditional (eg x86 or x86_64) system but can be larger on other architectures or if you have configured large pages specially.



This gives a theoretical maximum of 16TB per swap area, and up to 32 swap areas. There may be other limitations that apply before you reach this but this is as big a swap area that mkswap can create for you.



As to how much you want, any swap area beyond the maximum you actually utilize contributes nothing to system performance or stability. The trick is to estimate the maximum amount of utilization that will ever occur in a normal or even abnormal situation, and use that as your swap file size and no more.



At time of writing, swap space greater than around 4GB more than your physical memory size is very unlikely to be utilized, unless your system is very abnormal. On a typical system such as a desktop system used by one person at a time, you can probably even stop at a maximum of say 6GB to 8GB even if your physical memory is greater.






share|improve this answer





























    up vote
    2
    down vote













    This answer might not be appropriate for Ubuntu 18.04 (thanks to @Chai T. Rex for pointing this out in the comments).



    Anyway for previous versions, here it goes (there is still no proposed update LTS>LTS, so this might still be relevant):



    It's not a file, it's a partition, and yes it does because of swappiness




    The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.




    So basically if your swap partition is much bigger than the RAM that you have, the system will tend to swap more, causing a general slowness.






    share|improve this answer


















    • 4




      There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
      – Chai T. Rex
      May 27 at 22:47











    • Ok thanks, I correct the answer
      – dadexix86
      May 27 at 22:48






    • 1




      I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
      – Byte Commander
      May 27 at 22:55











    • I would assume the same, but until I'll get my hands on it, this is just a wild assumption
      – dadexix86
      May 27 at 22:56











    • There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
      – Devon van Schoor
      May 27 at 23:00


















    up vote
    2
    down vote













    According to the answer by Gilles




    ...There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.




    Additionally, he cites man page for mkswap:




    The maximum useful size of a swap area depends on the architecture and the kernel version.




    In linux/swap.h library there is MAX_SWAPFILES entry, so there is limit on the number of swap files on the kernel level, however that apparently isn't definitive area either. According to the linked document:




    It should be noted that the six bits for “type” should allow up to 64 swap areas to exist in a 32 bit architecture instead of the MAX_SWAPFILES restriction of 32




    Which I understand has having maximum of up to 64 swap files on the 32-bit architectures. However, I haven't noticed in the document mention what would happen on 64-bit architecture. Also worth noting that in this case, OP's efforts to create swap files failed on 30th entry.



    As for swap partitions, there appears to be no limit for that in the kernel, besides previously mentioned constats, but number of any partitions still would be limited by the underlying BIOS and disk layout.






    share|improve this answer





























      up vote
      2
      down vote













      There is not much difference in speed or performance when increasing the swap partition to be arbitrarily large.



      There are several factors related to swap that can affect performance such as swappiness and hard drive type (SDD or HDD).



      Swap is fairly slow and increasing swappiness reduces the performance. However it only has an affect if there is not enough RAM. But it is better than not having any swap. My recommendation is to make the swap partition size twice as big as your RAM.






      share|improve this answer


















      • 5




        that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
        – phuclv
        May 28 at 6:07






      • 3




        @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
        – el.pescado
        May 28 at 7:19










      • 2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
        – Germain
        May 28 at 13:46

















      up vote
      0
      down vote













      I arrive at the fact that a swap file or swap partition practically have no limit. Also, my 16GB swap file is quite big but the size does not affect the speed.



      However what I gather is that what does effect the speed is the system actually making use of that swap space as opposed to the physical hardware.



      My solution to that is to make a high swappiness value so that the swap is not overly used as opposed to the faster hardware.
      so I did:



      sudo -s
      nano /etc/sysctl.conf


      Added to file:



      #vm.swappiness = 50


      save



      sudo sysctl -p


      to refresh (or could have just rebooted)






      share|improve this answer






















      • Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
        – mook765
        May 28 at 6:27











      • But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
        – Devon van Schoor
        May 28 at 12:50











      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: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2faskubuntu.com%2fquestions%2f1041024%2fis-there-a-maximum-size-at-which-a-swap-file-can-function%23new-answer', 'question_page');

      );

      Post as a guest






























      6 Answers
      6






      active

      oldest

      votes








      6 Answers
      6






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      6
      down vote













      It makes no difference in terms of speed or performance. It just allows you to use up to 20 GB of virtual memory before the OOM killer starts killing processes to reclaim memory.



      If you want better performance:



      • decrease swappiness if you don't use more than 4 GB that often

      • add RAM

      • switch to an SSD and put the swap file on it





      share|improve this answer




















      • If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
        – Videonauth
        May 27 at 23:13






      • 10




        @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
        – AlexP
        May 28 at 0:30











      • If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
        – thomasrutter
        May 29 at 0:12







      • 1




        Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
        – thomasrutter
        May 29 at 0:14







      • 1




        Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
        – thomasrutter
        May 29 at 15:21















      up vote
      6
      down vote













      It makes no difference in terms of speed or performance. It just allows you to use up to 20 GB of virtual memory before the OOM killer starts killing processes to reclaim memory.



      If you want better performance:



      • decrease swappiness if you don't use more than 4 GB that often

      • add RAM

      • switch to an SSD and put the swap file on it





      share|improve this answer




















      • If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
        – Videonauth
        May 27 at 23:13






      • 10




        @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
        – AlexP
        May 28 at 0:30











      • If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
        – thomasrutter
        May 29 at 0:12







      • 1




        Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
        – thomasrutter
        May 29 at 0:14







      • 1




        Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
        – thomasrutter
        May 29 at 15:21













      up vote
      6
      down vote










      up vote
      6
      down vote









      It makes no difference in terms of speed or performance. It just allows you to use up to 20 GB of virtual memory before the OOM killer starts killing processes to reclaim memory.



      If you want better performance:



      • decrease swappiness if you don't use more than 4 GB that often

      • add RAM

      • switch to an SSD and put the swap file on it





      share|improve this answer












      It makes no difference in terms of speed or performance. It just allows you to use up to 20 GB of virtual memory before the OOM killer starts killing processes to reclaim memory.



      If you want better performance:



      • decrease swappiness if you don't use more than 4 GB that often

      • add RAM

      • switch to an SSD and put the swap file on it






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered May 27 at 22:49









      Chai T. Rex

      3,45611132




      3,45611132











      • If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
        – Videonauth
        May 27 at 23:13






      • 10




        @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
        – AlexP
        May 28 at 0:30











      • If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
        – thomasrutter
        May 29 at 0:12







      • 1




        Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
        – thomasrutter
        May 29 at 0:14







      • 1




        Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
        – thomasrutter
        May 29 at 15:21

















      • If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
        – Videonauth
        May 27 at 23:13






      • 10




        @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
        – AlexP
        May 28 at 0:30











      • If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
        – thomasrutter
        May 29 at 0:12







      • 1




        Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
        – thomasrutter
        May 29 at 0:14







      • 1




        Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
        – thomasrutter
        May 29 at 15:21
















      If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
      – Videonauth
      May 27 at 23:13




      If you often come into the point of having to swap out memory blocks, a SSD due their architecture and limited write cycles is not the way to go because it can easily use up the SSD's write cycles very quickly. If you only occasionally come into the need of swap memory SSD's are fine.
      – Videonauth
      May 27 at 23:13




      10




      10




      @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
      – AlexP
      May 28 at 0:30





      @Videonauth: "Easily use up the SSD's write cycles very quickly": any kind of half-decent modern SSD can sustain writing the full capacity of the SSD day after day for years. Your advice might have been correct in 2010, but it's out of date. Even a consumer-grade 256 GiB Samsung SSD 840 can sustain writing 100 GiB per day for more than 2 years.
      – AlexP
      May 28 at 0:30













      If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
      – thomasrutter
      May 29 at 0:12





      If you have lots of RAM, decreasing swappiness makes even less difference than if you had limited RAM. Actually installing lots of RAM makes any other tweaks to swap redundant if it's enough that you can avoid swapping. Keep a swap partition for stability "just in case", 99.9% of the time it won't be used, and you'll retain great performance.
      – thomasrutter
      May 29 at 0:12





      1




      1




      Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
      – thomasrutter
      May 29 at 0:14





      Also, the thing about limited SSD write cycles has been untrue for over a decade, it's really time this FUD needs to be called out. Sorry this comment is so redundant given that AlexP already addressed this, but it bears underlining. SSDs are great for write-heavy applications.
      – thomasrutter
      May 29 at 0:14





      1




      1




      Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
      – thomasrutter
      May 29 at 15:21





      Wear leveling in SSDs became a thing around 2008 (2008 paper | 2009 Anandtech article). "Did laptops at normal consumer price points even come with SSDs in 2008" heck no, SSDs were crazy expensive and didn't really come standard.
      – thomasrutter
      May 29 at 15:21













      up vote
      5
      down vote













      You can have up to 32 swap areas (files or partitions) with up to ~4 billion (2^32) pages each, where a "page" is 4kB on a traditional (eg x86 or x86_64) system but can be larger on other architectures or if you have configured large pages specially.



      This gives a theoretical maximum of 16TB per swap area, and up to 32 swap areas. There may be other limitations that apply before you reach this but this is as big a swap area that mkswap can create for you.



      As to how much you want, any swap area beyond the maximum you actually utilize contributes nothing to system performance or stability. The trick is to estimate the maximum amount of utilization that will ever occur in a normal or even abnormal situation, and use that as your swap file size and no more.



      At time of writing, swap space greater than around 4GB more than your physical memory size is very unlikely to be utilized, unless your system is very abnormal. On a typical system such as a desktop system used by one person at a time, you can probably even stop at a maximum of say 6GB to 8GB even if your physical memory is greater.






      share|improve this answer


























        up vote
        5
        down vote













        You can have up to 32 swap areas (files or partitions) with up to ~4 billion (2^32) pages each, where a "page" is 4kB on a traditional (eg x86 or x86_64) system but can be larger on other architectures or if you have configured large pages specially.



        This gives a theoretical maximum of 16TB per swap area, and up to 32 swap areas. There may be other limitations that apply before you reach this but this is as big a swap area that mkswap can create for you.



        As to how much you want, any swap area beyond the maximum you actually utilize contributes nothing to system performance or stability. The trick is to estimate the maximum amount of utilization that will ever occur in a normal or even abnormal situation, and use that as your swap file size and no more.



        At time of writing, swap space greater than around 4GB more than your physical memory size is very unlikely to be utilized, unless your system is very abnormal. On a typical system such as a desktop system used by one person at a time, you can probably even stop at a maximum of say 6GB to 8GB even if your physical memory is greater.






        share|improve this answer
























          up vote
          5
          down vote










          up vote
          5
          down vote









          You can have up to 32 swap areas (files or partitions) with up to ~4 billion (2^32) pages each, where a "page" is 4kB on a traditional (eg x86 or x86_64) system but can be larger on other architectures or if you have configured large pages specially.



          This gives a theoretical maximum of 16TB per swap area, and up to 32 swap areas. There may be other limitations that apply before you reach this but this is as big a swap area that mkswap can create for you.



          As to how much you want, any swap area beyond the maximum you actually utilize contributes nothing to system performance or stability. The trick is to estimate the maximum amount of utilization that will ever occur in a normal or even abnormal situation, and use that as your swap file size and no more.



          At time of writing, swap space greater than around 4GB more than your physical memory size is very unlikely to be utilized, unless your system is very abnormal. On a typical system such as a desktop system used by one person at a time, you can probably even stop at a maximum of say 6GB to 8GB even if your physical memory is greater.






          share|improve this answer














          You can have up to 32 swap areas (files or partitions) with up to ~4 billion (2^32) pages each, where a "page" is 4kB on a traditional (eg x86 or x86_64) system but can be larger on other architectures or if you have configured large pages specially.



          This gives a theoretical maximum of 16TB per swap area, and up to 32 swap areas. There may be other limitations that apply before you reach this but this is as big a swap area that mkswap can create for you.



          As to how much you want, any swap area beyond the maximum you actually utilize contributes nothing to system performance or stability. The trick is to estimate the maximum amount of utilization that will ever occur in a normal or even abnormal situation, and use that as your swap file size and no more.



          At time of writing, swap space greater than around 4GB more than your physical memory size is very unlikely to be utilized, unless your system is very abnormal. On a typical system such as a desktop system used by one person at a time, you can probably even stop at a maximum of say 6GB to 8GB even if your physical memory is greater.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 29 at 0:05

























          answered May 28 at 1:04









          thomasrutter

          25.2k46085




          25.2k46085




















              up vote
              2
              down vote













              This answer might not be appropriate for Ubuntu 18.04 (thanks to @Chai T. Rex for pointing this out in the comments).



              Anyway for previous versions, here it goes (there is still no proposed update LTS>LTS, so this might still be relevant):



              It's not a file, it's a partition, and yes it does because of swappiness




              The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.




              So basically if your swap partition is much bigger than the RAM that you have, the system will tend to swap more, causing a general slowness.






              share|improve this answer


















              • 4




                There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
                – Chai T. Rex
                May 27 at 22:47











              • Ok thanks, I correct the answer
                – dadexix86
                May 27 at 22:48






              • 1




                I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
                – Byte Commander
                May 27 at 22:55











              • I would assume the same, but until I'll get my hands on it, this is just a wild assumption
                – dadexix86
                May 27 at 22:56











              • There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
                – Devon van Schoor
                May 27 at 23:00















              up vote
              2
              down vote













              This answer might not be appropriate for Ubuntu 18.04 (thanks to @Chai T. Rex for pointing this out in the comments).



              Anyway for previous versions, here it goes (there is still no proposed update LTS>LTS, so this might still be relevant):



              It's not a file, it's a partition, and yes it does because of swappiness




              The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.




              So basically if your swap partition is much bigger than the RAM that you have, the system will tend to swap more, causing a general slowness.






              share|improve this answer


















              • 4




                There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
                – Chai T. Rex
                May 27 at 22:47











              • Ok thanks, I correct the answer
                – dadexix86
                May 27 at 22:48






              • 1




                I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
                – Byte Commander
                May 27 at 22:55











              • I would assume the same, but until I'll get my hands on it, this is just a wild assumption
                – dadexix86
                May 27 at 22:56











              • There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
                – Devon van Schoor
                May 27 at 23:00













              up vote
              2
              down vote










              up vote
              2
              down vote









              This answer might not be appropriate for Ubuntu 18.04 (thanks to @Chai T. Rex for pointing this out in the comments).



              Anyway for previous versions, here it goes (there is still no proposed update LTS>LTS, so this might still be relevant):



              It's not a file, it's a partition, and yes it does because of swappiness




              The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.




              So basically if your swap partition is much bigger than the RAM that you have, the system will tend to swap more, causing a general slowness.






              share|improve this answer














              This answer might not be appropriate for Ubuntu 18.04 (thanks to @Chai T. Rex for pointing this out in the comments).



              Anyway for previous versions, here it goes (there is still no proposed update LTS>LTS, so this might still be relevant):



              It's not a file, it's a partition, and yes it does because of swappiness




              The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.




              So basically if your swap partition is much bigger than the RAM that you have, the system will tend to swap more, causing a general slowness.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 27 at 22:47

























              answered May 27 at 22:46









              dadexix86

              5,3632492




              5,3632492







              • 4




                There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
                – Chai T. Rex
                May 27 at 22:47











              • Ok thanks, I correct the answer
                – dadexix86
                May 27 at 22:48






              • 1




                I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
                – Byte Commander
                May 27 at 22:55











              • I would assume the same, but until I'll get my hands on it, this is just a wild assumption
                – dadexix86
                May 27 at 22:56











              • There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
                – Devon van Schoor
                May 27 at 23:00













              • 4




                There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
                – Chai T. Rex
                May 27 at 22:47











              • Ok thanks, I correct the answer
                – dadexix86
                May 27 at 22:48






              • 1




                I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
                – Byte Commander
                May 27 at 22:55











              • I would assume the same, but until I'll get my hands on it, this is just a wild assumption
                – dadexix86
                May 27 at 22:56











              • There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
                – Devon van Schoor
                May 27 at 23:00








              4




              4




              There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
              – Chai T. Rex
              May 27 at 22:47





              There are swap files now, and they're the default (instead of partitions) when installing 18.04 from scratch.
              – Chai T. Rex
              May 27 at 22:47













              Ok thanks, I correct the answer
              – dadexix86
              May 27 at 22:48




              Ok thanks, I correct the answer
              – dadexix86
              May 27 at 22:48




              1




              1




              I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
              – Byte Commander
              May 27 at 22:55





              I assume the behaviour of swap pretty much stays the same, no matter whether it's backed by a partition or file. You can also have multiple swap files and/or partitions at the same time. Anyway, I don't think more swap would have a negative effect while there's still enough RAM left.
              – Byte Commander
              May 27 at 22:55













              I would assume the same, but until I'll get my hands on it, this is just a wild assumption
              – dadexix86
              May 27 at 22:56





              I would assume the same, but until I'll get my hands on it, this is just a wild assumption
              – dadexix86
              May 27 at 22:56













              There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
              – Devon van Schoor
              May 27 at 23:00





              There swap partitions and there are swap files. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot). Swap partition are better in case of full disk where the swap file could be created fragmented. ... The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation – Devon van Schoor j
              – Devon van Schoor
              May 27 at 23:00











              up vote
              2
              down vote













              According to the answer by Gilles




              ...There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.




              Additionally, he cites man page for mkswap:




              The maximum useful size of a swap area depends on the architecture and the kernel version.




              In linux/swap.h library there is MAX_SWAPFILES entry, so there is limit on the number of swap files on the kernel level, however that apparently isn't definitive area either. According to the linked document:




              It should be noted that the six bits for “type” should allow up to 64 swap areas to exist in a 32 bit architecture instead of the MAX_SWAPFILES restriction of 32




              Which I understand has having maximum of up to 64 swap files on the 32-bit architectures. However, I haven't noticed in the document mention what would happen on 64-bit architecture. Also worth noting that in this case, OP's efforts to create swap files failed on 30th entry.



              As for swap partitions, there appears to be no limit for that in the kernel, besides previously mentioned constats, but number of any partitions still would be limited by the underlying BIOS and disk layout.






              share|improve this answer


























                up vote
                2
                down vote













                According to the answer by Gilles




                ...There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.




                Additionally, he cites man page for mkswap:




                The maximum useful size of a swap area depends on the architecture and the kernel version.




                In linux/swap.h library there is MAX_SWAPFILES entry, so there is limit on the number of swap files on the kernel level, however that apparently isn't definitive area either. According to the linked document:




                It should be noted that the six bits for “type” should allow up to 64 swap areas to exist in a 32 bit architecture instead of the MAX_SWAPFILES restriction of 32




                Which I understand has having maximum of up to 64 swap files on the 32-bit architectures. However, I haven't noticed in the document mention what would happen on 64-bit architecture. Also worth noting that in this case, OP's efforts to create swap files failed on 30th entry.



                As for swap partitions, there appears to be no limit for that in the kernel, besides previously mentioned constats, but number of any partitions still would be limited by the underlying BIOS and disk layout.






                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  According to the answer by Gilles




                  ...There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.




                  Additionally, he cites man page for mkswap:




                  The maximum useful size of a swap area depends on the architecture and the kernel version.




                  In linux/swap.h library there is MAX_SWAPFILES entry, so there is limit on the number of swap files on the kernel level, however that apparently isn't definitive area either. According to the linked document:




                  It should be noted that the six bits for “type” should allow up to 64 swap areas to exist in a 32 bit architecture instead of the MAX_SWAPFILES restriction of 32




                  Which I understand has having maximum of up to 64 swap files on the 32-bit architectures. However, I haven't noticed in the document mention what would happen on 64-bit architecture. Also worth noting that in this case, OP's efforts to create swap files failed on 30th entry.



                  As for swap partitions, there appears to be no limit for that in the kernel, besides previously mentioned constats, but number of any partitions still would be limited by the underlying BIOS and disk layout.






                  share|improve this answer














                  According to the answer by Gilles




                  ...There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.




                  Additionally, he cites man page for mkswap:




                  The maximum useful size of a swap area depends on the architecture and the kernel version.




                  In linux/swap.h library there is MAX_SWAPFILES entry, so there is limit on the number of swap files on the kernel level, however that apparently isn't definitive area either. According to the linked document:




                  It should be noted that the six bits for “type” should allow up to 64 swap areas to exist in a 32 bit architecture instead of the MAX_SWAPFILES restriction of 32




                  Which I understand has having maximum of up to 64 swap files on the 32-bit architectures. However, I haven't noticed in the document mention what would happen on 64-bit architecture. Also worth noting that in this case, OP's efforts to create swap files failed on 30th entry.



                  As for swap partitions, there appears to be no limit for that in the kernel, besides previously mentioned constats, but number of any partitions still would be limited by the underlying BIOS and disk layout.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 27 at 23:24

























                  answered May 27 at 23:18









                  Sergiy Kolodyazhnyy

                  63.9k9127274




                  63.9k9127274




















                      up vote
                      2
                      down vote













                      There is not much difference in speed or performance when increasing the swap partition to be arbitrarily large.



                      There are several factors related to swap that can affect performance such as swappiness and hard drive type (SDD or HDD).



                      Swap is fairly slow and increasing swappiness reduces the performance. However it only has an affect if there is not enough RAM. But it is better than not having any swap. My recommendation is to make the swap partition size twice as big as your RAM.






                      share|improve this answer


















                      • 5




                        that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                        – phuclv
                        May 28 at 6:07






                      • 3




                        @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                        – el.pescado
                        May 28 at 7:19










                      • 2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                        – Germain
                        May 28 at 13:46














                      up vote
                      2
                      down vote













                      There is not much difference in speed or performance when increasing the swap partition to be arbitrarily large.



                      There are several factors related to swap that can affect performance such as swappiness and hard drive type (SDD or HDD).



                      Swap is fairly slow and increasing swappiness reduces the performance. However it only has an affect if there is not enough RAM. But it is better than not having any swap. My recommendation is to make the swap partition size twice as big as your RAM.






                      share|improve this answer


















                      • 5




                        that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                        – phuclv
                        May 28 at 6:07






                      • 3




                        @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                        – el.pescado
                        May 28 at 7:19










                      • 2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                        – Germain
                        May 28 at 13:46












                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote









                      There is not much difference in speed or performance when increasing the swap partition to be arbitrarily large.



                      There are several factors related to swap that can affect performance such as swappiness and hard drive type (SDD or HDD).



                      Swap is fairly slow and increasing swappiness reduces the performance. However it only has an affect if there is not enough RAM. But it is better than not having any swap. My recommendation is to make the swap partition size twice as big as your RAM.






                      share|improve this answer














                      There is not much difference in speed or performance when increasing the swap partition to be arbitrarily large.



                      There are several factors related to swap that can affect performance such as swappiness and hard drive type (SDD or HDD).



                      Swap is fairly slow and increasing swappiness reduces the performance. However it only has an affect if there is not enough RAM. But it is better than not having any swap. My recommendation is to make the swap partition size twice as big as your RAM.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited May 28 at 12:37









                      Zanna

                      47.8k13116226




                      47.8k13116226










                      answered May 27 at 23:01







                      user834668














                      • 5




                        that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                        – phuclv
                        May 28 at 6:07






                      • 3




                        @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                        – el.pescado
                        May 28 at 7:19










                      • 2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                        – Germain
                        May 28 at 13:46












                      • 5




                        that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                        – phuclv
                        May 28 at 6:07






                      • 3




                        @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                        – el.pescado
                        May 28 at 7:19










                      • 2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                        – Germain
                        May 28 at 13:46







                      5




                      5




                      that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                      – phuclv
                      May 28 at 6:07




                      that recommendation is outdated. Modern systems with 32 or 64GB RAM won't need 64 or 128GB swap
                      – phuclv
                      May 28 at 6:07




                      3




                      3




                      @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                      – el.pescado
                      May 28 at 7:19




                      @LÆ°uVÄ©nhPhúc I wouldn't use more than 2GB of swap these days...
                      – el.pescado
                      May 28 at 7:19












                      2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                      – Germain
                      May 28 at 13:46




                      2gb seems very low ... virtual machines or games could really fill more than 2gb of swap very quickly. I think 4 to 8gb of swap works well with any amount of ram. If you need more than 8gb then you should probably add more ram.
                      – Germain
                      May 28 at 13:46










                      up vote
                      0
                      down vote













                      I arrive at the fact that a swap file or swap partition practically have no limit. Also, my 16GB swap file is quite big but the size does not affect the speed.



                      However what I gather is that what does effect the speed is the system actually making use of that swap space as opposed to the physical hardware.



                      My solution to that is to make a high swappiness value so that the swap is not overly used as opposed to the faster hardware.
                      so I did:



                      sudo -s
                      nano /etc/sysctl.conf


                      Added to file:



                      #vm.swappiness = 50


                      save



                      sudo sysctl -p


                      to refresh (or could have just rebooted)






                      share|improve this answer






















                      • Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                        – mook765
                        May 28 at 6:27











                      • But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                        – Devon van Schoor
                        May 28 at 12:50















                      up vote
                      0
                      down vote













                      I arrive at the fact that a swap file or swap partition practically have no limit. Also, my 16GB swap file is quite big but the size does not affect the speed.



                      However what I gather is that what does effect the speed is the system actually making use of that swap space as opposed to the physical hardware.



                      My solution to that is to make a high swappiness value so that the swap is not overly used as opposed to the faster hardware.
                      so I did:



                      sudo -s
                      nano /etc/sysctl.conf


                      Added to file:



                      #vm.swappiness = 50


                      save



                      sudo sysctl -p


                      to refresh (or could have just rebooted)






                      share|improve this answer






















                      • Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                        – mook765
                        May 28 at 6:27











                      • But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                        – Devon van Schoor
                        May 28 at 12:50













                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      I arrive at the fact that a swap file or swap partition practically have no limit. Also, my 16GB swap file is quite big but the size does not affect the speed.



                      However what I gather is that what does effect the speed is the system actually making use of that swap space as opposed to the physical hardware.



                      My solution to that is to make a high swappiness value so that the swap is not overly used as opposed to the faster hardware.
                      so I did:



                      sudo -s
                      nano /etc/sysctl.conf


                      Added to file:



                      #vm.swappiness = 50


                      save



                      sudo sysctl -p


                      to refresh (or could have just rebooted)






                      share|improve this answer














                      I arrive at the fact that a swap file or swap partition practically have no limit. Also, my 16GB swap file is quite big but the size does not affect the speed.



                      However what I gather is that what does effect the speed is the system actually making use of that swap space as opposed to the physical hardware.



                      My solution to that is to make a high swappiness value so that the swap is not overly used as opposed to the faster hardware.
                      so I did:



                      sudo -s
                      nano /etc/sysctl.conf


                      Added to file:



                      #vm.swappiness = 50


                      save



                      sudo sysctl -p


                      to refresh (or could have just rebooted)







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited May 28 at 8:40









                      Zanna

                      47.8k13116226




                      47.8k13116226










                      answered May 28 at 0:36









                      Devon van Schoor

                      364




                      364











                      • Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                        – mook765
                        May 28 at 6:27











                      • But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                        – Devon van Schoor
                        May 28 at 12:50

















                      • Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                        – mook765
                        May 28 at 6:27











                      • But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                        – Devon van Schoor
                        May 28 at 12:50
















                      Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                      – mook765
                      May 28 at 6:27





                      Adding the line #vm.swappiness = 50 to /etc/sysctl.conf doesn't have any effect, the leading # makes this line to be a comment, remove it. You can check swappiness with cat /proc/sys/vm/swappiness.
                      – mook765
                      May 28 at 6:27













                      But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                      – Devon van Schoor
                      May 28 at 12:50





                      But the method I described did work. When I input [cat /proc/sys/vm/swappiness] I get 50 as the output
                      – Devon van Schoor
                      May 28 at 12:50













                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1041024%2fis-there-a-maximum-size-at-which-a-swap-file-can-function%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      pylint3 and pip3 broken

                      Missing snmpget and snmpwalk

                      How to enroll fingerprints to Ubuntu 17.10 with VFS491