linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* find subvolume directories
@ 2019-07-12 23:17 Ulli Horlacher
  2019-07-13  3:59 ` Andrei Borzenkov
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Ulli Horlacher @ 2019-07-12 23:17 UTC (permalink / raw)
  To: linux-btrfs

I need to find (all) subvolume directories.
I know, btrfs subvolumes root directories have inode #256, but a
"find / -inum 256" is horrible slow!

Next idea: "btrfs subvolume list /" is really fast, but its output is not
always direct usable to find the subvolume directory.

Example output on a SUSE system:

root@trulla:~# btrfs subvolume list /
ID 257 gen 2280099 top level 5 path @
ID 258 gen 2280769 top level 257 path @/home
ID 259 gen 2280947 top level 257 path @/opt
ID 260 gen 2280098 top level 257 path @/srv
ID 261 gen 2280954 top level 257 path @/tmp
ID 262 gen 2280187 top level 257 path @/usr/local
ID 263 gen 2280099 top level 257 path @/var/crash
ID 264 gen 2280949 top level 257 path @/var/log
ID 265 gen 2280099 top level 257 path @/var/opt
ID 266 gen 2280954 top level 257 path @/var/spool
ID 267 gen 2280947 top level 257 path @/var/tmp
ID 270 gen 2280222 top level 257 path @/.snapshots
ID 453 gen 2280954 top level 270 path @/.snapshots/128/snapshot
ID 1235 gen 2280099 top level 257 path @/var/lib/machines
ID 12392 gen 2123118 top level 270 path @/.snapshots/1065/snapshot
ID 12393 gen 2123120 top level 270 path @/.snapshots/1066/snapshot
ID 13273 gen 2176640 top level 270 path @/.snapshots/1089/snapshot
ID 13274 gen 2176651 top level 270 path @/.snapshots/1090/snapshot
ID 13553 gen 2203681 top level 270 path @/.snapshots/1103/snapshot

There is no /@/ directory in the default filesystem because of:

root@trulla:/# stat /@/.snapshots/128/snapshot
stat: cannot stat '/@/.snapshots/128/snapshot': No such file or directory

root@trulla:~# btrfs subvolume get-default /
ID 453 gen 2280954 top level 270 path @/.snapshots/128/snapshot

root@trulla:/# mount | grep " / "
/dev/sda2 on / type btrfs (rw,relatime,space_cache,subvolid=453,subvol=/@/.snapshots/128/snapshot)

On this particular system I could remove "@" from the subvolume path to
get the subvolume directory:

root@trulla:/# stat /.snapshots/128/snapshot
  File: '/.snapshots/128/snapshot'
  Size: 198             Blocks: 0          IO Block: 4096   directory
Device: 27h/39d Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-07-13 01:03:08.543830085 +0200
Modify: 2019-07-13 01:03:37.336445461 +0200
Change: 2019-07-13 01:03:37.336445461 +0200
 Birth: -

But what if a btrfs filesystem does not have a toplevel /@/ directory, but
anything else, like /this/is/my/top/directory ?

Will be the first output line of "btrfs subvolume list /"
always look like

ID 257 gen 2280099 top level 5 path this/is/my/top/directory 

?



-- 
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:<20190712231705.GA16856@tik.uni-stuttgart.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-07-22 12:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).