Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux:zfs [2024/04/17 03:47] – admin | linux:zfs [2025/02/05 12:49] (current) – [ZFS - notification] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Linux ZFS ====== | ====== Linux ZFS ====== | ||
+ | https:// | ||
< | < | ||
<code BASH> | <code BASH> | ||
+ | # zfs pools and mount points | ||
+ | tree /dev/zvol/ | ||
+ | /dev/zvol/ | ||
+ | ├── rpool | ||
+ | ├── data | ||
+ | │ | ||
+ | │ | ||
+ | └── swap -> ../../zd16 | ||
+ | | ||
+ | zfs get all rpool/ | ||
+ | zfs set compression=off rpool/ | ||
+ | | ||
+ | zfs get compressratio | ||
+ | NAME PROPERTY | ||
+ | rpool | ||
+ | rpool/ | ||
+ | rpool/ | ||
+ | rpool/ | ||
+ | rpool/ | ||
+ | |||
+ | |||
# start trim operation | # start trim operation | ||
zpool trim rpool | zpool trim rpool | ||
Line 7: | Line 29: | ||
zpool status -t rpool | zpool status -t rpool | ||
</ | </ | ||
+ | |||
+ | ===== ZFS move - recompress ===== | ||
+ | ++++ Recompress zfs| | ||
+ | <code BASH> | ||
+ | #You basically have to rewrite every block of every file. | ||
+ | |||
+ | #A reasonably safe and simple way to do it is like this, however this | ||
+ | #assumes you have sufficient space. | ||
+ | |||
+ | #First set the new value for compression. | ||
+ | |||
+ | zfs set compression=on tank/fs | ||
+ | |||
+ | #Send a snapshot to a temporary name | ||
+ | |||
+ | zfs snapshot tank/***@1 | ||
+ | zfs send -R tank/***@1 | zfs recv -vFd tank/ | ||
+ | |||
+ | #Mark the original as readonly and send anything newly written | ||
+ | #since the 'zfs send' above started. | ||
+ | |||
+ | zfs set readonly=on tank/fs | ||
+ | zfs snapshot tank/***@2 | ||
+ | zfs send -i tank/***@1 tank/***@2 | zfs recv -v tank/ | ||
+ | |||
+ | #Now delete the original and rename the newone into its place. | ||
+ | |||
+ | zfs delete tank/fs | ||
+ | zfs rename tank/ | ||
+ | |||
+ | #Note that the new tank/fs will have all the the snapshots of | ||
+ | #the original as well since -R was used with the zfs send. | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | |||
+ | ===== ZFS - notification ===== | ||
+ | ++++ telegram notification zfs| | ||
+ | <code BASH> | ||
+ | # https:// | ||
+ | nano / | ||
+ | |||
+ | #!/bin/bash | ||
+ | TELEGRAM_BOT_TOKEN=" | ||
+ | TELEGRAM_CHAT_ID=" | ||
+ | |||
+ | subject=" | ||
+ | details=" | ||
+ | |||
+ | MESSAGE=" | ||
+ | Event: $subject | ||
+ | Details: | ||
+ | $details" | ||
+ | |||
+ | curl -s -X POST " | ||
+ | -d " | ||
+ | -d " | ||
+ | |||
+ | chmod +x / | ||
+ | |||
+ | # zed-functions.sh Modified zed_notify function | ||
+ | zed_notify() | ||
+ | { | ||
+ | zed_notify_email " | ||
+ | [ " | ||
+ | [ " | ||
+ | |||
+ | # Execute external Telegram script if it exists | ||
+ | if [ -x "/ | ||
+ | / | ||
+ | [ " | ||
+ | [ " | ||
+ | fi | ||
+ | } | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== ZFS backup ===== | ||
+ | |||
+ | <code bash> | ||
+ | # create file 20 gb | ||
+ | dd if=/ | ||
+ | # create pool on file | ||
+ | zpool create test / | ||
+ | |||
+ | |||
+ | # send data replication to local system | ||
+ | zfs send -vR rpool@snap1 | zfs receive | ||
+ | |||
+ | # send data of zpool to file | ||
+ | zfs send -vR rpool@snap1 > / | ||
+ | # recieve | ||
+ | zfs receive rpool < / | ||
+ | |||
+ | |||
+ | zpool attach rpool nvme-512GB_SSD_NJM358R015419P70GX-part3 ata-SPCC_Solid_State_Disk_AA230918S351201018-part3 | ||
+ | zpool remove rpool / | ||
+ | </ | ||
+ | |||
+ | ===== ZFS monitoring ===== | ||
+ | https:// | ||
+ | https:// | ||
+ | |||