How often should I defrag ZFS pools?

24,564

This is not something you need to so often. Mainly because there's no notion of online defragmentation in ZFS. That's really only possible by copying the pool data to another pool or rewriting to new storage. Strive to keep your zpools below 70% utilization instead.

Share:
24,564

Related videos on Youtube

Sandra
Author by

Sandra

Updated on September 18, 2022

Comments

  • Sandra
    Sandra over 1 year

    I ZFS scrub once a month which takes ~24 hours for the 72TB. For what I can find about how often I should scrub is:

    • very busy pools, once per week
    • not so busy pools, once per month

    or run a scrub, measure the time, and adjust accordingly.

    But what about online defragmention?

    Question

    Is online defragmention considered good practice like scrubbing is? And if, how often should I degrag?

    • BeowulfNode42
      BeowulfNode42 about 10 years
      Due to the way this question is worded, I feel it necessary to emphasise that a ZFS scrub does not defrag, see Nex7's comment for what a scrub does. The title asks about defrag, most of the body talks about scrub, and the last line asks about defrag, this is why I voted down this question.
  • Nex7
    Nex7 over 10 years
    I would say not /nearly/ so often. A scrub simply reads every block on the system. That's all it does. By virtue of how ZFS handles reads, ZFS will automatically repair any bad blocks when they're read. This means a scrub is only necessary to read data that isn't commonly being read anyway. Thus, the asker's comment of very busy pools once per week and not so busy pools once per month is actually backwards. A very busy pool, especially one that reads the majority of the live data regularly, need not scrub that often. A quiet pool that is rarely accessed should scrub more often.
  • Thomas
    Thomas about 7 years
    It's important to at least scrub reasonably often (or, more generally, ensure all of the drive data gets read often) because otherwise, ZFS will have no idea what the status of the data on the disk actually is, and you may find upon resilvering after a disk failure that your redundant drives contain corrupted data that went undetected due to lack of reads (and then restore your data from backup, or just lose it)
  • Admin
    Admin almost 2 years
    Why should one strive to keep the zpool below 70% utilization?
  • Admin
    Admin almost 2 years
    @lindhe The number is higher today. But above some level free-space fragmentation, performance become an issue.