BTRFS subvolume as root?

Hello, in the last months I changed to BTRFS in the root (the home remains Ext4 because VM’s) and works great, fast and stable, I like mainly because of the ease of snapshots that allow me to recover from almost any dangerous activities.

For example recently made a snapshot just to try to change SystemMD to OpenRC and everything was a disaster in the snapshot, I remember that I could not even start the system because I configured wrong OpenRC and all I could do was put a LiveCD, chroot in the BTRFS partition and return to healthy snapshot, then everything worked properly.

But lately, I wonder if I can do the rollback’s more practical, since currently I have to do the following:

  1. Original root snapshot (with configs and stable)
  2. Make a temp root fron above btrfs sub set-def <id original root snap> /
  3. Mount bad root to /mnt from temp root
  4. Make rsync from temp root to bad root (original root)
  5. Make real root (original root) default again.

All these instructions have read in the Fun Btrfs.

But as I said, I want to do more easy:

  1. Never use real root, just important updates with chroot.
  2. Make a RW snapshot and use as new root
  3. Execute btrfs sub snap / /newroot when I need to rescue from a serious error.

The idea is to never touch the original root (only update it), and always work on a snapshot and enable rapid rollback without copying files to have a good real root.(don’t use rsync)

But I can’t find if is advisable to use a snapshot as root (daily), I want to know about performance issues. (CoW/SSD).

You can use btrfs /home with VS’s, just make sure to disable CoW for them.
See “Warning” below this Archwiki section: https://wiki.archlinux.org/index.php/VirtualBox#Use_the_right_front-end

It is not particulary an answer to your question, but you can try to boot into a good snapshot
https://wiki.archlinux.org/index.php/Btrfs#Booting_into_snapshots_with_GRUB

You can “simply” chroot a snapshot, adjust the fstab and run update-grub.

@kainonergon @eugen-b Thanks you for comments!

  • I use Ext4 for /home because I don’t want to disable CoW, even in one directory. And Ext4 VM’s performance is better that Btrfs.

  • I don’t use GRUB, I use systemd-boot with UEFI (Secure boot enabled) and I have the following:

    1. Manjaro (default) --> original root
    2. Manjaro (fallback)
    3. Manjaro (installation date) --> snapshot from original root when I installed Manjaro
  • I know that I can chroot in the snapshot, specially for test configs and dangerous packages.

Right now, I’m using the real root (id 0). I’ trying to make a new snapshot for each test of new dangerous features. But when I do something bad, and the real root (id 0) don’t work, I need to rollback (rsync) all the good files from root snapshot to real root, because the real root must be healthy.

But I want to know if I can use a BtrFS subvolume (snapshot) as root for daily use, without performance issues. (never use the real root, just update it).

Again, Thanks you for comments! :slight_smile:

I need to read your posts again, because I don’t understand everything.

I can tell you that I use to install the NET edition (also the core edition of antiX) and then create snapshots, add custom Grub entries for them, boot into them, install different DEs and whatsoever. No issues so far. Also copying the whole installation into a subvolume on another drive works.

I have no experience in this problem. Maybe you can use snapper rollback command to restore your root?

@kainonergon @eugen-b Sorry My english isn’t good at all :sweat:

@eugen-b different DE’s is awesome with the same OS (new stuff for me )

@kainonergon snnpper is good but I can do that I need with btrfs command

I’m researching more about BtrFS and I found this:

Note that a snapshot is not a backup: Snapshots work by use of btrfs’s copy-on-write behaviour. A snapshot and the original it was taken from initially share all of the same data blocks. If that data is damaged in some way (cosmic rays, bad disk sector, accident with dd to the disk), then the snapshot and the original will both be damaged. Snapshots are useful to have local online “copies” of the filesystem that can be referred back to, or to implement a form of deduplication, or to fix the state of a filesystem for making a full backup without anything changing underneath it. They do not in themselves make your data any safer. BtrFS wiki

In fact The subvolume have the same data of real root, that mean that I can use the subvolume as a root without issues. i.e. different DE’s with the same base system.

In other way, the home (personal data) require backup weekly/monthly because subvolumes aren’t backups

Tnanks for help! :slight_smile:

1 Like

@totakaro, I think your new approach will work.
Once I used OpenSUSE Tumbleweed (not very long), and I guess they used the same approach as default for the root partition. They used snapper to create snapshots before any significant change to the system (install, uninstall, update packages). If something went wrong, there was an option to boot up any of the snapshots and if you want to revert your root to that state, run snapper rollback. It created rw snapshot of currently booted snapshot and set it as default root.
Your way is similar, just without snapper you should use your own scripts. Good luck in your dangerous activities!

Thanks for your response!

Finally I can say that the only way is TEST.
Now, I convinced that subvolume snapshot will work as root.

I will return again in a few months for share my experience :slight_smile:

2 Likes

Hello!

@kainonergon @eugen-b

1 month since I wrote about my btrfs experiment :slight_smile:

Today, I’m happy with my subvolume settings.

BtrFS is great for manage subvolumes and snapshots.

When dangerous activity can destroy the root, the rollback would be very easy.

I noticed that OpenSuse is working with BtrFS snapshot a lot.

A day…
While I was boring, trying to correct a issue with a plugin, I execute a stupid command at shell, then this changed all root permissions, to the home user, I fix the permissions problem but the system don’t worked anymore, because my “mistake”.

I switched to root user and just rollback to the most recent snapshot, in a few seconds.

btrfs sub snap /snapshot-2016-08-23 /new-2016-08-31
btrfs sub set-def <new-id> /
reboot
btrfs sub del /<deprecated subvolume>

I have saved hours searching for fix a issue because a stupid mistake, thanks to btrfs rollback.

2 Likes

Hi @kainonergon @eugen-b

3 years using Manjaro KDE with a root BtrFS partition.

Today, I did a factory reset using a healthy snapshot.

@philm Happy to see Manjaro in Forbes: https://www.forbes.com/sites/jasonevangelho/2019/09/08/manjaro-linux-just-made-a-massive-announcement-about-its-future/#5b5998f336f9

All is working like a charm :+1:

1 Like

Forum kindly sponsored by Bytemark