Announcement

Collapse
No announcement yet.

Subvolume won't delete

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

    Subvolume won't delete

    Awhile ago I had to revert to a pprevious setup due to a problematic upgrade. The recovery went well, but the process left the previous @ subvolume (which I renamed @_new) as a lingering subvolume in a group which includes @, @home, and a swap file. I've tried to delete @_new, both using the command line as well as Oshluvr's script for Dolphin, but no luck. I'm notified that the subvolume has been deleted, but it hasn't bee, I suspect this might be a problem of heirarchy, but since I am by and large ignorant of the structure of btrfs, I have no idea what to do. Any help would be appreciated.

    #2
    The only time I've had trouble deleting a subvolume was when another subvolume was nested within it.

    So you're saying that when using the command line, you get no response from the command line - no errors or messages - but the subvolume remains?

    Does it still have content or is it empty?

    Please Read Me

    Comment


      #3
      Assuming this subvolume is under /, enter this in Konsole and post what it returns:

      Code:
      sudo btrfs su li /

      Please Read Me

      Comment


        #4
        Also, make sure the subvolume is NOT read-only

        Please Read Me

        Comment


          #5
          Here's the listing, plus the results of the delete command by terminal:

          steve@steve-b460mds3hv2:~$ sudo btrfs su li /
          [sudo] password for steve:
          ID 256 gen 296249 top level 5 path @_new
          ID 258 gen 296205 top level 5 path @swap
          ID 259 gen 70 top level 256 path @_new/var/lib/portables
          ID 260 gen 70 top level 256 path @_new/var/lib/machines
          ID 263 gen 296254 top level 5 path @home
          ID 429 gen 296254 top level 5 path @
          ID 438 gen 291953 top level 5 path snapshots/@_260712-194929_ro
          ID 439 gen 291955 top level 5 path snapshots/@home_260712-195022_ro
          ID 440 gen 295884 top level 5 path snapshots/@_260719-194320_ro
          ID 441 gen 295887 top level 5 path snapshots/@home_260719-194439_ro
          steve@steve-b460mds3hv2:~$ sudo btrfs subv delete /mnt/@_new
          Delete subvolume 256 (no-commit): '/mnt/@_new'
          ERROR: Could not destroy subvolume/snapshot: Directory not empty


          Comment


            #6
            Originally posted by oldgeek View Post
            ERROR: Could not destroy subvolume/snapshot: Directory not empty



            This error occurs because Btrfs does not allow you to delete a parent subvolume if it contains nested, hidden subvolumes inside it. Even if ls shows the directory is empty, systemd components (like machines or portables) or Docker/Podman layers often automatically create subvolumes within your snapshots, blocking the deletion.

            To resolve this issue, you must identify and delete the nested subvolumes first.

            Step 1: Find the Hidden Nested Subvolumes

            Run the following command to reveal any hidden nested subvolumes under your target directory:


            sudo btrfs subvolume list -o /path/to/your/target/subvolume

            Use code with caution.


            (Note: Replace /path/to/your/target/subvolume with the exact path of the subvolume you are trying to delete.)


            Step 2: Delete the Inner Subvolumes

            The step above will spit out a list of nested paths. Delete each of those inner subvolumes individually, starting from the deepest level:


            sudo btrfs subvolume delete /path/to/your/target/subvolume/nested/path

            Use code with caution.



            Step 3: Delete the Parent Subvolume

            Once all the inner subvolumes are cleared out, you can successfully delete your main subvolume without errors:

            sudo btrfs subvolume delete /path/to/your/target/subvolume




            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


              #7
              Originally posted by oldgeek View Post
              Here's the listing, plus the results of the delete command by terminal:

              steve@steve-b460mds3hv2:~$ sudo btrfs su li /
              [sudo] password for steve:
              ID 256 gen 296249 top level 5 path @_new
              ID 258 gen 296205 top level 5 path @swap
              ID 259 gen 70 top level 256 path @_new/var/lib/portables
              ID 260 gen 70 top level 256 path @_new/var/lib/machines
              ID 263 gen 296254 top level 5 path @home
              ID 429 gen 296254 top level 5 path @
              ID 438 gen 291953 top level 5 path snapshots/@_260712-194929_ro
              ID 439 gen 291955 top level 5 path snapshots/@home_260712-195022_ro
              ID 440 gen 295884 top level 5 path snapshots/@_260719-194320_ro
              ID 441 gen 295887 top level 5 path snapshots/@home_260719-194439_ro
              steve@steve-b460mds3hv2:~$ sudo btrfs subv delete /mnt/@_new
              Delete subvolume 256 (no-commit): '/mnt/@_new'
              ERROR: Could not destroy subvolume/snapshot: Directory not empty


              Well, there you go. You have two nested subvolumes under "@_new":

              Code:
              ID 259 gen 70 top level 256 path @_new/var/lib/portables
              ID 260 gen 70 top level 256 path @_new/var/lib/machines
              Do this in Konsole:
              Code:
              sudo btrfs su de -c /mnt/@_new/var/lib/portables​
              sudo btrfs su de -c /mnt/@_new/var/lib/machines
              sudo btrfs su de -c /mnt/@_new

              Please Read Me

              Comment


                #8
                I tried to delete both subvolumes, but got error messages:

                steve@steve-b460mds3hv2:~$ sudo btrfs su de -c /mnt/@_new/var/lib/portables​
                ERROR: Could not statfs: No such file or directory
                steve@steve-b460mds3hv2:~$ sudo btrfs su de -c /mnt/@_new/var/lib/machines
                ERROR: Could not statfs: No such file or directory


                Comment


                  #9
                  UPDATE: Using oshunluvr's btrfs script for Dolphin, I was able to delete the two nested files as well as the @_new subvolume. I don't know why the terminal commands didn't work, though. Viewing the nested files on Dolphin, I saw a padlock icon on both. Can anyone clear up these two mysteries for me? And thanks to the gentleman who answered my question and led me to the correct solution.

                  Comment


                    #10
                    You would see a "padlock" using Dolphin because they were owned by root user and not allowed to be viewed by other users.

                    I can't answer why the command line deletes didn't work except to speculate that the path was incorrect. Which might explain why the Dolphin service menu did work because it would sus the correct path.

                    For future reference, note that Read-Only subvolumes/snapshots are not delete-able until they are set as Read-Write. The Dolphin service menus can check and change that setting as well.

                    BTW, glad you're getting some use from my efforts re. the Dolphin menus
                    Last edited by oshunluvr; Today, 08:58 AM.

                    Please Read Me

                    Comment


                      #11
                      Thanks for clearing that up. I find your service menu invaluable in doing my weekly mairtenance (snapshots, backups) and don't use anything else.

                      Comment


                        #12
                        Originally posted by oshunluvr View Post
                        For future reference, note that Read-Only subvolumes/snapshots are not delete-able until they are set as Read-Write.
                        I don't get that.
                        Code:
                        $ sudo btrfs subvolume create @foo
                        Create subvolume './@foo'
                        $ sudo btrfs subvolume snapshot -r @foo @bar
                        Create readonly snapshot of '@foo' in '@bar'
                        $ sudo btrfs subvolume delete @bar
                        Delete subvolume 570 (no-commit): '/t/@bar'
                        I just deleted a read-only snapshot.
                        Regards, John Little

                        Comment


                          #13
                          Originally posted by jlittle View Post

                          I don't get that.
                          Code:
                          $ sudo btrfs subvolume create @foo
                          Create subvolume './@foo'
                          $ sudo btrfs subvolume snapshot -r @foo @bar
                          Create readonly snapshot of '@foo' in '@bar'
                          $ sudo btrfs subvolume delete @bar
                          Delete subvolume 570 (no-commit): '/t/@bar'
                          I just deleted a read-only snapshot.
                          Maybe they changed that and my info is old...

                          Looks like that was "fixed" back in 2015 or so, lol
                          Last edited by oshunluvr; Today, 08:58 AM.

                          Please Read Me

                          Comment

                          Users Viewing This Topic

                          Collapse

                          There are 0 users viewing this topic.

                          Working...
                          X