Per title. From quick googling, I understand that zfs is a filesystem that provides some kind of software RAID and resiliency (eg CRC checks at the block level). Is my understanding right that it just good for detecting storage corruption, but not really self healing?

My home server just for a mini storage/ media server and I am broke to afford RAID. So at the moment, it’s just 2 consumer grade drives .

So pros with zfs I can think of, I get slightly better data resiliency.

But after reading the docs, the cons for me are that a) it’s not so straightforward/ somewhat complex to tune and use, b) it’s not default in mainline linux, and c) slightly lower performance?

What do you think and is it worth learning to use it vs just slapping a plain xfs/ ext4 ?

  • andioop@piefed.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 days ago

    I’m just so glad you asked this because I’ve been looking for an answer to this too. Will read all the comments!

  • Shimitar@downonthestreet.eu
    link
    fedilink
    English
    arrow-up
    36
    arrow-down
    3
    ·
    7 days ago

    It’s my personal opinion but: no

    Btrfs is integrated in the kernel already and pretty solid. I have been running it for the last few years. I use Linux mdarray to create a raid5 and on top of it, format btrfs.

    Never had issues, and yes it did catch data corruption (and fixed it) so I am pretty happy .

    Zfs on the other hand, needs specific kernel patches and I don’t like that too much.

    • Avid Amoeba@lemmy.ca
      link
      fedilink
      English
      arrow-up
      6
      ·
      7 days ago

      ZFS has been running with upstream kernels for years. Ubuntu ships with precompiled module and Debian has a DKMS package which compiles ZFS against the stock kernel.

    • dadarobot@lemmy.ml
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      7 days ago

      fully agree.

      i used zfs on arch many yeara ago and my updates would fall months behind.

      then i switched to freebsd for better zfs support. but lost support of some linux apps

      later i started using truenas and it works great.

      on a related note, i switched to cachyos on my desktop and laptop and used btrfs for the first time and i absolutely love it.

      so if youre building a nas from scratch, id say use btrfs, but if youre using an os that manages that stuff for you, zfs is a great choice.

      • Guiorgy@lemmy.ml
        link
        fedilink
        English
        arrow-up
        5
        ·
        edit-2
        7 days ago

        If you only require mirrors (RAID 1) then BTRFS works fine, but if you need something more and the system has good support for it (e.g. Ubuntu) then ZFS is better IMO. Yes you can use mdraid with BTRFS, but I prefer 1 ZFS over 10 different moving parts.

        I use both, choosing which one depending on the conditions.

  • kalleboo@lemmy.world
    link
    fedilink
    English
    arrow-up
    19
    ·
    6 days ago

    Thanks to btrfs I learned I had bad RAM that was corrupting files. Nothing was crashing, so I would never have noticed otherwise. 100% would recommend using a file system with checksumming, be it ZFS or btrfs.

  • mlg@lemmy.world
    link
    fedilink
    English
    arrow-up
    7
    ·
    5 days ago

    In my experience, RAID 5 has always been poor performance, and at RAID 50 you’re better off just using ZFS.

    ZFS’s killer feature (aside from RAIDZ) is silent data corruption protection, which is why its preferred for large pools with many drives or anywhere where data resiliency needs to be very high.

    The key here is the pool size, ZFS is only worth running if you have a sizable amount of drives and the system resources (RAM mostly) to run it.

    You can run it on a cheap homelab server, and people do, but I wouldn’t recommend it unless you only use it for storage and you get more drives for RAIDZ.

    Otherwise, the cheapo method of getting better data resiliency without performance loss is RAID 10 (Or in your case, RAID 1). That’s my default for any consumer grade drives. The cost of half the usable space is just worth the level of protection you get from a drive failure, especially when you’re on a budget (still much cheaper per TB than buying some beefy SAS drives and doing RAIDZ).

    Make it a RAID 1 and chuck XFS on it for some corruption protection (or BTRFS, or ext4).


    Also, make sure you use smartctl and even consider making a script that runs a test monthly and saves the results somewhere easy. Start a long test of your drives and check the output later (take a couple of hours to a day) to see if it found any errors and look at the error counter stats. A failing drive will have a lot of errors stacked up in the counter, and a failed drive is if the long test fails.

  • SayCyberOnceMore@feddit.uk
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    edit-2
    6 days ago

    Just chipping in as someone who’s tried mdadm, zfs and btrfs over the years…

    I settled on btrfs in the end basically due to the quantity of tools that can read the filesystem.

    I use clonezilla and gparted a lot when setting up and maintaining systems and btrfs just has more support, easier to add disk, etc.

    It’s also - as others have mentioned - already in the kernel so you can keep your data and change your distro if needed.

    I see - and this is a generalisation - most people have ZFS because of TrueNAS, which is fine, but when I built my own (Arch, btw) NAS, it just all came together nicely (giggity) with btrfs

  • Jimbambuli@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    ·
    6 days ago

    I use both in my Proxmox cluster: ZFS on the big storage node, LVM-thin on the smaller ones. ZFS is worth it where you want snapshots, send/receive and checksums, but it wants RAM and you should plan the pool layout up front. On small boxes LVM-thin is simpler and does the job.

  • Avid Amoeba@lemmy.ca
    link
    fedilink
    English
    arrow-up
    15
    ·
    7 days ago

    Worth it 100%. Even for single-drive systems like laptops. It allows for a trivial full system backups while the system is running.

  • BeigeAgenda@lemmy.ca
    link
    fedilink
    English
    arrow-up
    19
    ·
    7 days ago

    I chose btrfs over zfs, because you can add and remove disks from a volume (I’m not sure if zfs has this feature now) I use this to move the volume from old to new disks.

    • FlexibleToast@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      6 days ago

      ZFS does have that feature now, sort of. You can add drives to a vdev now, but the vdev will keep its original shape. So for example if you had 4 drives in a RAIDZ it would be 3 stripe + 1 parity. If you add a 5th drive it will stay 3+1 and not efficiently use the space. It doesn’t rebalance to 4+1. It’s strongly recommended not to do it.

  • chattre@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    13
    ·
    7 days ago

    I think BTRFS is easy enough (included in the kernel, pretty stable) and has most of the practical benefits of ZFS with little overhead. I like the snapshots and FS compression

  • toastal@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    5 days ago

    One of the most annoying parts is that OpenZFS drags their feet on Linux kernel releases. I understand Linux isn’t their only target, but adapting to the new APIs is usually merged quickly, but you are lucky to get a release before the last kernel is deprecated. I’ve been keeping Linux 7.2 on life support for weeks now.

    The old advice was to stick to LTS. For stability this is true, but now with all these LLM-guided bug/security finds, much of these aren’t backported & leaves one at greater risk than before.

  • Onomatopoeia@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    13
    arrow-down
    1
    ·
    7 days ago

    ZFS shines with large datastores and multiple drives. It has its uses, for sure.

    As others have said, it puts all the layers: RAID blocks, file system, volume management, etc, all under a single umbrella. Because of this it can do some things that are more challenging with other approaches.

    For your two drives, I wouldn’t bother with anything other than what they are, and make sure you have proper backups.

    Drives die all the time. Just today one of my RAID boxes complained about a drive, in the process of replacing the drive I discovered 2 other bad drives that I had sitting around as spares.

    Last week an external drive decided to die. Fortunately I was using it as one of three replicants of my primary system, so no big deal.

    • monkeyman512@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      7 days ago

      That is a good point. A backup is probably higher priority over choosing a filesystem assuming you already have something functional and no backup.

      • Guiorgy@lemmy.ml
        link
        fedilink
        English
        arrow-up
        4
        ·
        7 days ago

        RAID is not a backup, what RAID gives is availability, what you should prioritize depends on the usecase, but generally proper backups are usually the priority

  • Strider@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    5 days ago

    Big zfs proponent here.

    So as I understand you want to do software raid, don’t bother with zfs. Just use standard lvm and whichever fs you like to make your mirror.

    Also it’s not just a Filesystem (so it’s far more). The best description I once saw that it is a layering violation and that’s actually a great description and also pro/con depending on your viewpoint. You can basically manage any storage any way you want. If that’s a good thing is up to you.

  • Guiorgy@lemmy.ml
    link
    fedilink
    English
    arrow-up
    8
    ·
    edit-2
    7 days ago

    Both ZFS and BTRFS require having at least 2 copies for healing, however, unlike a standard RAID1 that is oblivious to which of the 2 copies is healthy, the 2 filesystems use CRC checksums to figure out which is corrupt and recover the good one. As long as you have at least 2 copies, they will check the checksum on every read and heal it if corruption is detected. Besides that, you’d schedule a periodic scrub to also check the data that hasn’t been read in a while.

    In ZFS you can tell it to keep 2 copies of everything even if you only have 1 drive, which would give you the healing effect, but this obviously halves the drive capacity, and does not save you if that 1 drive dies, hence spreading it on multiple drives is better.

    Personally, I find ZFS easier to use than BTRFS, it’s not that complicated once you get the hang of it, plus LLMs can help anyway. It does have many dials that can be tuned, but unless you are trying to optimize it for a specific usecase, the generally recommend setting are fine for most use cases.

    It’s not built into the kernel, but server distros (e.g. Ubuntu) build it as a loadable module, which is kept in step with the kernel, so generally no issues there. On distros like Arch it can be really annoying though.

    “Slightly lower” is a bit of an understatement, both for ZFS and BTRFS. Those are CoW (Copy on Write) filesystems, so they are much slower to write, which is a traid off for the benefits of CoW. On the other hand, reads are only slightly slower (since CRC is always checked), and thanks to transparent compression, they can be even faster to read.

    One downside of ZFS over BTRFS is fragmentation, all CoW filesystems suffer from it, but BTRFS allows you to defragment in place (takes a while though) unlike ZFS.

    If you can’t afford storage, the data you want to store is generally compressible, and speed is not critical/priority, it might be woth using ZFS/BTRFS just for the transparent compression to save on space and get more out of the drives you have. I’m using BTRFS on a Fedora system for this reason alone, helps me avoid buying a new SSD 😬

  • Err(()).unwrap()@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    arrow-down
    1
    ·
    edit-2
    7 days ago

    I absolutely recommend ZFS. I’ve been burned by MD (the other software RAID) because it doesn’t scan the array for bad data, so bit rot and silent errors can go undetected until a process wants to read it. ZFS periodically scans the array and fixes corrupted data if possible.

    ZFS can use more CPU resources compared to MD, but the difference in performance is insignificant compared to the read bandwidth of mechanical hard drives. Memory usage is comparatively high because it uses the RAM as cache, but you can set a limit. My current 8TB RAIDZ1 array uses only 8GB of RAM and it could still be lower.

    I recommend using some dedicated OS to manage ZFS pools, like TrueNAS Scale or Proxmox.

    https://pve.proxmox.com/wiki/ZFS_on_Linux

    it’s not default in mainline linux

    It’s purely an issue of licenses. ZFS is a mature solution, and being out-of-tree does not reflect a qualitative issue. It’s available as a separate package on most distributions.

    • Shimitar@downonthestreet.eu
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      4
      ·
      7 days ago

      You cannot compare zfs to md, they are different like apples and oranges.

      MD it’s a raid device, not a filesystem.

      You should compare btrfs to zfs, they pretty much share the same capabilities and features.

      I use MD as my raid array, and btrfs on top of MD.

      Of course if you use ext4 on top of MD you get nothing of the good stuff, except a very solid array management due to md.