Re: subvolume list as user?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat 2017-09-16 (22:56), Goffredo Baroncelli wrote:

>> how can a user get a list of his subvolumes? He may created them some
>> time ago and forget it. He now wants to have a list of them.
> 
> Far to be perfect, but this could help
> 
> find / -inum 256  2>/dev/null
> 
> each subvolume has inode number 256

But non-btrfs filesystems can also have an inode 256!
And it is terrible slow and inefficent.
Ok, I will add a sudo wrapper for my btrfs_subvolume_list :

#!/usr/bin/perl -w

$mounts = '/proc/mounts';
open $mounts,$mounts or die "$0: cannot open $mounts - $!\n";
while (<$mounts>) {
  if (m:^(/\S+) (/\S*) btrfs:) {
    push @bfs,$2;
  }
}
close $mounts;
if (@bfs) {
  @bfs = sort @bfs;
} else {
  die "$0: no mounted btrfs filesystems\n";
}

@sv = ();
foreach my $fs (@bfs) {
  push @sv,"$fs\n";
  open $fs,"btrfs subvolume list '$fs'|" or next;;
  while (<$fs>) {
    chomp;
    s:.* \d+ path :$fs/:;
    push @sv,"$_\n" if -d;
  }
  close $fs;
}

print sort @sv;


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@xxxxxxxxxxxxxxxxxxxx
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<54b8bb4b-3807-15da-1db5-fab7b0ced253@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux