1

I have used snapper with Fedora 26 to create snapshots of my btrfs system, and I am trying to start fresh (i.e. remove snapper and anything it has done) but I have one snapshot I cannot remove as it appears to be my default subvolume (I don't remember why it would have done this, perhaps I tried a rollback).

# snapper delete 535
Deleting snapshot failed.
# btrfs subvolume get-default /
ID 1630 gen 112224 top level 275 path .snapshots/535/snapshot
# btrfs subvolume show /
/
    Name:                   root
    UUID:                   544f9215-4537-fe4b-b1b5-4da21d9abb9c
    Parent UUID:            -
    Received UUID:          -
    Creation time:          2017-07-19 21:28:42 +0100
    Subvolume ID:           257
    Generation:             112591
    Gen at creation:        8
    Parent ID:              5
    Top level ID:           5
    Flags:                  -
    Snapshot(s):

I am not certain if what I am asking here makes sense, but I want to change my default subvolume back to the parent (;master;root, not sure the right word) volume I had when I originally set up the system at the top-level of the file system, i.e. /, before the default change.

# btrfs subvolume list / -a -p -t
ID      gen     parent  top level       path
--      ---     ------  ---------       ----
257     112604  5       5               <FS_TREE>/root
258     112604  5       5               <FS_TREE>/home
263     112214  257     257             root/var/lib/machines
275     112593  257     257             root/.snapshots
276     112577  258     258             <FS_TREE>/home/.snapshots
1630    112224  275     275             <FS_TREE>/root/.snapshots/535/snapshot
1639    112604  257     257             root/var/log
1641    111548  257     257             root/mnt/virtualbox

Can I run a btrfs subvolume set-default to one of these to achieve this. I'm not certain on the meaning of /... as I was guessing I should change the default to the root with ID 257, but this threw me off.

The files inside this snapshot are now outdated compared to those in / and so I am not looking to overwrite / with the contents of the snapshot.

3

With mounting a BTRFS filesystem, it's possible to specify which subvolume to mount, or not:

A Btrfs filesystem has a default subvolume, which is initially set to be the top-level subvolume [who's ID is always 5] and which is mounted if no subvol or subvolid option is specified. - https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Snapshots

You can override the default subvolume by using the subvol option when mounting the filesystem:

mount /dev/sda / -o subvol=root/.snapshots/535/snapshot

In your case, subvolume 275 was changed to be the default when you performed a rollback.

rollback [options] [number]

Creates two new snapshots and sets the default subvolume. Per default the system boots from the default subvolume of the root filesystem. - http://snapper.io/manpages/snapper.html

What the Snapper map page is saying here implicitly is that it expects the mount point for your root filesystem to not specify a subvolume. Otherwise the rollback command would have no effect since it would be overwritten by the subvol option.

Your original default subvolume was the top-level (ID 5). You can certainly use btrfs subvolume set-default to make it the default again, but... perhaps you shouldn't.

If you've been booting from your 535 subvolume, then perhaps you've accumulated a vast number of changes over time on that subvolume. Reverting to your top-level subvolume would mean the loss of those changes; I'm using the word loss loosely here given that the changes would still exist, just in a different subvolume.

  • I did set-default to ID 257 subvolume and I was then able to delete the snapshot. All my changes since ID 275 was created and made default did not appear in that subvolume but in my root and so fortunately I didn't have to shuffle things around to recover 'lost' changes. Thanks. – Jdog Nov 2 '17 at 10:28
  • I'm trying to understand the same problem. When you say "loss of changes", in what situation does that happen? My root was subvolume 5. I rolled back to subvolume 685. I'm now on subvolume 1017, but mount sets "subvolid=1017,subvol=/@/.snapshots/685/snapshot" so I can't delete subvolume 685. As there are snapshot subvolumes after 685 and 685 was based on 5 then what might break if I "set-default 5 /"? Aren't snapshots built on each other so an older base for a newer snapshot should be fine? Thanks. – IBBoard Mar 1 '18 at 20:47
  • Just missed the edit deadline. Actually, I've got snapshot 685, which is btrfs subvolume ID 1017. Mount says "subvolid=1017,subvol=/@/.snapshots/685/snapshot" despite there being newer snapshots at boot time. If snapshots are built on each other and I've got newer snapshots than my current default, what would I lose by setting my original subvolume as default? I'm asking because I've got 10GB in root, 18GB used, and 4.9GB "excl" usage on the old base subvolume. – IBBoard Mar 1 '18 at 20:53
  • Actually, BTRFS snapshots don't depend on each other. For example, in Docker when images/layers are built on each other it creates dependencies between the layers; The upper layers depend on the lower ones. That's not the case in BTRFS. In BTRFS, subvolumes share blocks of data. For example, if subvolume B is a snapshot of subvolume A, that just means that (at the time of creation) B points to the same data as A. You can in fact delete snapshot A and B would remain unaffected. I don't quite grasp the specifics of your question, IBBoard, but perhaps this can help you intuit how it works. – Emmanuel Rosa Mar 2 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.