this post was submitted on 14 Aug 2023
109 points (99.1% liked)

Linux

47283 readers
751 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I'm having trouble understanding all the benefits of BTRFS and how they'll apply to me.

Copy on Write and auto-compression seem like they will free up a bit of space.

What other practical benefits will I see from using BTRFS? Are there any noticeable performance benefits?

I use my computer to dual-boot. I don't need snapshots because I have a custom script for a fresh install. I use my PC for gaming and work. I've got an NVMe, two SSD's and one HDD.

Thanks in advance!

all 42 comments
sorted by: hot top controversial new old
[–] [email protected] 58 points 1 year ago* (last edited 1 year ago) (1 children)

Transparent compression, snapshots, copy-on-write, deduplication, and data checksumming (and healing via read or scrub) are the main things you might notice as an end-user. BTRFS is mostly on par or slightly slower than other simpler filesystems for speed (can be faster on HDDs due to compression), so if you're using it you probably want to be taking advantage of the features it offers, not because it's going to be faster.

[–] [email protected] 7 points 1 year ago

Healing won't work without copies (RAID) available. However, scrubbing regularly can also allow your drive to detect and correct errors before they become irreparable.

[–] [email protected] 21 points 1 year ago

As a (semi) power user I also use btrfs subvolumes to create "partitions" (single disk system, @root, @home, @docker), allows for making snapshots only for system or user data, etc.

All around, I love btrfs and I am never going back to journaling fs like ext4

[–] [email protected] 20 points 1 year ago* (last edited 1 year ago) (1 children)

Copy on Write and auto-compression seem like they will free up a bit of space.

That benefit is more theoretical, than practical. The majority of content you have on your drive will be content that is already heavily compressed at the file format level (e.g. images, movies, music) and where additional compression has no effect. So don't expect any big savings out of the box, you get about 5-15% saving on a regular install.

The real benefit are in the additional functionality it provides, e.g. you can use copy-on-write to make backups of large games before trying to mod them, backups that you might have previously avoided due to 100GB copies taking so long, with BTRFS it is done in a second.

As for BTRFS snapshots you seem to have the wrong idea what they are for. With them you can create backups of your whole filesystem within a second, so you can have full backup in case something goes wrong. With the snapper daemon you can easily automate that make new snapshots every hour and expire them when no longer needed. That's a really useful thing to have and with BTRFS it's basically free.

Another big advantage is the ease of partitioning, or the lack of a need for it, with BTRFS subvolumes all your volumes can share the same free space, while still being addressable as separate file systems, e.g. you can have subvolumes for / and /home, without having to guestimate how much space you might need in the future. Can also be abused to install multiple distributions on the same filesystem.

Also checksums, BTRFS will tell you when your data goes bad.

[–] [email protected] 5 points 1 year ago (1 children)

I thought compression would not help much with disk space as well. I believe it depends on the use case. After switching to btrfs and enabling zstd compression, my Arch install reduced from 100GB to 60 GB in terms of used disk space. Most of the savings are from documentations of development packages.

[–] [email protected] 2 points 1 year ago

Just for reference

spoiler~> compsize -x / Processed 699693 files, 766975 regular extents (791577 refs), 360356 inline. Type Perc Disk Usage Uncompressed Referenced
TOTAL 57% 39G 68G 69G
none 100% 23G 23G 23G
zstd 35% 15G 44G 45G
prealloc 100% 69M 69M 104M
~> compsize -x /var/lib/flatpak Processed 340412 files, 115619 regular extents (256345 refs), 209687 inline. Type Perc Disk Usage Uncompressed Referenced
TOTAL 55% 6.7G 12G 24G
none 100% 3.6G 3.6G 6.6G
zstd 36% 3.1G 8.5G 18G
~> compsize -x /home/user/.local/share/Steam Processed 219633 files, 1097250 regular extents (1111566 refs), 57457 inline. Type Perc Disk Usage Uncompressed Referenced
TOTAL 84% 249G 295G 296G
none 100% 203G 203G 203G
zstd 50% 46G 91G 92G
prealloc 100% 36M 36M 36M
~> compsize -x /home/user/.local/share/bottles Processed 18582 files, 33406 regular extents (33406 refs), 2366 inline. Type Perc Disk Usage Uncompressed Referenced
TOTAL 53% 1.8G 3.3G 3.3G
none 100% 959M 959M 959M
zstd 36% 907M 2.4G 2.4G

So it's 29G(43%) from / + /home, 5.3G(45%) from flatpak packages, 46G(16%) from Steam, 1.5G(47%) from Bottles, ~82G total out of 380G(22%) which is nice

[–] [email protected] 18 points 1 year ago

If you don't think you want snapshotting then dont worry too much about it and use whatever fs you like. if you want a nice btrfs experience try tumbleweed or leap, it is already fully integrated with system and grub , and maintenance with cleanup etc. cobbling together btrfs on your own is fine too but if you miss sometging and mess things up it is usually user error not btrfs error. .

[–] [email protected] 17 points 1 year ago (1 children)

For me, snapshots are the best part of BTRFS because you can easily roll back bad updates without doing a fresh install. It might not be worth reinstalling for, but there's no reason not to on your next install.

[–] [email protected] 1 points 1 year ago (3 children)

I know it's all in my head, but there's something about a fresh install that gives me comfort.

I do a fresh install every few months when something starts behaving funky and it's normally faster than figuring out what's wrong.

Snapshots just don't have the same appeal to me lol

[–] [email protected] 6 points 1 year ago* (last edited 1 year ago) (1 children)

You do a fresh install every couple months? Damn. I'm using the same install from like... 7 years ago? Which was also 3 laptops ago. I just keep copying the install partitions from one laptop drive to the next.

There is definitely something rewarding to figuring out an issue and fixing it, vs starting from scratch every time. Also, you realistically shouldn't be having serious issues every few months, unless you're running a rolling distro like arch and there's issues with packages. I do think a bit of that might be in your head,or you're experiencing some weird hardware issues/failure.

[–] [email protected] 1 points 1 year ago

Switched hardware on my home server last week and moved to proxmox. My Ubuntu installation that was running before that was installed 2011.

[–] [email protected] 2 points 1 year ago

the main advantage of snapshots is how fast it happen, in two reboots with little to no wait time you can get your system back

[–] [email protected] 15 points 1 year ago

I use BTRFS simply because I run a rolling distro of Linux. For the average user, I don't think it is quite as necessary but the snapshots are nice. Of course, you could use timeshift to make snapshots as well.

[–] [email protected] 8 points 1 year ago

I love btrfs. Mostly, because I had a couple of instances of data loss with ext4, and because it's far more user friendly than xfs. Btrfs has sane defaults, and when you do want to use the tooling, there's a lot of good documentation, and it's mostly straightforward.

That said, unless you have some reason to be mucking around with the fs or want to play with snapshots or such, then I'd say just use your OS defaults.

[–] [email protected] 7 points 1 year ago* (last edited 9 months ago)

[This comment has been deleted by an automated system]

[–] [email protected] 6 points 1 year ago

For me, BTRFS is worth it for the transparent compression and file integrity checks alone.

I am not sure what Fedora does for virtual machines via boxes (like transparently disabling COW), but one caveat with BTRFS is that you have to be aware that COW is a problem for usage patterns of virtual machines on their images. Just for this one example alone BTRFS is probably not a good fit for the average user.

Another thing which I just learned very recently, is to mount BTRFS volumes with the noatime option significantly speeds up a lot of workloads on my machine (machine has a decent SSD). Again, using the noatime option might create some problems in corner cases, so one should be aware what one is doing.

[–] [email protected] 6 points 1 year ago

Yes, snapshots nice to have and compression reduces the disk usage for the operating system and software quite a bit.

[–] [email protected] 4 points 1 year ago

It you have a functioning dual boot don't worry about it. Next install it's worth looking in into and pretty easy to setup. It has trim support for ssds and is way easier to resize on a live system than lvm with another filesystem

[–] [email protected] 3 points 1 year ago

I use ZFS, not BTRFS, but both have snapshots, and if you're someone who likes to tinker with their system like me, it lets you do so without worrying that it will break.

[–] [email protected] 3 points 1 year ago

I'm mostly in it for the RAID1 with checksums. If a bit gets flipped, it'll get flipped right back from the other copy next time the automatic scrub happens. Normal RAID1 can't do this because, without checksums, it doesn't know which copy is good.

If you've written shell scripts, I don't think you're an average user. 😋

[–] [email protected] 2 points 1 year ago

Yes, a few examples of advantages here: https://lemmy.world/post/3197228

[–] [email protected] 2 points 1 year ago

Yes. I dual-boot and need everything to be accessible from Windows so I gave Windows 400 GiB while Linux only 75 GiB. Without compression I would be out of disk space. I think I hold about 95-100 GiB of data in 70 GiB. Snapshots are to revert broken updates, not to setup fresh installations. If you use a rolling release distro, they become invaluable. You can boot into snapshots if an update goes sideways.

[–] [email protected] 1 points 1 year ago

Yes and no. It is good and I did one restore of some files that worked fine, but in my case it was noticeably affecting my boot up times, and I reverted to ext4 (boot ups were fast again to less than one minute). For some reason, BTRFS was resulting in quick login, but about 18 mins before my actual desktop was responsive after login. I spend many days trying to troubleshoot that. Maybe you won't have this problem. I had my SSD system drive on ext4 with Timeshift backups, and my /home partition on BTRFS.

So I'm back on my ext4 doing a daily automated backup to a second drive with rsync (LuckyBackup app). I think there are further kernel improvements coming to BTRFS later in this year. But I'll probably only retry it again end of 2023 or in2024. So if you decide to move, just benchmark your boot times, so you can judge if it affects them badly or not.

That said, BTRFS has some great features, lost no data for me, and I think has a great future.

[–] [email protected] 1 points 1 year ago

I use btrfs only for secondary and external drives, while keeping the main system on ext4.

[–] [email protected] -3 points 1 year ago (3 children)

Copy on write is likely to introduce significant performance decreases in cases where large or medium size files have a couple bytes changed. It’s usually recommended to turn CoW off on those files; I found it to be more hassle than it’s worth for a root filesystem. It is still a reasonable file system for file storage that looks more like archival - files land there and seldomly or never change. If you don’t have a specific need in mind though, I wouldn’t bother - in my opinion, it’s not great as a general purpose filesystem.

[–] [email protected] 24 points 1 year ago

Copy on write is likely to introduce significant performance decreases in cases where large or medium size files have a couple bytes changed. It’s usually recommended to turn CoW off on those files

Do you happen to have a source or benchmark for this? My understanding of CoW is that the size of the file does not matter, as BTRFS works with blocks and not files. When a block is changed, it's written to a new location. All the old blocks that are not changed are not written again - this wouldn't even make sense in the context of how BTRFS deduplicates blocks anyway.

So:

  • 10 kB base file

  • modify 1kB of the content

  • == 11kB total "used" space, and 1kB of new written blocks.

that old 1kB that is no longer part of the file will eventually be cleaned up if needed, but there's no reason to delete it early.

[–] [email protected] 6 points 1 year ago

Why would OpenSuse/Fedora choose it as their default filesystem if it was as bad you describe?

[–] [email protected] 2 points 1 year ago

Thanks for the advice!

How do you define medium or large files? What examples of these exist on root?