How to Set Quota Limits for Home Folders (User Quota Setup Guide)
In this video, you’ll learn how to configure quota limits for user home folders on TrueNAS using ZFS. We explain the difference between dataset quotas and user quotas so you can choose the right method. You’ll see how to apply and adjust limits to prevent users from consuming excessive storage. The guide also covers recommended quota settings for SMB environments with Active Directory. We show how to verify quota usage, monitor capacity, and troubleshoot common issues. Quotas are essential for maintaining system performance and avoiding unexpected disk full errors. This setup helps IT admins manage user data efficiently and securely. Watch the full guide to implement a stable and well-controlled storage environment on TrueNAS.
Step 0: Set data total for Dataset Homefolder (option)
Step 1: Get the list of Homefolder users
On AD, open powershell and run the command to get username/OU
Get-ADUser -Filter * -Properties DistinguishedName |
Select-Object SamAccountName,
@{Name=”OU”;Expression={($_.DistinguishedName -replace ‘^CN=[^,]+,’, ”)}} |
Export-Csv “C:\ad_user_with_ou.csv” -NoTypeInformation -Encoding UTF8
Step 2: Create csv file to import
Create 2 columns username,quota_gib
Here you can filter departments, or users that need to assign quota, in this demo I will assign quota to 2 normal users, but the admin user it01 is not limited
Note: CSV must be UTF-8, No quotes, Comma as separator
Copy file quota.csv to /home/admin
Check file: cat /home/admin/quota.csv
sale01,1
hr01,2
Step 3: Create standard Python Script for TrueNAS (set_quota.py)
Create file:
sudo nano /home/admin/set_quota.py
Full content:
#!/usr/bin/env python3
import csv
import subprocess
# Dataset chứa Homefolder
DATASET = “volume1/Homefolder” # Name dataset apply
CSV_FILE = “/home/admin/quota.csv” # Link file quota.csv
DOMAIN = “TSF” # your domain
def gib_to_bytes(gib_value):
return int(float(gib_value) * 1024**3)
with open(CSV_FILE) as f:
reader = csv.DictReader(f)
for row in reader:
username = row[“username”].strip()
quota_gib = row[“quota_gib”].strip()
user_quota_bytes = gib_to_bytes(quota_gib)
# user format: TSF\username
zfs_user = f”{DOMAIN}\\{username}”
# zfs command:
cmd = [
“zfs”, “set”,
f”userquota@{zfs_user}={user_quota_bytes}”,
DATASET
]
print(“Running: “, ” “.join(cmd))
subprocess.run(cmd)
Step 4: Grant permission to run the file and execute
Grant permission to run
sudo chmod +x /home/admin/set_quota.py
Run the script
sudo /home/admin/set_quota.py
Done