Before upgrading to Fedora 25 I did a btrfs subvolume snapshot / /f24. I hat to little free space, so the update failed. Now the question is, how to revert the snapshot? I already booted into the snapshot by editing grub.cfg (setting rootflags=subvol=root/f24).

  1. this guy says to just btrfs subvolume delete root. But I'm not sure if grub2 will regenerate a bad grub.cfg on the next kernel update. Also delete root sounds like a rm -rf / like operation.

  2. This guy used rsync to just copy over the data from the snapshot to the root. I'm sure it works, but its a 2013 answer and I assume there is a better way to just revert the snapshot.

  3. I've found a couple of times to "just use mv", usually together with apt-btrfs-snapshot. It just doesn't sound like mv /f24 / will really work. (If it does, please correct me.)

In the End, the reverted snapshot should of course be named root again and not root/f24. Here is some info on the FS:

$ btrfs subvolume list /
ID 257 gen 419417 top level 5 path root
ID 3231 gen 419430 top level 257 path root/f24

Booted into the snapshot:

$ btrfs subvolume show /
    Name:           f24
    UUID:           b1782609-7d9f-4725-911d-428cda2256c7
    Parent UUID:        8df6fae9-770a-4d55-a4bf-6a32edf1fbd7
    Received UUID:      -
    Creation time:      2016-11-26 19:17:22 +0200
    Subvolume ID:       3231
    Generation:         419438
    Gen at creation:    411444
    Parent ID:      257
    Top level ID:       257
    Flags:          -

Is there a 2016 way to do this?

migrated from stackoverflow.com Nov 27 '16 at 11:27

This question came from our site for professional and enthusiast programmers.


Your situation is somewhat simplified by the fact that neither your current nor desired subvolume is the "real" Btrfs root, that is, subvolume ID 0.

Start by (temporarily) mounting the real Btrfs root, like this:

mkdir /mnt/btrfs-root
mount -o subvolid=0 /dev/somedevice /mnt/btrfs-root

Now, inside btrfs-root, you should be able to see your subvolume "root" as well as any other subvolumes you've got defined there. You can rearrange them just the way you want using plain mv:

cd /mnt/btrfs-top
mv -i root/f24 newroot
# Now at least you don't have one subvolume rooted inside another
# It's a little simpler to work with.

# Now just shuffle them as desired
mv -i root oldroot
mv -i newroot root

# ...and clean up
umount /mnt/btrfs-top
rmdir /mnt/btrfs-top

Now, the next time you mount the subvolume called "root", it will be the new one.

Be careful that you are not mounting your root filesystem by subvolid. If you are mounting it by subvolid then the subvolid won't change even if you rename things as above.

  • If you are mounting the filesystem by relying on the default subvolid, then you'll want to change the default subvolid to the new one:

    btrfs subvolume set-default 3231 /
  • If you are mounting it by explicit subvolid specification then you'll want to change /etc/fstab and /etc/default/grub to use subvolid=3231.

  • Awesome, what I was missing is that the root subvolume wasn't the real root. I read somewhere to do it like that but I didn't realize fedora does it automatically like this. Thanks a lot! – Mathias Nov 27 '16 at 14:41

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.