9

Is there a way to make a btrfs subvolume tree like what is shown below? (Only subvolumes - no regular directories or files.)

# tree /mnt/1
/mnt/1
├── a
├── snapshot
│   ├── a
│   └── subv
└── subv
    └── b

This example is created from a "sample" btrfs with no regular directories or files.
tree <mountpoint> shows all directories and files, not just the subvolumes. Using the -d option shows only directories, which is better, but still shows non-subvolume directories.

So, on an installed system, you get:

# tree /
/
├── bin -> usr/bin
├── boot
│   ├── grub
│   │   ├── fonts
│   │   │   └── unicode.pf2
│   │   ├── grub.cfg
│   │   ├── grub.cfg.example
│   │   ├── grubenv
│   │   ├── i386-pc
│   │   │   ├── 915resolution.mod
│   │   │   ├── acpi.mod
│   │   │   ├── adler32.mod
│   │   │   ├── affs.mod
... <over 242,000 lines snipped>
  • How about tree -x? It's not exactly what you asked for, but it may suit your purpose. – Celada Jun 25 '15 at 5:15
  • 2
    btrfs subvolume list / currently gives me 10 lines. tree -x / gives me over 108,000 lines. – user1902689 Jun 25 '15 at 5:27
  • Yeah, so then that's no good :-( I guess the trouble with your requirement is the question of what such a command should show if subvolumes /a and /a/b/c exist but the intermediate /a/b is not a subvolume but a regular directory. Omit the second level in the tree? But then where would /a/z appear if /a/z were a subvolume? Or show a blank placeholder in place of /a/b which isn't a subvolume? Also seems problematic. Anyway, maybe I'm just not imaginative enough to see the solution. Good luck. – Celada Jun 25 '15 at 5:34
  • @Celada - When I run btrfs subvolume list /, I see ID ### gen ### top level ### path <path>. Is the top level number corresponding to the ID numbers? If so, I'd be happy for a tree generated on that basis, where top level 5 (at least on my system, indicating the "top-level" subvolumes) are shown, with recursive branches showing any subvolumes with that node's top level. I'm guessing it would probably have to be a btrfs-progs feature. – user1902689 Jun 25 '15 at 6:16
  • I'm working on putting together a script for this. So far I've populated objects of each subvolume in a btrfs file system with their children. Anyone who's interested in helping please feel free to submit a pull request. – etskinner May 10 '17 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.