6

I have Fedora 20 and when I installed it I choose to go with btrfs as file system, by many reasons but mainly to have snapshots available.

But I can't seem to create a snapshot of /. I can snapshot my home folder (which also is btrfs) like this btrfs subvolume snapshot /home/ /snap/home, but when I try to snapshot / by writing btrfs subvolume snapshot / /snap it just outputs ERROR: incorrect snapshot name ('/').

I am sure that / is btrfs. gparted

Listing subvolumes outputs:

# btrfs subvolume list /
ID 256 gen 9562 top level 5 path home
ID 258 gen 9562 top level 5 path root
ID 306 gen 9517 top level 258 path snap/home/2014-08-15_00:44:00

Is it not possible to snapshot the root folder, even if it is using btrfs?

2 Answers 2

12

You need to provide a name for the snapshot under /snap e.g.

$ btrfs subvolume snapshot / /snap/root

If you don't provide a name btrfs will use the name of the source subvolume. In your case the source subvolume is called / which is not a valid name for the snapshot.

usage: btrfs subvolume snapshot [-r] <source> <dest>|[<dest>/]<name>

    btrfs subvolume snapshot [-r] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>

    Create a snapshot of the subvolume
    Create a writable/readonly snapshot of the subvolume <source> with
    the name <name> in the <dest> directory.  If only <dest> is given,
    the subvolume will be named the basename of <source>.

    -r             create a readonly snapshot
    -i <qgroupid>  add the newly created snapshot to a qgroup. This
                   option can be given multiple times.
2
  • 2
    With btrfs-progs 4.3.1 on Linux 4.3.3 this error also occurs if <dest> is an existing directory (where the error message could be much more helpful, reported as bugzilla.kernel.org/show_bug.cgi?id=109981). Commented Dec 25, 2015 at 21:25
  • Thanks. I was just trying to create a snapshot at as path at which there was already one. Damn, it's a pretty stupid error message.
    – Paul
    Commented Aug 7, 2020 at 21:40
1

If you want to preserve your root system you may wish to do this

mkdir /. snapshots
btrfs subvolume snapshot / /.snapshots/24072018
nano /.snapshots/24072018/etc/fstab

UUID=XXXXXXXX     /    btrfs    defaults, subvol=root/.snapshots/24072018  0      1

It's common for Fedora this days when you format your system with btrfs to create a subvolume called root, so if you didn't find the subvol option in fstab, then omit root from subvol.

The next step will to reboot your system. When the system starts up you will see the grub booting menu.

  • Press e on the default entry
  • Scroll down until you find the subvol option if Fedora was installed on a subvolume. If not you will have to find the rootflags option and write the following :

    • rootflags=subvol=.snapshots/24072018

      Or for the case the system was installed on a subvolume:

    • rootflags=subvol=root/.snapshots/24072018

Note that if the system was not installed on a subvolume it's unlikely you'll see the rootflags option in the grub entry, so you must write the rootflags parameter next to the "ro" parameter for this to work.

After booting successfully to your system, open the terminal, login to the root account, and update your grub configurations if you want to make the changes permanent.

1
  • 1
    The white-space in mkdir /. snapshots is an error, right?
    – MrCalvin
    Commented Jul 16, 2023 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .