How to Fix a Nearly Full ZFS Pool

ZFS pools work best when kept below 80% capacity, but what if your TrueNAS system has exceeded this limit? A full ZFS pool can lead to performance degradation, slow writes, and inefficient space allocation. Fortunately, there are several solutions to address this problem. This guide will walk you through various methods to free up space, optimize storage, and expand your pool if necessary.

Problem: The Pool Is Almost Full

Solution 1: Expanding the Pool

If you have additional drives available, the best long-term solution is to expand your ZFS pool.

How to Expand the Pool:

  • Add a New VDEV: If your pool consists of a single vdev, you can add a new vdev to increase capacity.
    • In TrueNAS, navigate to Storage > Pools and select your pool.
    • Click Add VDEV and follow the prompts to add more drives.
    • Keep in mind that vdevs cannot be removed once added.
  • Replace Drives with Larger Ones: If your pool uses mirrors, you can upgrade to larger disks one at a time.
    • Replace a drive with a larger one and allow resilvering to complete.
    • Repeat the process for all drives, after which ZFS will allow expanding the pool size.

Solution 2: Enable Compression and Optimize Data Storage

ZFS has built-in compression that can help reclaim space without deleting data, reducing storage requirements without impacting performance.

How to Enable Compression:

  1. Go to Storage > Pools in the TrueNAS GUI.
  2. Click on the dataset you want to compress.
  3. Under Edit Options, find the Compression setting and choose lz4 (a fast and efficient algorithm).
  4. Click Save to apply.

This will only compress newly written data, meaning existing files will remain uncompressed. To apply compression to existing data, you can move files to another dataset or vdev and back.

How to Apply Compression to Existing Data:

  1. Create a New VDEV: If you have added a new vdev for expansion, enable compression on it before moving data.
  2. Move Files to the New VDEV: Copy files from the original dataset to the new dataset on the second vdev. This will cause ZFS to rewrite the files, now applying compression.
  3. Delete the Original Copies: Once the files have been successfully copied and verified, delete the original uncompressed files to free up space.

This process not only ensures that existing data is compressed, but it can also help reduce fragmentation, improving overall read and write performance.

Solution 3: Delete Old Snapshots

Snapshots preserve historical versions of data but can consume a lot of space.

How to Delete Snapshots:

  1. Open Storage > Snapshots in TrueNAS.
  2. Identify snapshots that are no longer needed.
  3. Select them and click Delete.

If you have automated snapshots enabled, consider adjusting the retention policy to avoid excessive accumulation.

Solution 4: Remove Unused or Large Files

Unused or temporary files can contribute significantly to storage usage.

How to Identify Large Files:

  • Use the command du -sh /* in the TrueNAS shell to find large directories.
  • Check dataset usage with zfs list.
  • Use find /mnt/tank -type f -size +1G to locate files larger than 1GB.

How to Delete Files:

  • Manually delete unnecessary files via the TrueNAS file explorer or shell (rm -rf /path/to/file).
  • Empty the .recycle folders if using SMB shares.

Solution 5: Offload Data to Another System

If deleting data is not an option, consider moving infrequently used files to another storage device.

How to Offload Data:

  • Use rsync or scp to copy files to a backup server.
  • Archive old data onto an external USB or another network share.

Conclusion

If your ZFS pool is nearing or exceeding 80% capacity, taking action quickly can prevent performance issues and potential system instability. By expanding storage, enabling compression, deleting unnecessary data, and offloading files, you can reclaim space and maintain a healthy TrueNAS system. Regular monitoring and proactive management will help prevent future overfill situations and keep your ZFS pool running efficiently.

Similar Posts