How to create and restore btrfs snapshot of my root partition?


the short version of want to do is: i want to create a complete snapshot of my root directory. Then i want to perform a potentially dangerous action on my system and if this fails i want to restore the state saved in the snapshot. How can i do all of this (creating a snapshot and restoring to a snapshot)

Some info about my system:

  • Dell XPS notebook
  • 500 GB hard disc (/ is on a btrfs partition, /home is a xps partition)
  • OS: opensuse Tumbleweed

the long version is: my notebook has an intel graphics device and a deticated NVIDIA GPU. Currently i have neither the propritary NVIDIA driver installed nor the nouveau driver. The reason is: the latter does not work with my GPU and the other caused some problems as i tried it the first time (black screen after booting).
And in general i like to use the intel chip most of the time and practically there is no easy way to switch between those two devices. Recently i heard rumors that NVIDIA may be working on improving the optimus experience on those notebooks, that is why i want to install the NIVIDA driver (from the official nvidia repository for tumbleweed), even when, in the end, still the intel device is used. From an earlyer experiment i did, i know that it is possible to install the NVIDIA driver and reach a state where it is possible to open the nvidia-settings and get the infomation message that no nvidia driver is used (because the intel chip is used, which is fine for me).

So, but i know that everything can get horribly wrong when trying to install the NVIDIA driver, that is why i want to prepare an easy way to revert everything to the state i currently have!

But i never tried to fiddle with btrfs before so i have no idea what to do. My questions are:

  1. How to create such a snapshot (using yast and the command line)?
  2. How to revert to a state stored in such a snapshot from a unbootable system?
  3. Is /home included when it is mounted to / ? (i do not want to include /home)