[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: btrfs snapshots (of root file system)?



On Sun, Oct 1, 2023 at 7:20 AM hw <hw@adminart.net> wrote:
>
> Hi,

Hello! I'm not going into much detail but maybe I can guide you to
better be able to find what you want.

> with btrfs, how do I make a snapshot of the root file system?  The
> purpose is to update software and being able to go back to a previous
> state if necessary.
>
> There doesn't seem to be a command to create snapshots but only
> subvolumes?  How does a subvolume turn into a snapshot?  (The root
> file system is, of course, not on a subvolume.)

Everything in btrfs is a suvolume, including the root (aka
"top-level"). A snapshot is merely a subvolume created *from* another
subvolume, and can optionally be read-only.

You can take a snapshot of the top level subvolume by doing "btrfs sub
snap / @foo". Documentation for creating both empty subvolumes and
snapshots are in btrfs-subvolume.

> How do I merge snapshots?  IIRC, when you remove a ZFS snapshot, the
> older state is merged to the state the snapshot is in.  Apparently
> btrfs can only delete snapshots --- and it seems like a bad idea to
> delete the root file system.  How would I boot from it when it's been
> deleted?

I don't think you can merge snapshots the way you describe. I don't
see how it could be atomic? You can however move subvolumes around
freely, create new snapshots at will, and select the boot subvolume
either by the "subvol=<path>" mount option or by setting the default
subvolume (btrfs sub set-default).

> Can I make a snapshot on a different volume?  The manpage doesn't say
> that the destination of a subvolume must be on the same volume, and in
> any case, I should be able to do that.

You can create snapshots anywhere *within the same filesystem*. To be
fair, the manpage says "A BTRFS subvolume is a part of filesystem" and
"A snapshot is also subvolume". It could be more clear.


Reply to: