Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

subvol's within root subvol snapshots are not snapshoted together with the root subvol #6

Closed
visit1985 opened this Issue · 7 comments

3 participants

@visit1985
Collaborator
  1. Setup

    # btrfs su li -p /
    ID 256 gen 86 parent 5 top level 5 path __active
    ID 258 gen 79 parent 256 top level 256 path home
    ID 259 gen 86 parent 256 top level 256 path var
    ID 260 gen 86 parent 256 top level 256 path usr
    
  2. Create a snapshot of the root subvolume

    # btrfs su sn __active __snapshot/test
    Create a snapshot of '__active' in '__snapshot/test'
    
  3. Reboot and rollback to snapshot just created

    ERROR: Root device mounted successfully, but /sbin/init does not exist.
    Bailing out, you are on your own. Good luck.
    

The issue is that /usr is empty on the subvolume mounted to /new_root, but why?

  1. Booted back to __active

    # mount -o subvolid=0 /dev/sda2 /mnt
    # ls -l /mnt/__rollback/usr
    total 0
    # ls -l /mnt/__snapshot/test/usr
    total 0
    

Snapshots do not snapshot subvolumes within __active incrementally.

  1. Snapshot again

    # btrfs su sn __active __snapshot/test2
    Create a snapshot of '__active' in '__snapshot/test2'
    # rm -r __snapshot/test2/{home,var,usr}
    # btrfs su sn __active/home __snapshot/test2/home
    Create a snapshot of '__active/home' in '__snapshot/test2/home'
    # btrfs su sn __active/var __snapshot/test2/var
    Create a snapshot of '__active/var' in '__snapshot/test2/var'
    # btrfs su sn __active/usr __snapshot/test2/usr
    Create a snapshot of '__active/usr' in '__snapshot/test2/usr'
    
    # btrfs su li -p /
    ID 256 gen 110 parent 5 top level 5 path __active
    ID 258 gen 111 parent 256 top level 256 path home
    ID 259 gen 112 parent 256 top level 256 path var
    ID 260 gen 113 parent 256 top level 256 path usr
    ID 267 gen 95 parent 5 top level 5 path __snapshot/test
    ID 269 gen 95 parent 5 top level 5 path __rollback
    ID 270 gen 113 parent 5 top level 5 path __snapshot/test2
    ID 271 gen 111 parent 270 top level 5 path __snapshot/test2/home
    ID 272 gen 112 parent 270 top level 5 path __snapshot/test2/var
    ID 273 gen 113 parent 270 top level 5 path __snapshot/test2/usr
    
  2. Again reboot and rollback to snapshot test2

    ERROR: Root device mounted successfully, but /sbin/init does not exist.
    Bailing out, you are on your own. Good luck.
    

TL;DR We need to snapshot to __rollback recursively!

@visit1985
Collaborator

We could introduce an option to boot directly from the snapshot, or make this a question in the rollback dialog itself.

What do you think @xtfxme?

@visit1985
Collaborator

Regardless if mkinitcpio-btrfs handles it correct, the purpose of creating subvolumes for curtain FHS directories remains valid - one can handle quotas with it. But for me it makes no sens to neither have recursive snapshots nor dynamic mount of subvolumes from parent snapshots.

Maybe its worth to describe this in the btrfs mailinglist and ask for further opinions.

@visit1985
Collaborator

Wrote a mail to the btrfs mailinglist. Let's see what the experts think.

@xtfxme
Owner

yeah, sadly this has been brought up before, with no input from the developers whatsoever (unfortunately they are not very good in this respect). i am of the opinion that it's btrfs's job to handle this, and that it should be an optional flag flag to the btrfs subvolume snapshot command -- anything else is racy, inconsistent, and hacky. subvols can simply be mv'ed around, so you could theoretically move the other subvols into place right before returning control to mkinitcpio, but this is a workaround at best, error-prone, and opens a can of worms in terms of policy (when should X be snapshot? how about Y? what about if Z condition?)

my opinion hasn't deviated much from this message:

https://mailman.archlinux.org/pipermail/arch-general/2012-July/028080.html

...the only remotely reasonable solution i see is to create a snapshot, then move everything else into place... FTR, this is one of several resaons i intended on requiring that the root-subvol (id=0) be mounted in a known or configurable location... we could use symlinks then, or at least manage stuff while the system was running.

@visit1985
Collaborator

http://thread.gmane.org/gmane.comp.file-systems.btrfs/29890
http://thread.gmane.org/gmane.comp.file-systems.btrfs/29908

They didn't come up with a solution, or even an opinion about this issue. They set on the set-default discussion and its compatibility to grub.

At least at one point they all agree: Btrfs quota is too experimental to use on a root filesystem. There are some major bugs in it which can corrupt data. This makes the whole discussion of our issue irrelevant.

@sysfu

I have a related issue where I would like to make snapshots of the entire system. I have several subfolders in my homedir that I keep in sync with other computers using BitTorrent sync, so I would like to exclude my homedir from these snapshots.

From time to time I install and experiment with software which I later decide I want to remove every trace of from the system. The mkinitcpio-btrfs boot snapshot rollback feature accomplishes this nicely.

Snapshot rollbacks of homedir subfolders is not desirable however as I anticipate this creating havoc with BitTorrent sync.

Does anyone happen to know if the OpenSUSE Snapper utility can be used to work around this problem?

@visit1985 visit1985 self-assigned this
@visit1985
Collaborator

Someone tried submit a patch for recursive subvolume snapshots, but it was dropped. It's impossible to do atomic recursive snapshots with the current feature set. No further investigation.

@visit1985 visit1985 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.