Limit ZFS ARC Size for Apps Needing RAM
This guide shows you how to cap the ZFS Adaptive Replacement Cache (ARC) so your other applications can get the memory they need. You’ll set a maximum size for the ARC, either permanently or just for the current session, and verify the change took effect. You’ll need root or sudo access to your system and the ZFS command-line tools installed.
What You’ll Need
- Root or sudo access to the system running ZFS.
- The
zfsandzpoolcommand-line tools (usually installed with ZFS). - Knowledge of how much RAM you want to dedicate to the ARC (a good starting point is 1–2 GB on a desktop, or 10–20% of total RAM on a server).
Step-by-Step
- Check the current ARC size. Run
arcstatorcat /proc/spl/kstat/zfs/arcstatsto see the currentc(ARC target size) andc_max(maximum ARC size) values. This tells you what you’re working with before you change anything. - Set a temporary limit for the current session. Use the
zfsmodule parameter to set the maximum ARC size in bytes. For example, to limit it to 2 GB (2,147,483,648 bytes):echo 2147483648 > /sys/module/zfs/parameters/zfs_arc_max
This change is immediate but resets on reboot.
- Make the limit permanent. Edit the ZFS module configuration file. On most Linux systems, create or edit
/etc/modprobe.d/zfs.confand add:options zfs zfs_arc_max=2147483648
Then update the initramfs (on Debian/Ubuntu:
sudo update-initramfs -u; on RHEL/Fedora:sudo dracut --force) and reboot for it to take effect. - Alternatively, set the limit via the zfs command (if your system supports it). Some ZFS versions allow setting it at runtime with:
sudo zfs set zfs_arc_max=2147483648
This is not supported everywhere, so check your ZFS version first.
- Verify the change. Run
cat /sys/module/zfs/parameters/zfs_arc_maxto confirm the value is set. Also checkarcstatto see the newc_maxvalue. - If you want to also limit the minimum ARC size (to prevent it from shrinking too much), set
zfs_arc_minsimilarly. For example, to keep at least 512 MB:echo 536870912 > /sys/module/zfs/parameters/zfs_arc_min
And add the same to
/etc/modprobe.d/zfs.conffor permanence. - Monitor memory usage. Use
free -horhtopto see how much RAM is now available to your applications. Adjust the ARC limit up or down as needed.
Common Mistakes
- Using MB instead of bytes. The
zfs_arc_maxparameter expects bytes, not megabytes or gigabytes. A value like2048will set the ARC to 2 KB, not 2 GB. - Forgetting to update initramfs. If you edit
/etc/modprobe.d/zfs.confbut don’t runupdate-initramfs(or equivalent), the change won’t survive a reboot. - Setting the limit too low. If you set the ARC to a tiny value, ZFS performance will drop significantly, and you may see high I/O wait times. Keep it at least a few hundred MB for any real workload.
- Confusing
zfs_arc_maxwithzfs_arc_meta_limit. The latter only limits the metadata portion of the ARC, not the whole cache.
Tips
- Use a percentage of RAM. A common starting point is 50% of total RAM for the ARC on a dedicated ZFS server, but for a desktop or mixed workload, 1–2 GB is often enough.
- Test with a temporary limit first. Before making a permanent change, set the limit at runtime and observe your system for a day. If performance is acceptable, then make it permanent.
- Combine with other ZFS memory tunables. If you’re still short on RAM, consider reducing
zfs_arc_meta_limit(default is 75% of ARC) orzfs_dirty_data_maxto lower memory pressure. - Use
arcstatto see real usage. Thecvalue shows the current target, andc_maxshows the maximum. Ifcis well belowc_max, your limit is not the bottleneck.
Troubleshooting
Change doesn’t stick after reboot. Check that /etc/modprobe.d/zfs.conf is correctly formatted and that you ran the initramfs update. Also verify that no other configuration file overrides it (e.g., /etc/modprobe.d/*.conf).
ARC size still shows the old value. The c_max value in arcstat may not update immediately. Wait a few seconds and check again. If it still doesn’t change, the module parameter may be read-only on your system; you may need to use the zfs set command or reboot.
System becomes unstable after setting a very low limit. If you set the ARC too low, ZFS may fail to allocate enough memory for its internal structures. Reboot to reset the parameter, then set a more reasonable limit.
Applications still don’t get enough RAM. The ARC is only one part of memory usage. Check for other memory consumers like page cache, and consider adjusting vm.swappiness or using cgroups to limit other processes.
Frequently Asked Questions
What is the default maximum ARC size?
On Linux, the default is typically 1/8 of physical RAM, up to a maximum of 16 GB. This is why ZFS can consume a lot of memory on systems with large amounts of RAM.
Can I set the ARC limit per pool?
No, the ARC is a global cache shared across all pools. The limit applies to the entire ZFS subsystem, not individual pools.
Will limiting the ARC slow down my storage?
Yes, a smaller ARC means fewer cache hits, so read operations may be slower. But if your applications need the RAM, the trade-off can be worth it. You can tune the limit to balance performance and memory availability.
How do I know how much RAM the ARC is actually using?
Run arcstat and look at the size field. This shows the current size of the ARC in bytes. You can also use arc_summary to get a human-readable breakdown.
Is there a way to disable the ARC entirely?
Yes, set zfs_arc_max to 0. However, this is not recommended because ZFS will still need some memory for metadata, and performance will suffer dramatically. It’s better to set a small but non-zero limit.
Does this work on FreeBSD or macOS?
The module parameter path is Linux-specific. On FreeBSD, you can set vfs.zfs.arc_max via sysctl or in /boot/loader.conf. On macOS (if using ZFS via a third-party driver), the method varies; check your driver’s documentation.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.