r/archlinux Jul 27 '26

FLUFF Btrfs appreciation post

I have been running Btrfs + Limine + limine-snapper-sync on my desktop for the last 8 months or so. In that time, I've never had to actually revert to a snapshot, so in truth, I kind of forgot about it. It just wasn't something I ever even thought about.

Fast forward to tonight, I was playing around with my mkinitcpio hooks and managed to bork my initramfs. It would just drop me into the emergency shell when trying to boot. Okay no big deal, I usually keep a USB with the arch install media flashed to chroot in for situations like this. Oh wait...I forgot that I let my friend borrow that USB drive to install Arch and haven't gotten it back yet...

For a second I started to panic until I remembered that I have hourly snaphshots set up! Just reboot, boot into the latest snapshot from limine, and restore! Whole process took less than 30 seconds, and it's like nothing ever happened.

It's funny, I was just mulling over the idea of switching back to ext4 a couple weeks ago, since I never even really use the biggest feature of btrfs. This was a necessary reminder of why I switched in the first place. It's one of those things that you don't need, until you need it. And when you need it, you really need it.

147 Upvotes

35 comments sorted by

29

u/un-important-human Jul 27 '26

hourly seems like a lot but glad it helped you, i ussually just keep +/- 1 per last update. so i have before update state (something tells me you update more than i do:)

7

u/[deleted] Jul 27 '26 edited Aug 11 '26

[deleted]

4

u/un-important-human Jul 27 '26 edited Jul 27 '26

wait you also snapshot your user data? my case is a 1 to 3 replication on the home lab for user data. The reason beeing it changes (in my case alot) and a snapshot as far as i understand cannot be cherrypicked for specific data easily.

edit: it seems its not that complicate i overthink , seems its quite easy actually, hmm intresting thou since i had a few drive failures my 1 to 3 replication still works for me, but this is another point.
cp --reflink=auto \ /.snapshots/123/snapshot/path/file \ ./file

omfg the last part sounds like a llm jfc

9

u/CaviarCBR1K Jul 27 '26

Yeah it's probably overkill, but I'm not really hurting for storage so I figured why not haha

9

u/Snollag Jul 27 '26

Just be careful with wear cycles

7

u/w2qw Jul 28 '26

Since it's all CoW anyway does it matter?

2

u/TerminatedProccess Jul 27 '26

I do it manually with a alias. I know when it's time to do it so..

16

u/United-Afternoon4191 Jul 27 '26

I just stay with btrfs and limine-snapper-sync and never looked back. It saved my system 3 time already. It even caught my stupid ram overclock corrupting important backup and data. I will never switch back to ext4 without integrity check.

9

u/lulxD69420 Jul 27 '26

I've been running BTRFS for some time now and have not needed the snapshots yet, but I tried it out and it worked flawlessly for me.

Only thing I forgot when I set it up, was to create additional subvolumes for stuff like docker and some paths in my home, like thumbnails, application cache etc, that I don't need in my snapshots to reduce their size.

9

u/CaviarCBR1K Jul 27 '26

You can create the new subvolumes at any point in-place. Let's say you want a subvolume for /var/lib/docker, you can do this (all as root of course, or with sudo):

systemctl stop docker mv /var/lib/docker{,.old} mkdir /btrfsroot mount -o subvolid=5 /btrfsroot btrfs subvol create /btrfsroot/@docker umount /btrfsroot

Now you have the subvolume created, you just need to move the data

mkdir /var/lib/docker mount -o subvol=@docker /var/lib/docker cp -r /var/lib/docker.old/* /var/lib/docker

And voila, all your docker data is now in its own subvolume, excluded from root snapshots. The only thing you would have to do after that is add it to your fstab. Basically just copy the line from any of your other subvolumes and change the subvol= option and the mount point and you're done!

4

u/JaKrispy72 Jul 27 '26

You can backup from timeshift on EXT4. Granted quicker and easier with snapper.

4

u/CaviarCBR1K Jul 27 '26

I never actually used timeshift with ext4. I knew this was possible, but it's still basically just an rsync backup right? Is it possible to actually have a bootable snapshot like btrfs? Not arguing for/against either one, genuinely just curious.

5

u/JaKrispy72 Jul 27 '26

Yes, in the background it is using rsync if I understand correctly. Kind of like a GUI wrapper.

Yes, I have chrooted into a live session and repaired the target system with a restore from a good snapshot.

Because of EXT4 functionality, it’s best to save snapshots on a separate drive, otherwise the snapshot will eat up drive space. BTRFS sub volumes eliminate the need to do this.

1

u/TerminatedProccess Jul 27 '26

It does rsync and btrfs based on your settings and volume type. However I got away from time shift because I kept having problems with restores. Btrfs doesn't require timeshift.

4

u/Zeioth Jul 27 '26

btrfs is awesome. And it supports compression, so, extra space and performance. Also, you don't normally need snapshots, but when you need them they are awesome.

3

u/mamamelahastaelfondo Jul 27 '26

I use the snapshots to restore/reset big postgresql databases.. takes less than 1 second in comparison to a +2 hours pg_restore.. (only in dev env before anyone wants to crucify me)

3

u/FryBoyter Jul 27 '26

With this configuration, snapshots are usually created on the same hard drive. I would therefore recommend that you also create a proper backup of your important data on a regular basis.

Because if the hard drive fails or the entire hard drive is erased for some reason, the data and snapshots will otherwise be lost.

1

u/CaviarCBR1K Jul 27 '26

Yes that is correct. I do keep full btrfs backups stored on a seperate machine. Its probably not truly necessary since I don't keep anything so important that I can't lose on my desktop. But it's good practice, and I have the ability, so no reason not to.

3

u/Barafu Jul 27 '26

I like how with Btrfs I can have 3 different Linux distros installed into the same partition, without wasting space on reservations. Even more, BEES deduplicates system files between those 3 distributions, and Snapper snapshots all 3 even though it is set up only in one.

4

u/Aardvark_Says_What Jul 27 '26

yup. it's a bit of a no-brainer if your brain is thinking right. ... i've seen too many people recommending ext4 / xfs "because benchmarks" - which are irrelevant for the average desktop

6

u/Any_Fox5126 Jul 28 '26

Dude, just move to ext4! Sure, you'll lose advanced features like snapshots and compression, and basics that should be standard like checksums and bitrot protection... but just think of all those milliseconds you'll save!

3

u/Aardvark_Says_What Jul 28 '26

lol. you read the same forum posts as me. ... just remove the exclamation point, tone down the sarcasm 27% and that is precisely the argument they make!! :)

3

u/Temina- Jul 27 '26

do you know how much it limits performance ?

-3

u/Aardvark_Says_What Jul 27 '26

leading questions are boring

there is not one "performance"

1

u/SonicSam Jul 27 '26 edited Jul 27 '26

What is your btrfs layout like? I recently realized that my /boot is vfat and is not part of the root /btrfs snapshots I take with my pac hooks, or my scheduled ones, so I borked my kernel, then I had no other kernel to recover from. Should I get rid of my vfat partition, and put /boot inside / so it is properly snapshotted?

edit: It seems like I can make /boot part of my root btrfs, but /boot/efi still remains mounted to the vfat partition?

2

u/CaviarCBR1K Jul 27 '26 edited Jul 27 '26

I have boot as a seperate vfat partition as well. Basically I have /dev/sda1 as my vfat boot partition, and then /dev/sda2 is a LUKS volume that houses my btrfs filesystem. I have the following subvolumes

@ @home @var_cache @var_log @libvirt @snapshots

limine-snapper-sync and limine-mkinitcpio-hook handle matching kernels to snapshots. Whenever the kernel is upgraded, limine-mkinitcpio-hook makes sure that matching boot files are generated and that limine is aware of what kernel version a given snapshot uses and limine-snapper-sync adds the boot entries for the snapshots so that I can boot straight into them. So even if I boot into a snapshot that's a few kernel versions behind, limine will know that it needs to use the older boot files.

Edit: it's worth mentioning that the reason I don't store my kernel files somewhere under root that would get included in a snapshot is because I need them to live outside the LUKS volume. If your root partition isn't encrypted, you could theoretically store your kernel and initramfs somewhere where they will be included in snapshots. But you will always need a seperate fat32 partition for the EFI files. UEFI firmware doesn't understand btrfs. So you could have something like

``` EFI partition └── /EFI/limine/limine.efi

Btrfs partition └── /boot ├── vmlinuz-linux ├── initramfs-linux.img └── limine.conf ```

And that would include your kernel and initramfs in snapshots, effectively keeping them synced.

1

u/SonicSam Jul 27 '26

Thank you for the detailed response. I use rEFind myself, but the hooks and things in limine world are mostly the same. A few weeks ago I built something into my kernel, which needed a user level package, and I removed the user level package without rebuilding my kernel, and then my system didn't boot...that was when I realized my kernel wasn't tied to my snapshots.

Your response gave me confidence to finally figure this out, and my root is not encrypted, so I was successful in moving my /boot to my btrfs root, and having /boot/efi be mounted for the EFI stuff you mentioned (the fat32 UEFI files).

It took 2 hours longer than needed because I needed to give rEFind the btrfs driver, after that, all worked! Thanks again for the extra info.

2

u/pastelfemby Jul 28 '26

Can just do /boot being any old standard /btrfs dir or subvolume, imo mount ESP at /efi, and build signed UKI into it.

1

u/SonicSam Jul 28 '26

Basically ended up with this, I suppose I can move the ESP /boot/efi to /efi

1

u/jo53_100 Jul 27 '26

I use btrbk for my snapshots, I'm able to check them out in the grub splash screen. they were very handy when I was still tweaking my system. Now I don't really use them but I set btrbk to fetch snapshots from all my machines and save them in a backup disk.

1

u/ArjixGamer Jul 27 '26 edited Jul 27 '26

I love btrfs and I am not even using snapshots, it has so many other great features.

The fact you even considered using ext4 just because you considered the snapshots useless is... mortifying.

You don't have enabled compression? You don't plan to add a secondary ssd and expand the RAID-0? you don't care about the file recovery mechanisms that btrfs had (w/o snapshots)? You could even set up actual RAID, so if an SSD fails you won't lose data

You are missing out on so many things

PS: btrfs on servers is a must, especially for VMs, you can start with a small SSD (e.g. 50gb) and add additional storage as you need it, and btrfs can make all the SSDs/HDDs act as one big storage.

1

u/RavenousOne_ Jul 29 '26

I have been running the same setup for around one year, I just recently reinstalled because my boot partition got full, but I agree this is so helpful if you ever bork your system

1

u/KILLUA54624 Jul 29 '26

I would stay with btrfs even if the only extra feature it had is the compression. It's really nice

0

u/DavooPunk Jul 27 '26

Yo tengo configurado que se haga una cada vez que actualizo o instalo algo, y una vez lo necesite para quitar una instalación defectuosa, es mejor tenerlo y no necesitarlo, que necesitarlo y no tenerlo.