On Sun, Nov 29, 2020 at 9:52 AM Sreyan Chakravarty <sreya...@gmail.com> wrote:
>
> Hi,
>
> I have only 1 partition, which has my root and /home together.
>
> I have installed Fedora33 with the default BTRFS settings, in which it does 
> not create a subvolume for root.

It does. You can check with any or all of these commands:

mount | grep btrfs
sudo btrfs subvolume list -t /
cat /etc/fstab

> I have created a snapshot of my entire root filesystem using:
>
>                    sudo btrfs subv snapshot / /root/snapshots/test
>
> Now what do I do ?
>
> How do I restore the snapshot ?

There's a lot more than one way to do this. As one possible example:

$ sudo mount /dev/nvme0n1p7 /mnt
$ cd /mnt
$ ls -li
total 0
256 dr-xr-xr-x. 1 root root 1330 Nov 26 23:25 boot
256 dr-xr-xr-x. 1 root root 1966 Nov 23 22:43 boot.20201126
256 drwxr-xr-x. 1 root root   10 Jul 27 12:22 home
256 drwxr-xr-x. 1 root root   10 Jul 27 12:22 home.20201126-2
256 drwxr-xr-x. 1 root root   26 Nov  1 13:05 images
256 dr-xr-xr-x. 1 root root  132 Nov  5 18:23 root
256 dr-xr-xr-x. 1 root root  132 Nov  5 18:23 root.20201126

These are all subvolumes, as evidence by (a) it's a Btrfs file system,
and (b) each has inode 256. Some folks like to put a character in the
name of their subvolumes to indicate it's a subvolume, common is using
the @ character. So @home and @root. I don't use this convention
myself, I just stick only subvolumes in the "top-level" of the file
system as you see here.

The other convention I use is I make read-only snapshots with a date.
What I do for a rollback is:

# mv root rootold
# btrfs sub snap root.20201126 root
# reboot

What this does is mounts the "top-level" [1] so you have direct access
to the root and home subvolumes. And then rename the current root to
something else; and then snapshot the desired snapshot as the new
root. I do it this way because I don't have to modify either fstab or
GRUB, both of which are expecting a subvolume named "root". You do not
need to worry about renaming an active/in-use subvolume. Internally
Btrfs is using subvolume ID's anyway, and that won't change. You'll
notice if you rename a mounted subvolume, its name is immediately
updated, verify this with the mount command before and after renaming.

An alternative approach is a bit advanced only in that it requires
knowing about the "default subvolume". And to give a complete answer
is a bit of a story. But you can get the gist from 'man btrfs
subvolume' and read the set-default and get-default sections in
particular.

[1] Nested versus flat layouts. The above example is a flat layout.
https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Layout


-- 
Chris Murphy
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org

Reply via email to