public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
To: linux-btrfs@vger.kernel.org
Subject: Re: find subvolume directories
Date: Sat, 20 Jul 2019 11:27:40 +0200	[thread overview]
Message-ID: <20190720092740.GA8099@tik.uni-stuttgart.de> (raw)
In-Reply-To: <04d6d375-ee33-8d77-d139-a81302efd7f8@tty0.ch>

On Thu 2019-07-18 (14:00), Axel Burri 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!
> 
> 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

Meanwhile I have come to the same solution :-)
Only I use /proc/mounts instead of /proc/self/mountinfo

framstag@fex:/tmp: btrfs_list
ACCESS-MODE SUBVOLUME
rw /local/home/framstag/blubb
ro /local/home/framstag/blubb/.snapshot/2017-09-15_1811.test
ro /local/home/framstag/blubb/.snapshot/2017-11-30_1007.test
ro /local/home/framstag/blubb/.snapshot/2017-12-02_1026.test
ro /local/home/framstag/blubb/.snapshot/2019-07-18_0139.test
rw /local/tmp/test

My first (wrong) approach was to use 
btrfs subvolume list TOPLEVEL_SUBVOLUME_MOUNTPOINT 
only, but not all btrfs mountpoints.


> Note that this approach needs root, as "btrfs subvolume list" requires
> "cap_sys_admin" and "cap_dac_read_search".

My btrfs_list uses sudo and lists only subvolumes belonging to the user.


> # cd /tmp
> # wget https://raw.githubusercontent.com/digint/btrbk/action-ls/btrbk
> # chmod +x /tmp/btrbk
> 
> 
> List subvolumes below /home:
> 
> # ./btrbk ls /home

root@fex:~# /tmp/btrbk ls /local/
ERROR: Configuration file not found: /etc/btrbk.conf, /etc/btrbk/btrbk.conf
ERROR: Failed to parse configuration file

root@fex:~# touch /etc/btrbk.conf

root@fex:~# /tmp/btrbk ls /local/
/local
/local/home
/local/home/.snapshot/2019-07-14_0000.weekly
/local/home/.snapshot/2019-07-18_0000.daily
/local/home/.snapshot/2019-07-19_0000.daily
/local/home/.snapshot/2019-07-20_0000.daily
/local/home/.snapshot/2019-07-20_0900.hourly
/local/home/.snapshot/2019-07-20_1000.hourly
/local/home/.snapshot/2019-07-20_1100.hourly
/local/home/framstag/blubb
/local/home/framstag/blubb/.snapshot/2017-09-15_1811.test
/local/home/framstag/blubb/.snapshot/2017-11-30_1007.test
/local/home/framstag/blubb/.snapshot/2017-12-02_1026.test
/local/home/framstag/blubb/.snapshot/2019-07-18_0139.test
/local/home/smc/test
/local/spool/fex
/local/tmp/test

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<04d6d375-ee33-8d77-d139-a81302efd7f8@tty0.ch>

      parent reply	other threads:[~2019-07-20  9:27 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
2019-07-20  9:27   ` Ulli Horlacher [this message]

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=20190720092740.GA8099@tik.uni-stuttgart.de \
    --to=framstag@rus.uni-stuttgart.de \
    --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