On Fri, Jul 5, 2019 at 4:45 AM Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > > > This is a conceptual btrfs question :-) > > I have this btrfs filesystem: > > root@xerus:~# mount | grep /test > /dev/sdd4 on /test type btrfs > (rw,relatime,space_cache,user_subvol_rm_allowed,subvolid=5,subvol=/) > > with some snapshots: > > root@xerus:~# btrfs subvolume list /test > ID 736 gen 9722 top level 5 path .snapshot/2018-12-02_1215.test > ID 737 gen 9722 top level 5 path .snapshot/2018-12-02_1216.test > ID 738 gen 9722 top level 5 path .snapshot/2018-12-02_1217.test > > I now want to do a rollback to .snapshot/2018-12-02_1217.test > I can do it with: > > mount -t btrfs -o subvol=.snapshot/2018-12-02_1217.test /dev/sdd4 /test > > But (how) can I delete the original root subvol to free disk space?
Near as I can tell you have to stop using whatever is using the subvolume you consider stale, so that you can umount the subvolme and then delete it. I think the more complicated rollback is for system root because that pretty much takes a reboot to clean everything up. So for example: [chris@flap ~]$ sudo btrfs sub list -t / ID gen top level path -- --- --------- ---- 258 38163 5 home 274 38155 5 root 280 36478 5 images 281 12926 5 home.20190624 282 12927 5 root.20190624 283 17109 5 root.20190626 285 17573 5 root.20190626-2 286 17840 5 root.20190626-3 # mount /dev/ /mnt # mv root rootold # btrfs sub snap root.20190626-3 root ## reboot when I'm ready to rollback The system does not get cranky at the rename. The mount command immediately sees the rename so 'rootold' is still mounted at / and everything works. But on reboot, I get a rollback. And I don't have to update grub stuff this way. And then at my leisure I delete the rootold subvolume. In any case, I would not do a rollback by directly using the subvolume I want to rollback to, I would make a snapshot of it and use the snapshot. That way if I do something stupid during the rollback, I haven't messed up my only copy of that subvolume. For /home, it's similar except I just log out instead of reboot. It's slightly annoying that I need root user enabled, because of course if I login as chris, the subvolume mounted on /home is pinned. I can't umount it now. Or alternatively a slightly more complicated setup with each user getting their own subvolume, and then I could login as some alternate admin user to do the rollback. But I'd still do it the same way: umount /home, rename the subvolume, snapshot the snapshot I want to rollback to giving it the name that's used in fstab, and then I just 'mount /home' and continue on. -- Chris Murphy