Skip to contentSkip to conversation

Determining subvolumes

DISCUSSION Gene Czarcinski 3 participants 3 messages Dec 26, 2012 – Jan 3, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I know that I can find out what btrfs "volumes" are on a system with the command:
btrfs fi show

I can also check if a partition of disk is a btrfs volume with the command:
blkid -o value -s TYPE /dev/<disk|partition>

And, if I mount that btrfs volume with something like:
mount -t btrfs /dev/<btrfs> /mnt/btrfs

The, I can get a list of btrfs subvolumes on that volume with the command:
btrfs subvolume list /mnt/btrfs

My question: Is there a way of finding out what subvolumes are defined on a btrfs volume without mounting the volume?

Gene

#1 lore raw
Quoted 7 lines · Gene Czarcinski

I know that I can find out what btrfs "volumes" are on a system with the command:
btrfs fi show

I can also check if a partition of disk is a btrfs volume with the command:
blkid -o value -s TYPE /dev/<disk|partition>

Quoted 8 lines

And, if I mount that btrfs volume with something like:
mount -t btrfs /dev/<btrfs> /mnt/btrfs

The, I can get a list of btrfs subvolumes on that volume with the command:
btrfs subvolume list /mnt/btrfs

My question: Is there a way of finding out what subvolumes are defined on a btrfs volume without mounting the volume?

No. (Well, in theory the code is possible, but there's nothing I'm
aware of that will do it)

Hugo.

Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
              --- Python is executable pseudocode; perl ---              
                        is executable line-noise.                        
#2 lore raw
Quoted 11 lines · Hugo Mills
Quoted 10 lines · Gene Czarcinski

I know that I can find out what btrfs "volumes" are on a system with the command:
btrfs fi show

I can also check if a partition of disk is a btrfs volume with the command:
blkid -o value -s TYPE /dev/<disk|partition>

And, if I mount that btrfs volume with something like:
mount -t btrfs /dev/<btrfs> /mnt/btrfs

Quoted 8 lines
Quoted 5 lines

The, I can get a list of btrfs subvolumes on that volume with the command:
btrfs subvolume list /mnt/btrfs

My question: Is there a way of finding out what subvolumes are defined on a btrfs volume without mounting the volume?

No. (Well, in theory the code is possible, but there's nothing I'm
aware of that will do it)

It is possible to work with the filesystem offline, but lots of the useful code is written only in kernel module (and accessed via ioctl() calls from userspace).

Listing the subvolumes consists of:

* opening the filesystem (open_ctree_fs_info)
* search root tree for all ROOT_ITEM (via btrfs_search_slot) and also the found items recursively
* resolve the full path for each given root id (normally done via BTRFS_IOC_INO_LOOKUP) - btrfs_search_path_in_tree could be used almost verbatim (is not present in progs)

The existing functions to list subvolumes would need enhancing to work both online and offline (eg. the filtering and printing code coud be shared).

I don't know how far we should go to allow friendly access to an offline volume. For debugging purposes it's usually enough to grep through output of btrfs-debug-tree. Simple tasks like listing subvolumes or manipulating default subvolume do not sound like a bad use case.

david