Announcement

Collapse
No announcement yet.

Remove swap file/partition in fstab without causing problems?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Remove swap file/partition in fstab without causing problems?

    I did a manual drive partition setup. The first big question was what all the options did with the new installer.

    I set up an ext4 /boot partition, and a fat32 /boot/efi partition - no idea if that is needed.

    then set up encrypted btrfs partitions for / and /home

    Seemed to go ok. Definitely better than the old installer that would crash if trying to create more than one encrypted partition. I would still like to test if 4 or more encrypted partitions can be made during install, but that is another day.

    When booting in and doing the recommended 7 steps for improving nvme life, then rebooting, upon looking at fstab there was an entry for swap under the / encrypted partition.

    Looking at the /@swap folder and file, the file was only 512MB and was the only file in the swap folder in the / directory.

    Can the fstab entry for the swap "partition"/file just be removed? At 512MB is this really doing anything? or is it a self growing file as needed?

    My system has 32gb of ram, which seems enough to hold all the memory use for the few things I do.

    Is the proper way to not use the swap file to just delete the entry in fstab? Any tips for not borking the system?

    thanks

    #2
    For your sake I hope you made the /boot partition big enough (these days I recommend >= 2GB, especially if you have an Nvidia GPU)…

    You need a swap partition or file > your physical RAM if you want to use hibernation.

    Otherwise it is still better to have a swap (e.g. a partition or file) available - as small as it may be - because some programs (and probably therefore also system components) work better with a swap partition or file (and use it, often only a very small part of it) and no programs work worse with one present (even if many programs won't use it at all if your physical RAM is big enough). You could read such statements from kernel developers in recent years.
    There also is no serious Linux distribution which doesn't use some kind of swap by default.
    One thing you should do for a desktop installation, though, is to modify the swappiness value (also see Essential and strongly recommended things to do directly after a Kubuntu 24.04 LTS installation - step 2.). The value of 10 in step 2. is just a rough general recommendation for a desktop system - feel free to experiment with your specific set-up. With lots of RAM you could go as low as 1 for example. This always also depends on your specific use case, of course (size of physical RAM, which programs one uses and uses which way, etc.).

    And yes, you could simply remove (or better: comment out) swap from /etc/fstab (although I would generally not recommend it - see above). Afterwards you can remove the swap file itself, if your system was set up this way (like in a default (K)ubuntu installation).
    But if you have a swap partition on one of your drives and remove swap from /etc/fstab, AFAIK systemd will include it during boot nonetheless.
    You can check this with e.g. sudo swapon --show and free -h - and lsblk -e7 -f (for partitions).
    Last edited by Schwarzer Kater; May 05, 2024, 07:09 AM. Reason: addition
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

    get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
    install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

    Comment


      #3
      Thanks for the reply. I don't do suspend or hibernate, and did set the swappiness to 10 in step 2.

      I am not familiar enough with the ssd/nvme technology to know what a constant writing to swap does, nor the small size of the swap file in my install. I guess that having something that small would indicate some sort of dynamic allocation system, and 512MB is just a size one block of the nvme? And to me that means that block is going to be floating around constantly all over as the nvme does wear leveling.

      I will try the comment out idea and see what happens.

      Thanks.

      Comment


        #4
        What do you guys think about zram rather than using swap file?

        Comment


          #5
          Semi OT:

          shishimaru

          Maybe I would use zram swap on machines that really do not have much RAM (nowadays that would perhaps be 768, 1024 or 1536 MB) and tune e.g. swappiness, vfs_cache_pressure and other memory settings accordingly to make zram swap more efficient for my use case. With very little RAM zram swap can be quite effective.
          On the other hand zram swap has more impact on an old, slower CPU with few cores than on a modern, faster one with many cores.

          I am a bit sceptical about zram and tend to agree with DJ Ware: why use (and reduce) RAM itself, if enough RAM is available and one of swap's original purposes was to clear RAM of certain pages of memory?

          Generally at least I consider using zram swap to be better than having no swap partition or no swap file at all.

          What kind of swap is to prefer depends on the individual use case, of course. Only no swap at all is something I would not recommend.
          Last edited by Schwarzer Kater; May 06, 2024, 10:46 AM. Reason: typo
          Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
          Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

          get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
          install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

          Comment


            #6
            Also: Having two btrfs partitions removes one of major benefits to using BTRFS in the first place. The primary usage of BTRFS is to have ONE file system (a single partition or multiple devices/drives) that holds all the data and segregates it (i.e. / from /home) using subvolumes instead of partitions. This allows all subvolumes to share the free space without artificial borders created by partitioning.

            Please Read Me

            Comment


              #7
              I don't use more btrfs partition, but to be honest I'd still use them. It's just way more comfortable to re-install an OS. Backups exist, but I'd still understand.

              I totally forgot about the fact that zram tries to compress by the way. Still usable if one wants to write less, but at that point the swappiness should still help.

              Comment

              Working...
              X