Zfs 标志

Zfs

社区
jmagar
zfs

This skill should be used when managing ZFS pools in a homelab environment with multiple devices. It handles pool health monitoring, snapshot management with Sanoid/Syncoid, automated replication between devices, dataset property optimization, scrub scheduling, and error recovery. Use when the user asks to "check ZFS pool health", "setup ZFS replication", "configure ZFS snapshots", "optimize ZFS performance", "troubleshoot ZFS issues", "schedule ZFS scrubs", "check pool capacity", "setup Sanoid", or mentions ZFS-related tasks. CRITICAL: This skill enforces MANDATORY double confirmation for ALL destructive operations.

Add to TypingMind

概览

发布者jmagar
代码仓库claude-homelab
技能名称zfs
星标数
87
复刻数
11
附带文件
10
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 10 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 jmagar 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Zfs AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/jmagar/claude-homelab/tree/main/skills/zfs
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jmagar/claude-homelab.git /tmp/claude-homelab
mkdir -p .claude/skills
cp -r /tmp/claude-homelab/skills/zfs .claude/skills/zfs
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Zfs,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Zfs。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Zfs 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

ZFS Homelab Management

⚠️ MANDATORY SKILL INVOCATION ⚠️

YOU MUST invoke this skill (NOT optional) when the user mentions ANY of these triggers:

  • "check ZFS pool health", "ZFS status", "pool health", "zpool status"
  • "setup ZFS replication", "configure replication", "sync ZFS datasets"
  • "configure ZFS snapshots", "setup Sanoid", "snapshot retention"
  • "optimize ZFS performance", "tune ZFS properties", "ZFS compression"
  • "troubleshoot ZFS", "ZFS errors", "failed replication", "degraded pool"
  • "schedule ZFS scrubs", "setup scrubbing", "monthly scrub"
  • "check pool capacity", "pool space", "ZFS disk usage"
  • Any mention of ZFS, Sanoid, Syncoid, zrepl, raidz1, or ZFS datasets

Failure to invoke this skill when triggers occur violates your operational requirements.

Purpose

Comprehensive ZFS management for homelab environments with multi-device replication, automated snapshot management, performance optimization, and health monitoring.

Read-Write Operations: This skill performs both monitoring (read-only) and management (read-write) operations including:

  • Pool health checks and monitoring
  • Snapshot creation and pruning
  • Dataset replication between devices
  • Property optimization
  • Scrub scheduling

Recommended Architecture: Pull-based replication from centralized backup server to 5 source devices.

Based on research: Synthesized from 130+ URLs, 56,000+ vector database entries, and official OpenZFS/Oracle/FreeBSD documentation.

🚨 DESTRUCTIVE OPERATIONS - CRITICAL SAFETY PROTOCOL

ABSOLUTE REQUIREMENT: NO DESTRUCTIVE COMMANDS WITHOUT EXPLICIT USER AUTHORIZATION AND DOUBLE CONFIRMATION

This section defines the MANDATORY safety protocol that MUST be followed for ALL destructive ZFS operations.

Destructive Command Categories

EXTREMELY DESTRUCTIVE (Permanent Data Loss):

  • zfs destroy - Permanently destroys datasets/snapshots (UNRECOVERABLE)
  • zfs destroy -R - Recursively destroys all snapshots and child datasets (CATASTROPHIC)
  • zpool destroy - Destroys entire pool and all data (CATASTROPHIC)
  • zfs rollback - Rolls back to snapshot, LOSING all intermediate changes (DATA LOSS)
  • zpool labelclear - Removes ZFS labels, makes data inaccessible (DATA LOSS)

HIGHLY DESTRUCTIVE (Configuration/Availability Loss):

  • zpool remove - Removes vdev from pool (CANNOT BE UNDONE)
  • zpool detach - Detaches mirror device (removes redundancy)
  • zpool offline - Takes disk offline (reduces pool availability)
  • zpool replace - Replaces disk in pool (requires resilver)
  • zpool clear - Clears pool errors (can mask real problems)

MODERATELY DESTRUCTIVE (Cleanup Operations):

  • sanoid --prune-snapshots - Deletes old snapshots per retention policy
  • syncoid --no-sync-snap - Deletes snapshots on destination
  • zpool scrub -s - Stops in-progress scrub (interrupts data verification)

POTENTIALLY IRREVERSIBLE (Property Changes):

  • zfs set recordsize= - CANNOT be changed efficiently on existing data
  • zfs set compression= - Only affects new data, not existing
  • zfs inherit - Resets properties to inherited values (loses custom settings)

MANDATORY CONFIRMATION PROTOCOL

YOU MUST FOLLOW THIS PROTOCOL FOR ALL DESTRUCTIVE OPERATIONS:

  1. User Request Required - NEVER suggest or execute destructive commands unprompted
  2. Explicit Command Presentation - Show the EXACT command that will be executed
  3. Impact Explanation - Clearly explain what will be destroyed/lost/changed
  4. Backup Verification - Confirm backups exist before proceeding
  5. Double Confirmation - Require user to confirm TWICE:
    • First: "Do you want to execute this destructive operation?"
    • Second: "Are you absolutely sure? This cannot be undone."
  6. Dry-Run When Possible - Use --dry-run or -n flags if available
  7. Manual Execution Only - Provide command for user to run manually, DO NOT execute automatically

Safety Examples

WRONG - NEVER DO THIS:

markdown
User: "I have too many snapshots"
Assistant: "Let me clean those up for you."
[Executes: sanoid --prune-snapshots]  ❌ NO CONFIRMATION

CORRECT - ALWAYS DO THIS:

markdown
User: "I have too many snapshots"
Assistant: "I can help you prune old snapshots. First, let me check what would be deleted:

Command: sanoid --prune-snapshots --verbose --dry-run

This will show which snapshots would be removed based on your retention policy in /etc/sanoid/sanoid.conf.

⚠️ WARNING: This is a DESTRUCTIVE operation. Deleted snapshots cannot be recovered.

Before proceeding:
1. Have you verified your retention policy is correct?
2. Do you have backups of critical data?
3. Are you sure you want to permanently delete old snapshots?

If yes, I'll provide the command for you to run manually."

[User confirms twice]

Assistant: "Here is the command to run manually:

```bash
sudo sanoid --prune-snapshots --verbose

⚠️ FINAL WARNING: This will PERMANENTLY DELETE old snapshots. Are you absolutely sure?"

[User confirms a second time: "Yes, delete them"]

Assistant: "Understood. Please run the command above. I cannot execute destructive operations automatically."


### Safe Operations (No Confirmation Needed)

These operations are read-only and safe to execute:
- `./scripts/pool-health.sh` - Pool health checks
- `zpool status` - View pool status
- `zfs list` - List datasets/snapshots
- `zpool list` - List pools
- `zfs get all` - View properties
- `sanoid --verbose --dry-run` - Preview snapshot operations
- `syncoid --dry-run` - Preview replication

## Setup

This skill uses ZFS commands directly and does not require additional credentials beyond SSH access for remote replication.

**Required for remote replication:**

Remote replication requires passwordless SSH authentication between the backup server and source devices. This allows Syncoid to pull snapshots automatically without manual intervention.

1. **SSH keys configured** (passwordless authentication):
   ```bash
   # Generate SSH key on backup server
   ssh-keygen -t ed25519 -C "zfs-replication"

   # Copy to each source device
   ssh-copy-id user@device1
   ssh-copy-id user@device2
   # ... repeat for all devices

   # Test connectivity
   ssh user@device1 echo "SSH working"
  1. ZFS delegation (for non-root replication):

    bash
    # On backup server
    zfs allow -u replication-user create,mount,receive backup/device1
  2. Sanoid/Syncoid installed (for automation):

    bash
    sudo apt install sanoid  # Debian/Ubuntu
    sudo pkg install sanoid  # FreeBSD

See README.md for detailed setup instructions.

Commands

Pool Health Check

bash
# Check all pools
./scripts/pool-health.sh

# Check specific pool
./scripts/pool-health.sh tank

# JSON output for monitoring
./scripts/pool-health.sh --json

Snapshot Management (Sanoid)

bash
# Configure Sanoid
cp assets/sanoid.conf.template /etc/sanoid/sanoid.conf
sudo nano /etc/sanoid/sanoid.conf

# Manual snapshot
sudo sanoid --take-snapshots --verbose

# Manual prune
sudo sanoid --prune-snapshots --verbose

# List snapshots
zfs list -t snapshot

Replication Setup (Syncoid)

bash
# Manual replication (pull-based)
syncoid --recursive user@device1:tank backup/device1

# With options
syncoid \
  --recursive \
  --no-privilege-elevation \
  --identifier=device1 \
  --compress=zstd-fast \
  user@device1:tank backup/device1

Property Optimization

bash
# Enable compression (always)
zfs set compression=lz4 pool/dataset

# Disable atime
zfs set atime=off pool/dataset

# Tune recordsize (workload-specific)
zfs set recordsize=8K pool/databases     # Databases
zfs set recordsize=1M pool/media         # Large files
zfs set recordsize=128K pool/data        # Default

Scrub Scheduling

bash
# Manual scrub
zpool scrub poolname

# Check scrub status
zpool status poolname

# Pause scrub
zpool scrub -p poolname

# Add to cron (monthly)
0 2 * * 0 [ $(date +\%d) -le 7 ] && /usr/sbin/zpool scrub tank

Workflow

When user asks about ZFS pool health:

  1. "Check my ZFS pools" → Run ./scripts/pool-health.sh
  2. "Is my pool degraded?" → Run zpool status -v poolname
  3. "When was the last scrub?" → Check pool health script output
  4. "Pool capacity warnings" → Check capacity (warn at 70%, critical at 80%)

When user asks about ZFS replication:

  1. "Setup replication from 5 devices" → Configure pull-based syncoid jobs with staggered scheduling
  2. "Replicate device1 now" → Run syncoid command
  3. "Failed replication" → Check for resume tokens, consult troubleshooting guide
  4. "Check replication status" → Review logs: grep syncoid /var/log/syslog | tail -20

When user asks about snapshots:

  1. "Setup automated snapshots" → Copy sanoid.conf template, configure retention policy, add to cron
  2. "List snapshots" → Run zfs list -t snapshot (SAFE - read-only)
  3. "Restore from snapshot" → ⚠️ DESTRUCTIVE - Use zfs rollback or zfs clone (REQUIRES DOUBLE CONFIRMATION)
  4. "Too many snapshots" → ⚠️ DESTRUCTIVE - Run sanoid --prune-snapshots (REQUIRES DOUBLE CONFIRMATION, use --dry-run first)

When user asks about performance:

  1. "Optimize ZFS" → Check compression, atime, recordsize settings
  2. "Slow writes" → Check capacity (>80% impacts performance), consider adding SLOG
  3. "Tune for databases" → Set recordsize=8K, enable lz4 compression

Detailed Flow for Multi-Device Replication Setup

  1. Install Sanoid on all 5 devices + backup server
  2. Configure short retention on sources (24 hourly only)
  3. Configure pull-based syncoid on backup server:
    • Stagger devices by 15-20 minutes
    • Use --identifier flag per device
    • Enable compression with --compress=zstd-fast
  4. Setup ZFS delegation for non-root operation
  5. Add to cron with staggered schedule
  6. Test manual run before enabling automation

References

scripts/

scripts/pool-health.sh - Comprehensive pool health checker with JSON output support. Checks state, capacity, scrub status, and generates alerts.

references/

references/command-reference.md - Complete ZFS command syntax reference for zpool, zfs, sanoid, and syncoid commands with parameters and examples.

references/quick-reference.md - Quick command cheatsheet for common ZFS operations.

references/troubleshooting.md - Comprehensive troubleshooting guide covering:

  • Common replication failures (network, space, permissions, conflicts)
  • Pool health issues (degraded pools, high capacity, scrub errors)
  • Performance problems (slow writes/reads)
  • SSH/network issues
  • Recovery procedures
  • Decision trees for diagnostics

Load this reference when user encounters errors or requests troubleshooting assistance.

assets/

assets/sanoid.conf.template - Sanoid configuration template with homelab-optimized retention policies ready to copy to /etc/sanoid/sanoid.conf.

Notes

🚨 CRITICAL SAFETY REMINDER

ALL DESTRUCTIVE COMMANDS REQUIRE:

  1. Explicit user request
  2. Exact command shown to user
  3. Impact explanation
  4. First confirmation
  5. Second confirmation
  6. Manual execution (commands provided to user, NEVER auto-executed)

NEVER execute these commands automatically:

  • zfs destroy - Permanent data loss
  • zpool destroy - Catastrophic data loss
  • zfs rollback - Loses intermediate changes
  • sanoid --prune-snapshots - Deletes snapshots permanently
  • Any command that modifies, removes, or destroys data

See "🚨 DESTRUCTIVE OPERATIONS - CRITICAL SAFETY PROTOCOL" section above for complete details.

RAIDZ1 Critical Warnings

  • Single parity - Can tolerate only 1 disk failure
  • Two disk failures = complete data loss
  • Monitor SMART data aggressively
  • Monthly scrubs MANDATORY for data integrity
  • Consider migrating to RAIDZ2 for critical data

Pool Capacity Thresholds

  • <70%: Optimal performance
  • 70%: Warning (performance may degrade)
  • 80%: Critical (fragmentation increases)
  • 90%: Emergency (severe write degradation)
  • >95%: Risk of pool exhaustion

Important Concepts

  • Backup does NOT replace scrubbing - Both are required
  • Set recordsize BEFORE writing data - Cannot change efficiently after
  • NEVER enable dedup in homelab - Requires 5GB RAM per TB
  • LZ4 compression is always beneficial - Minimal overhead, often improves performance

Security Considerations

For production deployments:

  • Use dedicated replication user (not root)
  • Implement SSH key restrictions
  • Use ZFS delegation for non-root replication
  • Firewall rules limiting SSH to backup server IP

Reference

Official Documentation:

Automation Tools:

Additional Resources:

  • references/command-reference.md - Complete ZFS command syntax
  • references/quick-reference.md - Quick command cheatsheet
  • references/troubleshooting.md - Detailed troubleshooting guide

🔧 Agent Tool Usage Requirements

CRITICAL: When invoking scripts from this skill via the zsh-tool, ALWAYS use pty: true.

Without PTY mode, command output will not be visible even though commands execute successfully.

Correct invocation pattern:

typescript
<invoke name="mcp__plugin_zsh-tool_zsh-tool__zsh">
<parameter name="command">./skills/zfs/scripts/pool-health.sh [args]</parameter>
<parameter name="pty">true</parameter>
</invoke>

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Zfs AI 技能有什么作用?

This skill should be used when managing ZFS pools in a homelab environment with multiple devices. It handles pool health monitoring, snapshot management with Sanoid/Syncoid, automated replication between devices, dataset property optimization, scrub scheduling, and error recovery. Use when the user asks to "check ZFS pool health", "setup ZFS replication", "configure ZFS snapshots", "optimize ZFS performance", "troubleshoot ZFS issues", "schedule ZFS scrubs", "check pool capacity", "setup Sanoid", or mentions ZFS-related tasks. CRITICAL: This skill enforces MANDATORY double confirmation for...

为什么在 TypingMind 中使用 Zfs?

因为您只需安装一次,就能搭配任何模型使用。Zfs 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Zfs?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/jmagar/claude-homelab/tree/main/skills/zfs。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Zfs?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Zfs 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Zfs 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Zfs AI 技能免费吗?

是的。jmagar 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇