# ZFS Storage Architecture

# ZFS Storage Architecture

Terra utilizes ZFS for primary data storage, leveraging its advanced features for data integrity, snapshots, and caching.

## 🏊 Pools

### 🚀 `main` (SSD Pool)
*   **Hardware:** Raid-Z2 (6x 2TB SSD)
*   **Total Capacity:** ~12TB Raw
*   **Use Case:** High-performance data, VM disks, Docker root, and active AppData.
*   **L2ARC:** 48GB limit (leveraging NVMe partitions).

### 🐘 `bulk` (HDD Pool)
*   **Hardware:** Raid-Z1 (4x 12TB HDD)
*   **Total Capacity:** ~48TB Raw
*   **Use Case:** Large media storage, backups, and long-term archival.
*   **Special VDEV:** Mirrored NVMe partitions used for metadata offloading to speed up file listing on HDDs.

## 📂 Key Datasets & Mounts
*   **/srv**: Docker-compose configuration files (Stored on `main`).
*   **/main/appdata**: Primary persistent storage for containers (Stored on `main`).
*   **/bulk/pics**: Family photo/video archive (Stored on `bulk`).

## 🛡️ Health & Maintenance

### 🔍 Automated Monitoring (`smartd`)
Drive health is monitored via `smartmontools` with automated short and long self-tests configured to email results. Test schedules are staggered to prevent resource contention.

*   **NVMe (2x 500GB):** Short tests daily at 1am & 2am; Long tests quarterly on the 1st-2nd.
*   **HDD (4x 12TB):** Short tests daily at 3am-6am; Long tests on the 4th, 6th, 8th, and 10th of each month.
*   **SSD (6x 2TB):** Short tests daily from 1am-6am; Long tests quarterly on the 3rd, 5th, 7th, 9th, 11th, and 12th.

### 🧹 ZFS Scrubbing
A scrub is performed automatically on the 3rd Sunday of every month to ensure data integrity and prevent bitrot.

**Scrub Schedule (Cron):**
`24 0 15-21 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi`