I don't understand BTRFS subvolumes

I am trying to move an old installation to a new drive.

I don’t understand BTRFS subvolumes.

The fstab file shows mounting wtih “subvol=/@/blah-blah-blah”

Am I supposed to create those “subvolumes”? Are they supposed to be put in a directory named “@” ?

I see the old subvolumes listed if I view the old drive with Partitioner. They are named “@/blah-blah-blah”. Is this how they are to be created - under a “@” directory ???

No. You are not even forced to use btrfs at all. But then some features in openSUSE may not work or may work differently.

Obviously BTRFS is the Tumbleweed default …

How is the “@” to be created ???

Using “btrfs subvolume create /mnt/disk1/@” to create a subvolume also creates a directory visible using “ls”.

This @ directory does not exists on the original drive.

Why is is this? Is there a special command to create subvolumes without them being visible as directories?

It does exist. But openSUSE mounts as root filesystem subvolume below btrfs top level directory, so the content of top level directory is not visible. You need to mount subvolid=5 (or subvol=/) to see the full content of btrfs filesystem.

"openSUSE’s YaST installer creates a detailed btrfs root filesystem configuration that has been designed to be flexible and secure while still efficient when used with tools like Snapper.

One of the overriding requirements is to provide a clearly defined ‘root filesystem’ containing everything we care about for ‘full system rollback’ (facilitated by snapper), while using subvolumes to exclude everything we do not want in the ‘root filesystem’ so snapper does not accidentally destroy user data when rolling back the system and its’ applications. Details of our default subvolume layout can be found on the openSUSE wiki.

However this does lead to complications for some advanced users who wish to recreate this manually, such as when doing complex system recovery, custom automated provisioning or other tinkering. (NOTE: for Full System Recovery it is often better to use a tool like ReaR).

The below steps are the steps to manually create an openSUSE-style btrfs partition believed to be correct at time of writing (19 Jan 2018)."

This makes no sense.

ID 256 gen 722366 top level 5 path @
ID 258 gen 722618 top level 256 path @/var
ID 259 gen 722015 top level 256 path @/usr/local
ID 261 gen 722015 top level 256 path @/srv
ID 262 gen 722550 top level 256 path @/root
ID 263 gen 722015 top level 256 path @/opt
ID 264 gen 722618 top level 256 path @/home
ID 265 gen 722086 top level 256 path @/boot/grub2/x86_64-efi
ID 266 gen 722086 top level 256 path @/boot/grub2/i386-pc
ID 267 gen 722014 top level 256 path @/.snapshots
ID 268 gen 722618 top level 267 path @/.snapshots/1/snapshot
ID 274 gen 128 top level 267 path @/.snapshots/2/snapshot

/# btrfs subvolume create @/test
ERROR: cannot access ‘@’: No such file or directory

/# btrfs subvolume create /@/test
ERROR: cannot access ‘/@’: No such file or directory

So does “@” exist or not?? Because attempting to create subvolume “test” under it results in “No such file or directory”

Dear 8876523450,

Just posting some output without the command used to generate it makes no sense.

Just saying things like "… attempting to create subvolume “test” under it results in “No such file or directory” makes no sense.

You should post all and everything, copy/paste, including the line with the prompt and the command, all output, up to and including the next prompt line. Like:

henk@boven:~> uname -r
5.14.21-150400.24.46-default
henk@boven:~> 

Thanks, but this is the Internet and privacy matters. Posting your user@machine name is a bad idea.

The command is " btrfs subvolume list / "

Even without that, obviously I am demonstrating that “@” appears as a subvolume but subvolumes cannot be added to it. So where is this “@” subvolume that OpenSuse relies on?

:exploding_head: uhhmmmmm no! Basics about local networks…

You need to mount the topmost subvolume:

erlangen:~ # mount -o subvolid=5 /dev/nvme0n1p3 /mnt/
erlangen:~ # btrfs subvolume create /mnt/@@
Create subvolume '/mnt/@@'
erlangen:~ # btrfs subvolume show /mnt/@@
@@
        Name:                   @@
        UUID:                   046967ae-ecf0-b04f-bd63-bc97122b04a2
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2023-03-20 20:36:44 +0100
        Subvolume ID:           274
        Generation:             3086
        Gen at creation:        3086
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Send transid:           0
        Send time:              2023-03-20 20:36:44 +0100
        Receive transid:        0
        Receive time:           -
        Snapshot(s):
        Quota group:            0/274
          Limit referenced:     -
          Limit exclusive:      -
          Usage referenced:     16.00KiB
          Usage exclusive:      16.00KiB
erlangen:~ # 

But this doesn’t change anything.

Newly created subvolumes appear at / like any other directory.

Attempting to create a subvolume under “@” (supposedly the “root”) results in “No such file or directory”

I’m starting to think that BTRFS subvolumes are increadibly dangerous because a person can’t be confident of where their stuff actually is when making back-ups. (Or making backups of phantom subvolumes which don’t really exist …)

Are you sure?

Create subvolume '/mnt/@/test'
erlangen:~ # btrfs subvolume show /mnt/@/test
@/test
        Name:                   test
        UUID:                   0429ace2-c394-2a4a-b394-eb5e91d91456
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2023-03-20 21:07:21 +0100
        Subvolume ID:           275
        Generation:             3088
        Gen at creation:        3088
        Parent ID:              256
        Top level ID:           256
        Flags:                  -
        Send transid:           0
        Send time:              2023-03-20 21:07:21 +0100
        Receive transid:        0
        Receive time:           -
        Snapshot(s):
        Quota group:            0/275
          Limit referenced:     -
          Limit exclusive:      -
          Usage referenced:     16.00KiB
          Usage exclusive:      16.00KiB
erlangen:~ # 

Sure, you need to know what you are doing: System Backup with btrfs send / receive

1 Like

I don’t think so. But when you are afraid then don’t. But people here then might miss important things like who does do it and what is the working directory. But at least show the command you use.