How much space would be freed by removing a btrfs subvolume? Announcing the arrival of Valued...

Fundamental Solution of the Pell Equation

How to tell that you are a giant?

How does debian/ubuntu knows a package has a updated version

How to react to hostile behavior from a senior developer?

Identify plant with long narrow paired leaves and reddish stems

What's the meaning of 間時肆拾貳 at a car parking sign

How come Sam didn't become Lord of Horn Hill?

A coin, having probability p of landing heads and probability of q=(1-p) of landing on heads.

What to do with chalk when deepwater soloing?

How discoverable are IPv6 addresses and AAAA names by potential attackers?

How to deal with a team lead who never gives me credit?

Identifying polygons that intersect with another layer using QGIS?

Coloring maths inside a tcolorbox

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Short Story with Cinderella as a Voo-doo Witch

Why did the rest of the Eastern Bloc not invade Yugoslavia?

What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

Can I cast Passwall to drop an enemy into a 20-foot pit?

porting install scripts : can rpm replace apt?

prime numbers and expressing non-prime numbers

String `!23` is replaced with `docker` in command line

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Overriding an object in memory with placement new



How much space would be freed by removing a btrfs subvolume?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questioninstall with BTRFS: subvolume/partition scheme?How to check (simulate), how much space will be freed after I remove a btrfs subvolume?How does enabling btrfs quotas impact the system?Btrfs subvolume UUID clashBtrfs+LXC: any way to show even rough estimated free space for quota'ed subvol hosting LXC container?Install OpenSUSE in a BTRFS subvolumeWhy is the default top-level subvolume (id=5) not shown in btrfs subvolume list -a?How to resize at the beginning/move a btrfs partition on the command line?How to encrypt a btrfs subvolume?Span BTRFS over multiple partitions to increase disk space





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







11















Is there any way to calculate how much space I would free if I would remove one (or several) subvolumes on a Btrfs disk (without actually removing them)? I know that there is "currently no code that will do the calculation for you", but how would you do it?



I also wonder why they are saying that it would be so slow? Both actually removing a subvolume and asking about free space is very fast in my experience, why would doing the same thing hypothetically be so much slower?










share|improve this question


















  • 2





    I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

    – Adam Ryczkowski
    Aug 24 '14 at 10:06






  • 1





    You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

    – etskinner
    Apr 26 '17 at 12:34




















11















Is there any way to calculate how much space I would free if I would remove one (or several) subvolumes on a Btrfs disk (without actually removing them)? I know that there is "currently no code that will do the calculation for you", but how would you do it?



I also wonder why they are saying that it would be so slow? Both actually removing a subvolume and asking about free space is very fast in my experience, why would doing the same thing hypothetically be so much slower?










share|improve this question


















  • 2





    I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

    – Adam Ryczkowski
    Aug 24 '14 at 10:06






  • 1





    You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

    – etskinner
    Apr 26 '17 at 12:34
















11












11








11


2






Is there any way to calculate how much space I would free if I would remove one (or several) subvolumes on a Btrfs disk (without actually removing them)? I know that there is "currently no code that will do the calculation for you", but how would you do it?



I also wonder why they are saying that it would be so slow? Both actually removing a subvolume and asking about free space is very fast in my experience, why would doing the same thing hypothetically be so much slower?










share|improve this question














Is there any way to calculate how much space I would free if I would remove one (or several) subvolumes on a Btrfs disk (without actually removing them)? I know that there is "currently no code that will do the calculation for you", but how would you do it?



I also wonder why they are saying that it would be so slow? Both actually removing a subvolume and asking about free space is very fast in my experience, why would doing the same thing hypothetically be so much slower?







btrfs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 22 '14 at 9:02









HjulleHjulle

1606




1606








  • 2





    I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

    – Adam Ryczkowski
    Aug 24 '14 at 10:06






  • 1





    You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

    – etskinner
    Apr 26 '17 at 12:34
















  • 2





    I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

    – Adam Ryczkowski
    Aug 24 '14 at 10:06






  • 1





    You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

    – etskinner
    Apr 26 '17 at 12:34










2




2





I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

– Adam Ryczkowski
Aug 24 '14 at 10:06





I hope you know, that btrfs.wiki.kernel.org/index.php/Btrfs_mailing_list might be a better place to ask questions about the inner workings of the btrfs (or any other kernel component). If you get the answer please post it here as well. I'm curious about the answer myself.

– Adam Ryczkowski
Aug 24 '14 at 10:06




1




1





You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

– etskinner
Apr 26 '17 at 12:34







You say "Both actually removing a subvolume and asking about free space is very fast in my experience". When you delete a subvolume, it's really just marking that subvolume for deletion, it only actually frees those blocks when it gets time (which is what the 'no-commit' message means when you do it), so no, deleting isn't necessarily very fast.

– etskinner
Apr 26 '17 at 12:34












1 Answer
1






active

oldest

votes


















1














You should take a look at btrfs quota and btrfs qgroups (quota groups).



Basically qgroups do exactly what you requested, they track how much space is allocated by subvolumes. To enable qgroup functionality for a btrfs filesystem you have to



# btrfs quota enable /path/to/btrfs/filesystem


However, before you do this be warned that this triggers a complete re-computation of the qgroup data which will take some time especially for large filesystems with many subvolumes. This process runs asynchronously in the background. You can already check the status of the qgroups with



# btrfs qgroup show /path/to/btrfs/filesystem


This will give you some output like this:



WARNING: rescan is running, qgroup data may be incorrect
qgroupid rfer excl
-------- ---- ----
0/5 843.69GiB 61.91MiB
0/4881 811.06GiB 9.34GiB
0/7990 867.32GiB 329.91MiB
0/8400 867.17GiB 37.64MiB


(The warning in the first line is present as long as the rescan is still running.)



Btrfs automatically creates a qgroup for each subvolume. In this case there are three subvolumes with subvolume IDs 4881, 7990, and 8400. The part before the forward slash is the level of the qgroup. Each subvolume qgroup is on level 0. Additionally there is a special qgroup on level 0 that always has ID 5 and corresponds to the root of the btrfs filesystem.



For each qgroup the above output shows how much space is referenced by it. That means that the corresponding subvolume contains files whose total size equals the shown number.



However, due to snapshots and the copy-on-write nature of btrfs subvolumes may share files. This means that the content (or actually the extents) of files may be referenced by more than one subvolume. This is expressed by the second number which shows how much space is exclusively allocated by each subvolume and is not shared with any other subvolume. In case you delete a subvolume this is the space that will actually be freed.



If you want to find out how much space would be freed if you delete multiple subvolumes, you can use the aforementioned levels. qgroups are organized in a hierachy and groups on upper levels (higher than 0) aggregate the information of lower levels.



Thus, to find out how much space would be freed if subvolumes 4881 and 7990 (in the above example) would be deleted create a new qgroup (arbitrarily with ID 0, but you may choose whatever you like here) on level 1 with



# btrfs qgroup create 1/0 /path/to/btrfs/filesystem


Then assign the newly created qgroup as a parent to the qgroups of the subvolumes you want to delete with



# btrfs qgroup assign 0/4881 1/0 /path/to/btrfs/filesystem
# btrfs qgroup assign 0/7990 1/0 /path/to/btrfs/filesystem


This will trigger another re-scan of the quota information which may take a while. If it is finished and you now issue



# btrfs qgroup show -p /path/to/btrfs/filesystem


you get an output like this:



qgroupid rfer excl parent
-------- ---- ---- ------
0/5 1.38TiB 2.51GiB ---
0/4881 1.11TiB 10.86GiB 1/0
0/7990 1.23TiB 502.41MiB 1/0
0/8400 1.34TiB 1.69GiB 1/0
1/0 1.51TiB 132.23GiB ---



(I added the -p flag to add the parent column to the output which shows the parent/child relationship of the qgroups.)



Now the line with qgroup 1/0 tells you how much space is referenced by both subvolumes you want to delete and, more importantly, it tells you how much space is allocated by them exclusively. This is the amount of space that will be freed if you delete both subvolumes.




I also wonder why they are saying that it would be so slow?




This is due to the copy-on-write nature of btrfs together with snapshots. If you create a snapshot in btrfs (normally) all actual data in the newly created subvolume that contains the snapshot is shared with the source of the snapshot. Only when a file is changed or replaced in the source does it point to different content (extents). This makes it very difficult to assess how much space would actually be freed if a subvolume is deleted because you have to account for all the space that is shared with other subvolumes.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f151541%2fhow-much-space-would-be-freed-by-removing-a-btrfs-subvolume%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You should take a look at btrfs quota and btrfs qgroups (quota groups).



    Basically qgroups do exactly what you requested, they track how much space is allocated by subvolumes. To enable qgroup functionality for a btrfs filesystem you have to



    # btrfs quota enable /path/to/btrfs/filesystem


    However, before you do this be warned that this triggers a complete re-computation of the qgroup data which will take some time especially for large filesystems with many subvolumes. This process runs asynchronously in the background. You can already check the status of the qgroups with



    # btrfs qgroup show /path/to/btrfs/filesystem


    This will give you some output like this:



    WARNING: rescan is running, qgroup data may be incorrect
    qgroupid rfer excl
    -------- ---- ----
    0/5 843.69GiB 61.91MiB
    0/4881 811.06GiB 9.34GiB
    0/7990 867.32GiB 329.91MiB
    0/8400 867.17GiB 37.64MiB


    (The warning in the first line is present as long as the rescan is still running.)



    Btrfs automatically creates a qgroup for each subvolume. In this case there are three subvolumes with subvolume IDs 4881, 7990, and 8400. The part before the forward slash is the level of the qgroup. Each subvolume qgroup is on level 0. Additionally there is a special qgroup on level 0 that always has ID 5 and corresponds to the root of the btrfs filesystem.



    For each qgroup the above output shows how much space is referenced by it. That means that the corresponding subvolume contains files whose total size equals the shown number.



    However, due to snapshots and the copy-on-write nature of btrfs subvolumes may share files. This means that the content (or actually the extents) of files may be referenced by more than one subvolume. This is expressed by the second number which shows how much space is exclusively allocated by each subvolume and is not shared with any other subvolume. In case you delete a subvolume this is the space that will actually be freed.



    If you want to find out how much space would be freed if you delete multiple subvolumes, you can use the aforementioned levels. qgroups are organized in a hierachy and groups on upper levels (higher than 0) aggregate the information of lower levels.



    Thus, to find out how much space would be freed if subvolumes 4881 and 7990 (in the above example) would be deleted create a new qgroup (arbitrarily with ID 0, but you may choose whatever you like here) on level 1 with



    # btrfs qgroup create 1/0 /path/to/btrfs/filesystem


    Then assign the newly created qgroup as a parent to the qgroups of the subvolumes you want to delete with



    # btrfs qgroup assign 0/4881 1/0 /path/to/btrfs/filesystem
    # btrfs qgroup assign 0/7990 1/0 /path/to/btrfs/filesystem


    This will trigger another re-scan of the quota information which may take a while. If it is finished and you now issue



    # btrfs qgroup show -p /path/to/btrfs/filesystem


    you get an output like this:



    qgroupid rfer excl parent
    -------- ---- ---- ------
    0/5 1.38TiB 2.51GiB ---
    0/4881 1.11TiB 10.86GiB 1/0
    0/7990 1.23TiB 502.41MiB 1/0
    0/8400 1.34TiB 1.69GiB 1/0
    1/0 1.51TiB 132.23GiB ---



    (I added the -p flag to add the parent column to the output which shows the parent/child relationship of the qgroups.)



    Now the line with qgroup 1/0 tells you how much space is referenced by both subvolumes you want to delete and, more importantly, it tells you how much space is allocated by them exclusively. This is the amount of space that will be freed if you delete both subvolumes.




    I also wonder why they are saying that it would be so slow?




    This is due to the copy-on-write nature of btrfs together with snapshots. If you create a snapshot in btrfs (normally) all actual data in the newly created subvolume that contains the snapshot is shared with the source of the snapshot. Only when a file is changed or replaced in the source does it point to different content (extents). This makes it very difficult to assess how much space would actually be freed if a subvolume is deleted because you have to account for all the space that is shared with other subvolumes.






    share|improve this answer




























      1














      You should take a look at btrfs quota and btrfs qgroups (quota groups).



      Basically qgroups do exactly what you requested, they track how much space is allocated by subvolumes. To enable qgroup functionality for a btrfs filesystem you have to



      # btrfs quota enable /path/to/btrfs/filesystem


      However, before you do this be warned that this triggers a complete re-computation of the qgroup data which will take some time especially for large filesystems with many subvolumes. This process runs asynchronously in the background. You can already check the status of the qgroups with



      # btrfs qgroup show /path/to/btrfs/filesystem


      This will give you some output like this:



      WARNING: rescan is running, qgroup data may be incorrect
      qgroupid rfer excl
      -------- ---- ----
      0/5 843.69GiB 61.91MiB
      0/4881 811.06GiB 9.34GiB
      0/7990 867.32GiB 329.91MiB
      0/8400 867.17GiB 37.64MiB


      (The warning in the first line is present as long as the rescan is still running.)



      Btrfs automatically creates a qgroup for each subvolume. In this case there are three subvolumes with subvolume IDs 4881, 7990, and 8400. The part before the forward slash is the level of the qgroup. Each subvolume qgroup is on level 0. Additionally there is a special qgroup on level 0 that always has ID 5 and corresponds to the root of the btrfs filesystem.



      For each qgroup the above output shows how much space is referenced by it. That means that the corresponding subvolume contains files whose total size equals the shown number.



      However, due to snapshots and the copy-on-write nature of btrfs subvolumes may share files. This means that the content (or actually the extents) of files may be referenced by more than one subvolume. This is expressed by the second number which shows how much space is exclusively allocated by each subvolume and is not shared with any other subvolume. In case you delete a subvolume this is the space that will actually be freed.



      If you want to find out how much space would be freed if you delete multiple subvolumes, you can use the aforementioned levels. qgroups are organized in a hierachy and groups on upper levels (higher than 0) aggregate the information of lower levels.



      Thus, to find out how much space would be freed if subvolumes 4881 and 7990 (in the above example) would be deleted create a new qgroup (arbitrarily with ID 0, but you may choose whatever you like here) on level 1 with



      # btrfs qgroup create 1/0 /path/to/btrfs/filesystem


      Then assign the newly created qgroup as a parent to the qgroups of the subvolumes you want to delete with



      # btrfs qgroup assign 0/4881 1/0 /path/to/btrfs/filesystem
      # btrfs qgroup assign 0/7990 1/0 /path/to/btrfs/filesystem


      This will trigger another re-scan of the quota information which may take a while. If it is finished and you now issue



      # btrfs qgroup show -p /path/to/btrfs/filesystem


      you get an output like this:



      qgroupid rfer excl parent
      -------- ---- ---- ------
      0/5 1.38TiB 2.51GiB ---
      0/4881 1.11TiB 10.86GiB 1/0
      0/7990 1.23TiB 502.41MiB 1/0
      0/8400 1.34TiB 1.69GiB 1/0
      1/0 1.51TiB 132.23GiB ---



      (I added the -p flag to add the parent column to the output which shows the parent/child relationship of the qgroups.)



      Now the line with qgroup 1/0 tells you how much space is referenced by both subvolumes you want to delete and, more importantly, it tells you how much space is allocated by them exclusively. This is the amount of space that will be freed if you delete both subvolumes.




      I also wonder why they are saying that it would be so slow?




      This is due to the copy-on-write nature of btrfs together with snapshots. If you create a snapshot in btrfs (normally) all actual data in the newly created subvolume that contains the snapshot is shared with the source of the snapshot. Only when a file is changed or replaced in the source does it point to different content (extents). This makes it very difficult to assess how much space would actually be freed if a subvolume is deleted because you have to account for all the space that is shared with other subvolumes.






      share|improve this answer


























        1












        1








        1







        You should take a look at btrfs quota and btrfs qgroups (quota groups).



        Basically qgroups do exactly what you requested, they track how much space is allocated by subvolumes. To enable qgroup functionality for a btrfs filesystem you have to



        # btrfs quota enable /path/to/btrfs/filesystem


        However, before you do this be warned that this triggers a complete re-computation of the qgroup data which will take some time especially for large filesystems with many subvolumes. This process runs asynchronously in the background. You can already check the status of the qgroups with



        # btrfs qgroup show /path/to/btrfs/filesystem


        This will give you some output like this:



        WARNING: rescan is running, qgroup data may be incorrect
        qgroupid rfer excl
        -------- ---- ----
        0/5 843.69GiB 61.91MiB
        0/4881 811.06GiB 9.34GiB
        0/7990 867.32GiB 329.91MiB
        0/8400 867.17GiB 37.64MiB


        (The warning in the first line is present as long as the rescan is still running.)



        Btrfs automatically creates a qgroup for each subvolume. In this case there are three subvolumes with subvolume IDs 4881, 7990, and 8400. The part before the forward slash is the level of the qgroup. Each subvolume qgroup is on level 0. Additionally there is a special qgroup on level 0 that always has ID 5 and corresponds to the root of the btrfs filesystem.



        For each qgroup the above output shows how much space is referenced by it. That means that the corresponding subvolume contains files whose total size equals the shown number.



        However, due to snapshots and the copy-on-write nature of btrfs subvolumes may share files. This means that the content (or actually the extents) of files may be referenced by more than one subvolume. This is expressed by the second number which shows how much space is exclusively allocated by each subvolume and is not shared with any other subvolume. In case you delete a subvolume this is the space that will actually be freed.



        If you want to find out how much space would be freed if you delete multiple subvolumes, you can use the aforementioned levels. qgroups are organized in a hierachy and groups on upper levels (higher than 0) aggregate the information of lower levels.



        Thus, to find out how much space would be freed if subvolumes 4881 and 7990 (in the above example) would be deleted create a new qgroup (arbitrarily with ID 0, but you may choose whatever you like here) on level 1 with



        # btrfs qgroup create 1/0 /path/to/btrfs/filesystem


        Then assign the newly created qgroup as a parent to the qgroups of the subvolumes you want to delete with



        # btrfs qgroup assign 0/4881 1/0 /path/to/btrfs/filesystem
        # btrfs qgroup assign 0/7990 1/0 /path/to/btrfs/filesystem


        This will trigger another re-scan of the quota information which may take a while. If it is finished and you now issue



        # btrfs qgroup show -p /path/to/btrfs/filesystem


        you get an output like this:



        qgroupid rfer excl parent
        -------- ---- ---- ------
        0/5 1.38TiB 2.51GiB ---
        0/4881 1.11TiB 10.86GiB 1/0
        0/7990 1.23TiB 502.41MiB 1/0
        0/8400 1.34TiB 1.69GiB 1/0
        1/0 1.51TiB 132.23GiB ---



        (I added the -p flag to add the parent column to the output which shows the parent/child relationship of the qgroups.)



        Now the line with qgroup 1/0 tells you how much space is referenced by both subvolumes you want to delete and, more importantly, it tells you how much space is allocated by them exclusively. This is the amount of space that will be freed if you delete both subvolumes.




        I also wonder why they are saying that it would be so slow?




        This is due to the copy-on-write nature of btrfs together with snapshots. If you create a snapshot in btrfs (normally) all actual data in the newly created subvolume that contains the snapshot is shared with the source of the snapshot. Only when a file is changed or replaced in the source does it point to different content (extents). This makes it very difficult to assess how much space would actually be freed if a subvolume is deleted because you have to account for all the space that is shared with other subvolumes.






        share|improve this answer













        You should take a look at btrfs quota and btrfs qgroups (quota groups).



        Basically qgroups do exactly what you requested, they track how much space is allocated by subvolumes. To enable qgroup functionality for a btrfs filesystem you have to



        # btrfs quota enable /path/to/btrfs/filesystem


        However, before you do this be warned that this triggers a complete re-computation of the qgroup data which will take some time especially for large filesystems with many subvolumes. This process runs asynchronously in the background. You can already check the status of the qgroups with



        # btrfs qgroup show /path/to/btrfs/filesystem


        This will give you some output like this:



        WARNING: rescan is running, qgroup data may be incorrect
        qgroupid rfer excl
        -------- ---- ----
        0/5 843.69GiB 61.91MiB
        0/4881 811.06GiB 9.34GiB
        0/7990 867.32GiB 329.91MiB
        0/8400 867.17GiB 37.64MiB


        (The warning in the first line is present as long as the rescan is still running.)



        Btrfs automatically creates a qgroup for each subvolume. In this case there are three subvolumes with subvolume IDs 4881, 7990, and 8400. The part before the forward slash is the level of the qgroup. Each subvolume qgroup is on level 0. Additionally there is a special qgroup on level 0 that always has ID 5 and corresponds to the root of the btrfs filesystem.



        For each qgroup the above output shows how much space is referenced by it. That means that the corresponding subvolume contains files whose total size equals the shown number.



        However, due to snapshots and the copy-on-write nature of btrfs subvolumes may share files. This means that the content (or actually the extents) of files may be referenced by more than one subvolume. This is expressed by the second number which shows how much space is exclusively allocated by each subvolume and is not shared with any other subvolume. In case you delete a subvolume this is the space that will actually be freed.



        If you want to find out how much space would be freed if you delete multiple subvolumes, you can use the aforementioned levels. qgroups are organized in a hierachy and groups on upper levels (higher than 0) aggregate the information of lower levels.



        Thus, to find out how much space would be freed if subvolumes 4881 and 7990 (in the above example) would be deleted create a new qgroup (arbitrarily with ID 0, but you may choose whatever you like here) on level 1 with



        # btrfs qgroup create 1/0 /path/to/btrfs/filesystem


        Then assign the newly created qgroup as a parent to the qgroups of the subvolumes you want to delete with



        # btrfs qgroup assign 0/4881 1/0 /path/to/btrfs/filesystem
        # btrfs qgroup assign 0/7990 1/0 /path/to/btrfs/filesystem


        This will trigger another re-scan of the quota information which may take a while. If it is finished and you now issue



        # btrfs qgroup show -p /path/to/btrfs/filesystem


        you get an output like this:



        qgroupid rfer excl parent
        -------- ---- ---- ------
        0/5 1.38TiB 2.51GiB ---
        0/4881 1.11TiB 10.86GiB 1/0
        0/7990 1.23TiB 502.41MiB 1/0
        0/8400 1.34TiB 1.69GiB 1/0
        1/0 1.51TiB 132.23GiB ---



        (I added the -p flag to add the parent column to the output which shows the parent/child relationship of the qgroups.)



        Now the line with qgroup 1/0 tells you how much space is referenced by both subvolumes you want to delete and, more importantly, it tells you how much space is allocated by them exclusively. This is the amount of space that will be freed if you delete both subvolumes.




        I also wonder why they are saying that it would be so slow?




        This is due to the copy-on-write nature of btrfs together with snapshots. If you create a snapshot in btrfs (normally) all actual data in the newly created subvolume that contains the snapshot is shared with the source of the snapshot. Only when a file is changed or replaced in the source does it point to different content (extents). This makes it very difficult to assess how much space would actually be freed if a subvolume is deleted because you have to account for all the space that is shared with other subvolumes.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 5 hours ago









        Erki der LoonyErki der Loony

        1212




        1212






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f151541%2fhow-much-space-would-be-freed-by-removing-a-btrfs-subvolume%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...