linux:zfs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:zfs [2024/05/01 06:27] – [Linux ZFS] adminlinux:zfs [2025/02/05 12:49] (current) – [ZFS - notification] admin
Line 1: Line 1:
 ====== Linux ZFS ====== ====== Linux ZFS ======
 +https://lepkov.ru/zfs-cheatsheet/ backup https://habr.com/ru/companies/macloud/articles/547056/ \\
 <https://denisbondar.github.io/post/zfs-manual-rus/> - manual <https://xakep.ru/2014/07/08/zfs-at-home/#toc07.> old one\\ <https://denisbondar.github.io/post/zfs-manual-rus/> - manual <https://xakep.ru/2014/07/08/zfs-at-home/#toc07.> old one\\
 <code BASH> <code BASH>
Line 10: Line 11:
     │   └── vm-100-disk-1-part1 -> ../../../zd0p1     │   └── vm-100-disk-1-part1 -> ../../../zd0p1
     └── swap -> ../../zd16     └── swap -> ../../zd16
 +    
 +zfs get all rpool/data/subvol-111-disk-1  | grep com
 +zfs set compression=off rpool/data/subvol-111-disk-1
          
 zfs get compressratio zfs get compressratio
Line 59: Line 63:
 </code> </code>
 ++++ ++++
 +
 +
 +===== ZFS - notification =====
 +++++ telegram notification zfs|
 +<code BASH>
 + # https://github.com/leovp/telegram_notifications
 +nano /etc/zfs/zed.d/zed-telegram.sh
 +
 +#!/bin/bash
 +TELEGRAM_BOT_TOKEN="righttoken" # put your token here
 +TELEGRAM_CHAT_ID="chatid" # your chat_id for sending notification
 +
 +subject="$1"
 +details="$2"
 +
 +MESSAGE="🚨 ZFS Alert on $(hostname) 🚨
 +Event: $subject
 +Details:
 +$details"
 +
 +curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
 +     -d "chat_id=$TELEGRAM_CHAT_ID" \
 +     -d "text=$MESSAGE"
 +
 +chmod +x /etc/zfs/zed.d/zed-telegram.sh
 +
 +# zed-functions.sh Modified zed_notify function
 +zed_notify()
 +{
 +    zed_notify_email "${subject}" "${pathname}"; rv=$?
 +    [ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
 +    [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
 +
 +    # Execute external Telegram script if it exists
 +    if [ -x "/etc/zfs/zed.d/zed-telegram.sh" ]; then
 +        /etc/zfs/zed.d/zed-telegram.sh "${subject}" "$(cat "${pathname}")"; rv=$?
 +        [ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
 +        [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
 +    fi
 +}
 +</code>
 +++++
 +
 +
 +
 +
 +===== ZFS backup =====
 +
 +<code bash>
 +# create file  20 gb
 +dd if=/dev/zero of=/mnt/sdb3/zpool_test bs=1G count=20
 +# create pool on file 
 +zpool create test /mnt/sdb3/zpool_test
 +
 +
 +# send data replication to local  system 
 + zfs send -vR rpool@snap1 | zfs receive  test -F
 +
 +# send data of zpool to file 
 +zfs send -vR rpool@snap1 > /mnt/pve/backup/zfs-pve-rpool-20240624.backup
 +# recieve 
 +zfs receive rpool < /mnt/pve/backup/zfs-pve-rpool-20240624.backup
 +
 +
 +zpool attach rpool nvme-512GB_SSD_NJM358R015419P70GX-part3 ata-SPCC_Solid_State_Disk_AA230918S351201018-part3
 +zpool remove rpool /mnt/sdb3/zpool_mirror1_1
 +</code>
 +
 +===== ZFS monitoring =====
 +https://blog.roberthallam.org/2022/09/monitoring-zfs-with-influxdb-grafana-publishing-and-reflection-part-5/ \\
 +https://github.com/richardelling/zpool_influxdb \\
  
  
  
  
  • linux/zfs.1714544870.txt.gz
  • Last modified: 2024/05/01 06:27
  • by admin