Announcement

Collapse
No announcement yet.

Does the swapfile increase size dynamically?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Does the swapfile increase size dynamically?

    Is the swapfile configured to increase the size dynamically if it is filled up?

    #2
    I believe the answer is "No". It is created a certain size and will not exceed that size. It does dynamically change contents, but the "boundaries" stay the same. Thsi command will show you the size and current usage of your swapfile:

    swapon -s

    The current practice is to have a swapfile the same size as your RAM or at least 2GB if you have less RAM than that. If you feel like you need to make it larger, you must turn off swap, enlarge the current file, and reset and start it as swap.

    The above command would have also revealed where your current swapfile is located. Then, to stop swap and add 2GB to the current file;

    sudo swapoff /swapfile
    sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 oflag=append conv=notrunc
    sudo mkswap /swapfile
    sudo swapon /swapfile


    In order, the above commands do; stop swap, add 2GB, reset the file as a swapfile, restart swap.

    You don't even have to reboot.

    Please Read Me

    Comment


      #3
      Originally posted by oshunluvr View Post
      I believe the answer is "No". It is created a certain size and will not exceed that size. It does dynamically change contents, but the "boundaries" stay the same. Thsi command will show you the size and current usage of your swapfile:

      swapon -s

      The current practice is to have a swapfile the same size as your RAM or at least 2GB if you have less RAM than that. If you feel like you need to make it larger, you must turn off swap, enlarge the current file, and reset and start it as swap.

      The above command would have also revealed where your current swapfile is located. Then, to stop swap and add 2GB to the current file;

      sudo swapoff /swapfile
      sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 oflag=append conv=notrunc
      sudo mkswap /swapfile
      sudo swapon /swapfile


      In order, the above commands do; stop swap, add 2GB, reset the file as a swapfile, restart swap.

      You don't even have to reboot.
      If with Windows, if its swapfile (or whatever it uses) can increase dynamically, then how come Kubuntu doesn't set up a swapfile that can increase dynamically as well?

      Comment


        #4
        Doesn't the installer create a swap partition still, or has that changed?
        Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.

        Of course, being Linux, there are options
        https://github.com/Tookmund/Swapspace

        The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04

        I think for suspend and hibernate purposes, as static file or partition is required.

        I believe with LVM, I bet you can probably automate a swap resize via scripting.
        Last edited by claydoh; Feb 26, 2019, 06:10 PM.

        Comment


          #5
          Originally posted by claydoh View Post
          Doesn't the installer create a swap partition still, or has that changed?
          Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.

          Of course, being Linux, there are options
          https://github.com/Tookmund/Swapspace

          The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04

          I think for suspend and hibernate purposes, as static file or partition is required.

          I believe with LVM, I bet you can probably automate a swap resize via scripting.
          I didn't set up a swap partition at all, but Kubuntu for some reason already has a swapfile setted up and it has 2 GB currently.

          Comment


            #6
            Heh. It's been a bit since I have done a clean, stock install. I usually upgrade.

            Sent from my LG-H931 using Tapatalk

            Comment


              #7
              Originally posted by claydoh View Post
              Doesn't the installer create a swap partition still, or has that changed?
              Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.

              Of course, being Linux, there are options
              https://github.com/Tookmund/Swapspace

              The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04

              I think for suspend and hibernate purposes, as static file or partition is required.

              I believe with LVM, I bet you can probably automate a swap resize via scripting.
              Starting around 16.04 (I believe) the installer creates a swapfile by default unless you already have a swap partition - then it uses that.

              Please Read Me

              Comment

              Working...
              X