-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
307 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
--- | ||
status: new | ||
description: A comical explanation of various HTTP status codes. | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
status: new | ||
description: Various notes about my usage of ZFS/OpenZFS. | ||
--- | ||
|
||
# ZFS Notes | ||
|
||
In this document, replace `worldsgrave` with the name of your zpool. | ||
|
||
## Recommended settings | ||
|
||
### Compression | ||
|
||
Use `lz4` compression, it's fast and efficient. | ||
|
||
```shell | ||
zfs set compression=lz4 worldsgrave | ||
``` | ||
|
||
### Access Time | ||
|
||
Turn off `atime`, it's useless. | ||
|
||
```shell | ||
zfs set atime=off worldsgrave | ||
``` | ||
|
||
### De-Duplication | ||
|
||
!!! warning "De-Duplication" | ||
**NEVER** use de-dupe, it's a massive performance hit. | ||
|
||
## Scheduled Scrubing | ||
|
||
Create the following files: | ||
|
||
??? example "/etc/systemd/system/zfs-scrub@.service" | ||
|
||
``` desktop | ||
[Unit] | ||
Description=zpool scrub on %i | ||
|
||
[Service] | ||
Nice=19 | ||
IOSchedulingClass=idle | ||
KillSignal=SIGINT | ||
ExecStart=/usr/sbin/zpool scrub %i | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
??? example "/etc/systemd/system/zfs-scrub@.timer" | ||
|
||
``` desktop | ||
[Unit] | ||
Description=Monthly zpool scrub on %i | ||
|
||
[Timer] | ||
OnCalendar=monthly | ||
AccuracySec=1h | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
Enable and start the new service: | ||
|
||
```shell | ||
systemctl daemon-reload | ||
systemctl enable zfs-scrub@worldsgrave.timer | ||
``` | ||
|
||
## Scheduled Snapshots | ||
|
||
Install zrepl, see [zrepl.yaml](zrepl.yaml) for reference. | ||
|
||
## Useful Commands | ||
|
||
### List datasets | ||
|
||
```shell | ||
zfs list -o type,name,available,used,logicalused,usedbysnapshots,compressratio,mountpoint | ||
``` | ||
|
||
### List snapshots | ||
|
||
```shell | ||
zfs list -t snapshot | ||
``` | ||
|
||
### Recordsize | ||
|
||
```shell | ||
zfs get recordsize -t filesystem | ||
``` | ||
|
||
### Aliases | ||
|
||
``` shell | ||
alias zls="zfs list -o type,name,available,used,logicalused,usedbysnapshots,compressratio,mountpoint"+ | ||
alias zsl="zfs list -t snapshot" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
global: | ||
logging: | ||
# use syslog instead of stdout because it makes journald happy | ||
- type: syslog | ||
format: human | ||
level: warn | ||
monitoring: | ||
# Maker prometheus metrics available for scraping | ||
- type: prometheus | ||
listen: ":9811" | ||
listen_freebind: true # Enabled, so that zrepl will listen on all IPs, even if they are bound after zrepl starts | ||
|
||
# see /usr/share/doc/zrepl/examples | ||
# or https://zrepl.github.io/configuration/overview.html | ||
# or https://zrepl.github.io/quickstart/backup_to_external_disk.html | ||
|
||
jobs: | ||
# snapshot creation + pruning for worldsgrave | ||
- name: worldsgrave_snapshots | ||
type: snap | ||
filesystems: { | ||
"worldsgrave<": true, | ||
"worldsgrave/zrepl<": false, # Don't snapshot snapshots from rpool, that would be super dumb | ||
"worldsgrave/k8s<": false, # Dont' snapshot k8s PVs, the ZFS operator will do that as needed | ||
"worldsgrave/timemachine<": false, # Don't snapshot timemachine backups, that would also be dumb | ||
} | ||
# create snapshots with prefix `zrepl_` every 15 minutes | ||
snapshotting: | ||
type: periodic | ||
interval: 15m | ||
prefix: zrepl_ | ||
pruning: | ||
keep: | ||
# Fade-out scheme for snapshots starting with `zrepl_` | ||
# - Keep all created in the last hour | ||
# - Keep 24 each 1 hour apart | ||
# - Keep 14 each 1 day apart | ||
# - All older snapshots will be destroyed unless other keep rules apply to them | ||
- type: grid | ||
grid: 1x1h(keep=all) | 24x1h | 14x1d | ||
regex: "^zrepl_.*" | ||
# Keep all snapshots that don't have the `zrepl_` prefix | ||
# This protects manually created snapshots from being pruned by zrepl | ||
- type: regex | ||
negate: true | ||
regex: "^zrepl_.*" | ||
|
||
# Provide a destination on worldsgrave for snapshots from rpool | ||
- name: "worldsgrave_sink" | ||
type: sink | ||
root_fs: "worldsgrave/zrepl" | ||
serve: | ||
type: local | ||
listener_name: localsink | ||
|
||
# Backup root snapshots to worldsgrave | ||
- name: "backup_root" | ||
type: push | ||
connect: | ||
type: local | ||
listener_name: localsink | ||
client_identity: backup_root | ||
filesystems: { | ||
"rpool<": true, | ||
"rpool/k3s_agent<": false, # Don't snapshot the k3s agent zvol, it's not needed | ||
"rpool/k8s<": false, # Dont' snapshot k8s PVs, the ZFS operator will do that as needed | ||
} | ||
# Create snapshots with prefix `zrepl_` every 30 minutes | ||
snapshotting: | ||
type: periodic | ||
interval: 30m | ||
prefix: zrepl_ | ||
pruning: | ||
keep_sender: | ||
# Keep any snapshots on rpool that haven't been replicated to worldsgrave/zrepl yet | ||
- type: not_replicated | ||
# Fade-out scheme for snapshots starting with `zrepl_` on rpool | ||
# - Keep all created in the last hour | ||
# - Keep 24 each 1 hour apart | ||
# - All older snapshots will be destroyed unless other keep rules apply to them | ||
- type: grid | ||
grid: 1x1h(keep=all) | 24x1h | ||
regex: "zrepl_.*" | ||
# Keep all snapshots that don't have the `zrepl_` prefix | ||
- type: regex | ||
negate: true | ||
regex: "^zrepl_.*" | ||
keep_receiver: | ||
# Fade-out scheme for snapshots starting with `zrepl_` on worldsgrave/zrepl | ||
# - Keep 14 each 1 day apart | ||
# - All older snapshots will be destroyed unless other keep rules apply to them | ||
- type: grid | ||
grid: 14x1d | ||
regex: "zrepl_.*" | ||
# Keep all snapshots that don't have the `zrepl_` prefix | ||
# This protects manually created snapshots from being pruned by zrepl | ||
- type: regex | ||
negate: true | ||
regex: "^zrepl_.*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.