LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   SOLVED: BTRFS how to find the volume which is the parent of sub-volumes (https://www.linuxquestions.org/questions/linux-general-1/solved-btrfs-how-to-find-the-volume-which-is-the-parent-of-sub-volumes-4175675021/)

marozsas 05-11-2020 12:52 PM

SOLVED: BTRFS how to find the volume which is the parent of sub-volumes
 
Hi there !

Code:

localhost:/home/miguel # btrfs subvolume list -t /var
ID      gen    top level      path
--      ---    ---------      ----
256    1993    5              @
257    1997    256            @/var
258    1964    256            @/usr/local
259    1997    256            @/tmp
260    1888    256            @/srv
261    1964    256            @/root
262    1905    256            @/opt
263    1888    256            @/boot/grub2/x86_64-efi
264    1888    256            @/boot/grub2/i386-pc
localhost:/home/miguel #

How do I know who is the parent dir (volume) of theses sub-volumes ?

I expect to see all theses sub-volumes as regular folders in the parent folder.

thank you in advance,

shruggy 05-12-2020 06:34 AM

Just guessing. Maybe
Code:

btrfs inspect-internal subvolid-resolve <ID> <MountPoint>

marozsas 05-12-2020 09:55 AM

Quote:

Originally Posted by shruggy (Post 6122103)
Just guessing. Maybe
Code:

btrfs inspect-internal subvolid-resolve <ID> <MountPoint>

no, not useful really....
Code:

root@fenix:/home/miguel# btrfs inspect-internal subvolid 272 /home/miguel/tmp
miguel/tmp
root@fenix:/home/miguel#


marozsas 05-13-2020 11:47 AM

SOLVED
 
Code:

root@fenix:/home/miguel# btrfs filesystem show | awk '/ +uuid:/ {print $4}' | xargs -L 1 -I{} blkid -t  UUID={}
/dev/sdc2: LABEL="home-btrf" UUID="af3bd7fe-5796-4248-9917-3e71a5a56ec6" UUID_SUB="f1d4dae9-d68d-4dbf-8b35-7a789ec3d7f2" TYPE="btrfs" PARTLABEL="home" PARTUUID="63b012c8-4c9f-49f5-85d9-da7e0f6b4a23"
root@fenix:/home/miguel#

Looks like btrfs does not have a tool to inform which is the parent folder or root folder of sub-volume.
You have to figure out based on the UUID returned by "btrfs filesystem show" and using blkid, return the device that match that UUID.

I hope this could be useful to someone.

cheers,

JZL240I-U 05-14-2020 12:37 PM

Thanks for coming back and sharing your solution :).


All times are GMT -5. The time now is 05:15 AM.