Announcement

Collapse
No announcement yet.

Enlarging a BTRFS swap file

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

    #16
    NAME TYPE SIZE USED PRIO
    /swap/swapfile file 64G 465.2M -2
    steve7233@doctortux:~$


    Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

    http://www.kubuntu.org/getkubuntu

    Comment


      #17
      # /etc/fstab: static file system information.
      #
      # Use 'blkid' to print the universally unique identifier for a device; this may
      # be used with UUID= as a more robust way to name devices that works even if
      # disks are added and removed. See fstab(5).
      #
      # <file system> <mount point> <type> <options> <dump> <pass>
      UUID=9848703b-0c49-4cc1-980b-8b114cbe6fcb / btrfs subvol=/@,defaults,noatime,autodefrag,discard,compress=lzo 0 0
      UUID=9848703b-0c49-4cc1-980b-8b114cbe6fcb /home btrfs subvol=/@home,defaults,noatime,autodefrag,discard,compress =lzo 0 0
      UUID=9848703b-0c49-4cc1-980b-8b114cbe6fcb /swap btrfs subvol=/@swap,defaults 0 0
      /swap/swapfile swap swap defaults 0 0
      tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

      Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

      http://www.kubuntu.org/getkubuntu

      Comment


        #18
        Looks like it shows the one I tried to create, but I can't get it working yet.
        Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

        http://www.kubuntu.org/getkubuntu

        Comment


          #19
          Have you read the documentation? Swapfile - BTRFS documentation - Swapfile
          Windows no longer obstruct my view.
          Using Kubuntu Linux since March 23, 2007.
          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

          Comment


            #20
            When I try to use sudo swapon /swap/swapfile, it says device or resource busy. How do I find out what is using it?
            Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

            http://www.kubuntu.org/getkubuntu

            Comment


              #21
              I accidentally got it working. I don't know how. I will figure out how to make it permanent later. Oops, I forgot to click the post button. I had typed this a few hours ago, but forgot to post it. I just got back, and now I can see about making it permanent.
              Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

              http://www.kubuntu.org/getkubuntu

              Comment


                #22
                Should I replace the swapfile line in my fstab, or will the old one work? See comment #17 for my fstab.
                Just to remind users and devs that Ubuntu and its flavors have a long way to go to be as usr friendly as they should be.

                http://www.kubuntu.org/getkubuntu

                Comment


                  #23
                  Originally posted by steve7233 View Post
                  Should I replace the swapfile line in my fstab, or will the old one work? See comment #17 for my fstab.
                  I would leave it. It looks OK.

                  Comment


                    #24
                    Originally posted by steve7233 View Post
                    UUID=9848703b-0c49-4cc1-980b-8b114cbe6fcb /swap btrfs subvol=/@swap,defaults 0 0
                    /swap/swapfile swap swap defaults 0 0
                    You have a subvolume for swap and a swapfile? Why! And, the mount point you have in the /swap/swapfile stanza isn't correct (swap); it should be none.

                    AI Overview

                    An /etc/fstab entry for a btrfs swapfile should have the following format: /path/to/swapfile none swap defaults 0 0. The none in the second field indicates that the swapfile is not a typical mount point, and the third field specifies the filesystem type as swap. The defaults and 0 0 are standard options for swapfiles, ensuring they are handled correctly at boot.

                    Device /swapfile The absolute path to the swapfile. You can also use /dev//swapfile` if the file is in the root.
                    Mount Point none This is the mount point. For swap files, this should be none.
                    Filesystem Type swap This specifies the filesystem type as swap.
                    Options defaults This is a standard option for swap files. You may also see sw.
                    Dump 0 This field is not used for swap files and should be 0.
                    Pass 0 This field is not used for swap files and should be 0.

                    Example entry for a swapfile

                    /swapfile none swap defaults 0 0

                    How to apply the entry
                    • Create the swapfile: Use dd or fallocate to create a swapfile of the desired size.
                    • Set correct permissions:
                      chmod 600 /swapfile
                    • Set up the swap file:
                      mkswap /swapfile`
                    • Add the entry to /etc/fstab:
                      echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab
                    • Activate the swapfile:
                      sudo swapon -a
                    Last edited by Snowhog; Nov 21, 2025, 09:47 AM.
                    Windows no longer obstruct my view.
                    Using Kubuntu Linux since March 23, 2007.
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #25
                      Originally posted by Snowhog View Post
                      You have a subvolume for swap and a swapfile? Why! And, the mount point you have in the /swap/swapfile stanza isn't correct (swap); it should be none.
                      I have seen that Kubuntu does it this way in 25.10 on a fresh installation. It seems to solve some auto-mount problems with btrfs for some users.

                      AI Overview
                      Mount point none swap
                      Type swap swap
                      Effect Swapon called, standard Swapon called, systemd ordering safer for Btrfs
                      So essentially, both work. Ubuntu switched to the swap mount point as a practical workaround for Btrfs + systemd startup ordering.

                      Comment

                      Users Viewing This Topic

                      Collapse

                      There are 0 users viewing this topic.

                      Working...
                      X