Skip to contentSkip to conversation

where is the parent of a snapshot?

DISCUSSION Ulli Horlacher 5 participants 13 messages Jul 8, 2021 – Jul 9, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

This is btrfs v5.4.1 on Ubuntu 20.04:

I have created several snapshots of the btrfs root filesystem /mnt/spool:

root@unifex:~# df -HT /mnt/spool
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/loop0     btrfs   32T  258G   32T   1% /mnt/spool
root@unifex:~# btrfs filesys show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 238.70GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 101.00GiB path /dev/loop1
root@unifex:~# btrfs subvolume list -q /mnt/spool
ID 30401 gen 193524 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_0000.daily
ID 30424 gen 194441 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2100.hourly
ID 30425 gen 194472 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2200.hourly
ID 30426 gen 194497 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2300.hourly

I have expected to see the parent_uuid as the uuid of the root subvolume. Where is parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2?

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#1 lore raw
Quoted 16 lines · Ulli Horlacher

This is btrfs v5.4.1 on Ubuntu 20.04:

I have created several snapshots of the btrfs root filesystem /mnt/spool:

root@unifex:~# df -HT /mnt/spool
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/loop0     btrfs   32T  258G   32T   1% /mnt/spool
root@unifex:~# btrfs filesys show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 238.70GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 101.00GiB path /dev/loop1
Quoted 6 lines
root@unifex:~# btrfs subvolume list -q /mnt/spool
ID 30401 gen 193524 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_0000.daily
ID 30424 gen 194441 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2100.hourly
ID 30425 gen 194472 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2200.hourly
ID 30426 gen 194497 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2300.hourly

Is it really full list?

Quoted 5 lines

I have expected to see the parent_uuid as the uuid of the root subvolume. Where is parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2?

subvolume uuid is not shown by this command.

#2 lore raw
Quoted 18 lines · Andrei Borzenkov
Quoted 16 lines · Ulli Horlacher

This is btrfs v5.4.1 on Ubuntu 20.04:

I have created several snapshots of the btrfs root filesystem /mnt/spool:

root@unifex:~# df -HT /mnt/spool
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/loop0     btrfs   32T  258G   32T   1% /mnt/spool
root@unifex:~# btrfs filesys show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 238.70GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 101.00GiB path /dev/loop1
Quoted 8 lines
Quoted 6 lines
root@unifex:~# btrfs subvolume list -q /mnt/spool
ID 30401 gen 193524 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_0000.daily
ID 30424 gen 194441 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2100.hourly
ID 30425 gen 194472 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2200.hourly
ID 30426 gen 194497 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2300.hourly

Is it really full list?

Yes, that's all!

Quoted 1 line

subvolume uuid is not shown by this command.

root@unifex:/# btrfs subvolume list -qu /mnt/spool
ID 30428 gen 194535 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 7f044b92-d928-2f44-a880-e453feaa551d path .snapshot/2021-07-09_0000.daily
ID 30435 gen 194686 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid eeace077-5f22-c541-8fb4-f0523fd76c9e path .snapshot/2021-07-09_0700.hourly
ID 30436 gen 194715 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 70fc8ced-7c13-f947-bab6-5354eb71483f path .snapshot/2021-07-09_0800.hourly
ID 30437 gen 194756 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 254fcaba-9549-0244-8467-baaa3d68cb7b path .snapshot/2021-07-09_0900.hourly
root@unifex:/# btrfs version
btrfs-progs v5.4.1

My aim is to discover which directory is the parent of a snapshot. In this particular case I know it is /mnt/spool but I want to do it by a script, so I need a generic solution: "Directory XY is a snapshot of directory XZ"

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#3 lore raw

Try adding -a to the options. That should list all of the subvols on
the filesystem.

Hugo.

Quoted 49 lines · Ulli Horlacher
Quoted 18 lines · Andrei Borzenkov
Quoted 16 lines · Ulli Horlacher

This is btrfs v5.4.1 on Ubuntu 20.04:

I have created several snapshots of the btrfs root filesystem /mnt/spool:

root@unifex:~# df -HT /mnt/spool
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/loop0     btrfs   32T  258G   32T   1% /mnt/spool
root@unifex:~# btrfs filesys show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 238.70GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 101.00GiB path /dev/loop1
Quoted 8 lines
Quoted 6 lines
root@unifex:~# btrfs subvolume list -q /mnt/spool
ID 30401 gen 193524 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_0000.daily
ID 30424 gen 194441 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2100.hourly
ID 30425 gen 194472 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2200.hourly
ID 30426 gen 194497 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 path .snapshot/2021-07-08_2300.hourly

Is it really full list?

Yes, that's all!

Quoted 1 line

subvolume uuid is not shown by this command.

root@unifex:/# btrfs subvolume list -qu /mnt/spool
ID 30428 gen 194535 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 7f044b92-d928-2f44-a880-e453feaa551d path .snapshot/2021-07-09_0000.daily
ID 30435 gen 194686 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid eeace077-5f22-c541-8fb4-f0523fd76c9e path .snapshot/2021-07-09_0700.hourly
ID 30436 gen 194715 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 70fc8ced-7c13-f947-bab6-5354eb71483f path .snapshot/2021-07-09_0800.hourly
ID 30437 gen 194756 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 254fcaba-9549-0244-8467-baaa3d68cb7b path .snapshot/2021-07-09_0900.hourly
root@unifex:/# btrfs version
btrfs-progs v5.4.1

My aim is to discover which directory is the parent of a snapshot. In this particular case I know it is /mnt/spool but I want to do it by a script, so I need a generic solution: "Directory XY is a snapshot of directory XZ"

Signature · 4 lines
Hugo Mills             | Modern medicine does not treat causes: headaches are
hugo@... carfax.org.uk | not caused by a paracetamol deficiency.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
#4 lore raw
Quoted 2 lines · Hugo Mills

Try adding -a to the options. That should list all of the subvols on
the filesystem.

There is no difference:

root@unifex:/# btrfs subvolume list -qu /mnt/spool
ID 30428 gen 194535 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 7f044b92-d928-2f44-a880-e453feaa551d path .snapshot/2021-07-09_0000.daily
ID 30435 gen 194686 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid eeace077-5f22-c541-8fb4-f0523fd76c9e path .snapshot/2021-07-09_0700.hourly
ID 30436 gen 194715 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 70fc8ced-7c13-f947-bab6-5354eb71483f path .snapshot/2021-07-09_0800.hourly
ID 30437 gen 194756 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 254fcaba-9549-0244-8467-baaa3d68cb7b path .snapshot/2021-07-09_0900.hourly
root@unifex:/# btrfs subvolume list -aqu /mnt/spool
ID 30428 gen 194535 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 7f044b92-d928-2f44-a880-e453feaa551d path .snapshot/2021-07-09_0000.daily
ID 30435 gen 194686 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid eeace077-5f22-c541-8fb4-f0523fd76c9e path .snapshot/2021-07-09_0700.hourly
ID 30436 gen 194715 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 70fc8ced-7c13-f947-bab6-5354eb71483f path .snapshot/2021-07-09_0800.hourly
ID 30437 gen 194756 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 254fcaba-9549-0244-8467-baaa3d68cb7b path .snapshot/2021-07-09_0900.hourly
Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#5 lore raw

And an example of a new snapshot:

root@unifex:/# btrfs subvolume snapshot -r /mnt/spool /mnt/spool/.snapshot/2021-07-09_0944.test
Create a readonly snapshot of '/mnt/spool' in '/mnt/spool/.snapshot/2021-07-09_0944.test'
root@unifex:/# btrfs filesystem show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 209.80GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 100.00GiB path /dev/loop1
root@unifex:/# btrfs subvolume list -aqu /mnt/spool
ID 30428 gen 194535 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 7f044b92-d928-2f44-a880-e453feaa551d path .snapshot/2021-07-09_0000.daily
ID 30435 gen 194686 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid eeace077-5f22-c541-8fb4-f0523fd76c9e path .snapshot/2021-07-09_0700.hourly
ID 30436 gen 194715 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 70fc8ced-7c13-f947-bab6-5354eb71483f path .snapshot/2021-07-09_0800.hourly
ID 30437 gen 194756 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 254fcaba-9549-0244-8467-baaa3d68cb7b path .snapshot/2021-07-09_0900.hourly
ID 30438 gen 194793 top level 5 parent_uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2 uuid 5c6ade10-39ee-de47-a1f8-321953e397fd path .snapshot/2021-07-09_0944.test

So, where is subvolume uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2??

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#6 lore raw
Quoted 3 lines · Ulli Horlacher

So, where is subvolume uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2??

btrfs subvolume show /mnt/spool will display what you want. It seems
as though the subvolume list does not include the root subvolume.

#7 lore raw
Quoted 8 lines · Remi Gauvin
Quoted 3 lines · Ulli Horlacher

So, where is subvolume uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2??

btrfs subvolume show /mnt/spool will display what you want. It seems
as though the subvolume list does not include the root subvolume.

root@unifex:/# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   7f010d85-b761-45e7-8d4a-453f81bb10b2
        Parent UUID:            -
        Received UUID:          -
(...)

Ahhhh!
I was using the wrong command!

root@unifex:/# btrfs filesystem show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 209.81GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 100.00GiB path /dev/loop1

The filesystem has different uuid than the root subvolume?!

This was on Ubuntu 20.04 with btrfs 5.4.1

On Ubuntu 18.04 with btrfs 4.15.1 it looks different:

root@fex:~# btrfs filesystem show /mnt/spool
Label: none  uuid: dfece157-dd48-4868-b4a3-51e539325aaa
        Total devices 1 FS bytes used 1.85TiB
        devid    1 size 14.55TiB used 1.90TiB path /dev/loop0
root@fex:~# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   -
        Parent UUID:            -
        Received UUID:          -
        Creation time:          -
        Subvolume ID:           5
        Generation:             85076
        Gen at creation:        0
        Parent ID:              0
        Top level ID:           0
        Flags:                  -
        Snapshot(s):
                                .snapshot/2021-07-07_0000.daily
                                .snapshot/2021-07-08_0000.daily
                                .snapshot/2021-07-09_0000.daily
                                .snapshot/2021-07-09_0800.hourly
                                .snapshot/2021-07-09_0900.hourly
                                .snapshot/2021-07-09_1000.hourly
Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#8 lore raw
Quoted 11 lines · Ulli Horlacher

On Ubuntu 18.04 with btrfs 4.15.1 it looks different:

root@fex:~# btrfs filesystem show /mnt/spool
Label: none  uuid: dfece157-dd48-4868-b4a3-51e539325aaa
        Total devices 1 FS bytes used 1.85TiB
        devid    1 size 14.55TiB used 1.90TiB path /dev/loop0
root@fex:~# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   -

Interesting.. but regardless, what you probably want to do is create a new top level subvolume, (for example, @spool), and mount *that* (with the subvol=@spool option.)

If for no other reasons, it will make actually rolling back those snapshots much easier and cleaner, should the need arise.

#9 lore raw
In reply to Ulli Horlacher
Quoted 21 lines · Ulli Horlacher
Quoted 8 lines · Remi Gauvin
Quoted 3 lines · Ulli Horlacher

So, where is subvolume uuid 7f010d85-b761-45e7-8d4a-453f81bb10b2??

btrfs subvolume show /mnt/spool will display what you want. It seems
as though the subvolume list does not include the root subvolume.

root@unifex:/# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   7f010d85-b761-45e7-8d4a-453f81bb10b2
        Parent UUID:            -
        Received UUID:          -
(...)

Ahhhh!
I was using the wrong command!

Quoted 7 lines
root@unifex:/# btrfs filesystem show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 209.81GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 100.00GiB path /dev/loop1

The filesystem has different uuid than the root subvolume?!

Yes, it's been like that forever.

#10 lore raw
Quoted 14 lines · Nikolay Borisov
Quoted 14 lines
root@unifex:/# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   7f010d85-b761-45e7-8d4a-453f81bb10b2
        Parent UUID:            -
        Received UUID:          -
(...)
root@unifex:/# btrfs filesystem show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 209.81GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 100.00GiB path /dev/loop1
Quoted 3 lines
Quoted 1 line

The filesystem has different uuid than the root subvolume?!

Yes, it's been like that forever.

No:

root@fex:~# btrfs version
btrfs-progs v4.15.1
root@fex:~# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   -
        Parent UUID:            -
        Received UUID:          -
        Creation time:          -
        Subvolume ID:           5
        Generation:             85112
        Gen at creation:        0
        Parent ID:              0
        Top level ID:           0
        Flags:                  -
root@fex:~# btrfs filesystem show /mnt/spool
Label: none  uuid: dfece157-dd48-4868-b4a3-51e539325aaa
        Total devices 1 FS bytes used 1.85TiB
        devid    1 size 14.55TiB used 1.90TiB path /dev/loop0

There is no UUID on the root subvolume!

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#11 lore raw
Quoted 16 lines · Ulli Horlacher
Quoted 14 lines · Nikolay Borisov
Quoted 14 lines
root@unifex:/# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   7f010d85-b761-45e7-8d4a-453f81bb10b2
        Parent UUID:            -
        Received UUID:          -
(...)
root@unifex:/# btrfs filesystem show /mnt/spool
Label: none  uuid: 217ccc65-6ab9-44f0-b691-ec9bbcdd9496
        Total devices 2 FS bytes used 209.81GiB
        devid    1 size 14.55TiB used 161.02GiB path /dev/loop0
        devid    2 size 14.55TiB used 100.00GiB path /dev/loop1
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

The filesystem has different uuid than the root subvolume?!

Yes, it's been like that forever.

No:

root@fex:~# btrfs version
btrfs-progs v4.15.1

Which kernel version is that with?

Quoted 22 lines
root@fex:~# btrfs subvolume show /mnt/spool
/
        Name:                   <FS_TREE>
        UUID:                   -
        Parent UUID:            -
        Received UUID:          -
        Creation time:          -
        Subvolume ID:           5
        Generation:             85112
        Gen at creation:        0
        Parent ID:              0
        Top level ID:           0
        Flags:                  -
root@fex:~# btrfs filesystem show /mnt/spool
Label: none  uuid: dfece157-dd48-4868-b4a3-51e539325aaa
        Total devices 1 FS bytes used 1.85TiB
        devid    1 size 14.55TiB used 1.90TiB path /dev/loop0

There is no UUID on the root subvolume!

#12 lore raw
Quoted 4 lines · Nikolay Borisov
Quoted 2 lines
root@fex:~# btrfs version
btrfs-progs v4.15.1

Which kernel version is that with?

root@fex:~# sysinfo 
System:        Linux fex 5.4.0-77-generic x86_64
Distribution:  Ubuntu 18.04.5 LTS
Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>