From: Axel Burri <axel@tty0.ch>
To: Andrei Borzenkov <arvidjaar@gmail.com>, linux-btrfs@vger.kernel.org
Subject: Re: find subvolume directories
Date: Mon, 22 Jul 2019 14:36:38 +0200 [thread overview]
Message-ID: <c54485af-356a-0760-710a-23df03c803b8@tty0.ch> (raw)
In-Reply-To: <abb990f6-91b2-0762-e7d2-478d2cf90f42@gmail.com>
On 18/07/2019 19.48, Andrei Borzenkov wrote:
> 18.07.2019 15:00, Axel Burri пишет:
>> On 13/07/2019 01.17, Ulli Horlacher wrote:
>>> I need to find (all) subvolume directories.
>>> I know, btrfs subvolumes root directories have inode #256, but a
>>> "find / -inum 256" is horrible slow!
>>
>> Having all required frameworks for this in btrbk, implementing a "list
>> all subvolumes below <path>" command was quite easy to implement:
>>
>> https://github.com/digint/btrbk/commit/e12d980502
>>
>> - get mounted filesystems from /proc/self/mountinfo
>> - fetch subvolumes using "btrfs subvolume list" (fast, needs root)
>> - filter and print subvolumes below mount point
>>
>> Note that this approach needs root, as "btrfs subvolume list" requires
>> "cap_sys_admin" and "cap_dac_read_search".
>>
>>
>> Try it:
>>
>> Download btrbk from "action-ls" feature branch (no dependencies needed):
>>
>> # cd /tmp
>> # wget https://raw.githubusercontent.com/digint/btrbk/action-ls/btrbk
>> # chmod +x /tmp/btrbk
>>
>>
>> List subvolumes below /home:
>>
>> # ./btrbk ls /home
>> # ./btrbk ls /home -t
>>
>>
>> Comprehensive list of all accessible subvolumes:
>>
>> # ./btrbk ls / --format=long
>>
>
> Seems to work, also across non-btrfs mount point. One thing missing is
> actual subvolume path (not current mount point).
Displaying the subvolume path might be useful as well, but I think this
should better be hidden from the user, except he is investigating btrfs
internas.
Note that the subvolume path (from "btrfs subvolume list") is ambiguous:
You can not tell what parts are "path-to-subvolume", and which are
"subvolume-name" (especially for nested subvolumes within directories).
Nevertheless, I updated "btrbk/action-ls" to print subvolume_path as
well as subvolume_rel_path (relative to top_level subvolume) for
format=rel [1]:
# ./btrbk ls / --format=rel
[1] https://github.com/digint/btrbk/commit/c0f2896ae1
>
>>
>> Show commands run by btrbk:
>>
>> # ./btrbk ls / -l debug
>>
>>
>> If you need to run this as a regular user (and if you are brave), you
>> can install setcap enabled btrfs binaries from:
>> https://github.com/digint/btrfs-progs-btrbk
>>
>> Hope this helps,
>>
>> - Axel
>>
>
next prev parent reply other threads:[~2019-07-22 12:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 23:17 find subvolume directories Ulli Horlacher
2019-07-13 3:59 ` Andrei Borzenkov
2019-07-13 8:27 ` Ulli Horlacher
2019-07-13 11:10 ` Andrei Borzenkov
2019-07-13 11:28 ` Ulli Horlacher
2019-07-13 15:08 ` Andrei Borzenkov
2019-07-15 13:22 ` Piotr Szymaniak
2019-07-15 22:40 ` Ulli Horlacher
2019-07-15 23:58 ` [RFC] a standard user-friendly way to find a snapshot in nested subvolumes [was: find subvolume directories] Nicholas D Steeves
2019-07-16 0:41 ` Ulli Horlacher
2019-07-15 11:39 ` find subvolume directories Ulli Horlacher
2019-07-15 11:33 ` Ulli Horlacher
2019-07-16 11:04 ` Ulli Horlacher
2019-07-18 12:00 ` Axel Burri
2019-07-18 17:48 ` Andrei Borzenkov
2019-07-22 12:36 ` Axel Burri [this message]
2019-07-20 9:27 ` Ulli Horlacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c54485af-356a-0760-710a-23df03c803b8@tty0.ch \
--to=axel@tty0.ch \
--cc=arvidjaar@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox