This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
public:it:zfs [2022/11/20 22:27] – [zfs snapshots - show space used] phil | public:it:zfs [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ZFS ====== | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * https:// | ||
- | * [[https:// | ||
- | * https:// | ||
- | * https:// | ||
- | * [[https:// | ||
- | * https:// | ||
- | * [[https:// | ||
- | * https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * https:// | ||
- | * https:// | ||
- | |||
- | |||
- | ===== Encryption ===== | ||
- | |||
- | * [[https:// | ||
- | * https:// | ||
- | * https:// | ||
- | * https:// | ||
- | * https:// | ||
- | * https:// | ||
- | * https:// | ||
- | |||
- | < | ||
- | dataset=" | ||
- | keyname=" | ||
- | |||
- | b=/ | ||
- | p=$b/ | ||
- | |||
- | mkdir -p $b | ||
- | |||
- | dd if=/ | ||
- | |||
- | zfs create \ | ||
- | -o encryption=on \ | ||
- | -o keylocation=file:// | ||
- | -o keyformat=raw \ | ||
- | tank/ | ||
- | </ | ||
- | |||
- | / | ||
- | < | ||
- | [Unit] | ||
- | Description=Load ZFS keys | ||
- | DefaultDependencies=no | ||
- | Before=zfs-mount.service | ||
- | After=zfs-import.target | ||
- | Requires=zfs-import.target | ||
- | |||
- | [Service] | ||
- | Type=oneshot | ||
- | RemainAfterExit=yes | ||
- | ExecStart=/ | ||
- | |||
- | [Install] | ||
- | WantedBy=zfs-mount.service | ||
- | </ | ||
- | |||
- | |||
- | [[ https:// | ||
- | < | ||
- | # systemd-escape --path " | ||
- | dozer-nextcloud-data | ||
- | </ | ||
- | |||
- | Note that the '' | ||
- | < | ||
- | # systemctl enable zfs-load-key@$(systemd-escape --path " | ||
- | Created symlink / | ||
- | </ | ||
- | |||
- | ==== Adding key to encrypted dataset recursively ==== | ||
- | |||
- | < | ||
- | zfs list -r tank/vault -H -o name | while read line; do | ||
- | zfs set keylocation=file:/// | ||
- | zfs load-key " | ||
- | done | ||
- | </ | ||
- | |||
- | ===== My Bug Fixes ===== | ||
- | |||
- | * https:// | ||
- | |||
- | ===== PostgresQL on ZFS ===== | ||
- | |||
- | * https:// | ||
- | * [[https:// | ||
- | |||
- | ===== Replace a drive ===== | ||
- | It's just two commands. There are many ways to specify the drive. | ||
- | |||
- | The general format is: '' | ||
- | |||
- | < | ||
- | zfs offline tank ata-ST3300831A_5NF0552X | ||
- | </ | ||
- | Now physically replace the drive. | ||
- | < | ||
- | zfs replace tank ata-ST3300831A_5NF0552X / | ||
- | </ | ||
- | |||
- | Check the status of the zpool. You will see output that says the drive is being replaced. | ||
- | < | ||
- | zpool status | ||
- | </ | ||
- | |||
- | 1: https:// | ||
- | |||
- | ===== IO Error ===== | ||
- | As an FYI about what to do about this. | ||
- | |||
- | > On 01/29/2018 01:12 PM, root wrote: | ||
- | > ZFS has detected an io error: | ||
- | > | ||
- | > eid: 295 | ||
- | > | ||
- | > host: backup1 | ||
- | > time: 2018-01-29 13: | ||
- | > | ||
- | > | ||
- | > | ||
- | > | ||
- | > read: 0 | ||
- | > | ||
- | > pool: tank | ||
- | |||
- | < | ||
- | root at backup1:~# zpool status | ||
- | pool: tank | ||
- | | ||
- | status: One or more devices has experienced an unrecoverable error. | ||
- | attempt was made to correct the error. | ||
- | action: Determine if the device needs to be replaced, and clear the errors | ||
- | using 'zpool clear' or replace the device with 'zpool replace' | ||
- | see: http:// | ||
- | scan: scrub repaired 36K in 82h10m with 0 errors on Wed Jan 17 10:34:24 2018 | ||
- | config: | ||
- | |||
- | NAME STATE READ WRITE CKSUM | ||
- | tank ONLINE | ||
- | raidz2-0 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX11DA40HCD2 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D1404379 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NV9YL | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NVAAC | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NVAE9 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A28YZ | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2AZK | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2H5K | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2KTJ | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2NU9 | ||
- | |||
- | errors: No known data errors | ||
- | </ | ||
- | |||
- | 1. The link (http:// | ||
- | |||
- | 2. root at backup1:~# smartctl -a / | ||
- | SMART values 5, | ||
- | |||
- | 3. ZFS did recover, so there doesn' | ||
- | < | ||
- | root at backup1:~# zpool clear tank ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2NU9 | ||
- | root at backup1:~# zpool status | ||
- | pool: tank | ||
- | | ||
- | scan: scrub repaired 36K in 82h10m with 0 errors on Wed Jan 17 10:34:24 2018 | ||
- | config: | ||
- | |||
- | NAME STATE READ WRITE CKSUM | ||
- | tank ONLINE | ||
- | raidz2-0 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX11DA40HCD2 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D1404379 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NV9YL | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NVAAC | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX21D65NVAE9 | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A28YZ | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2AZK | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2H5K | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2KTJ | ||
- | ata-WDC_WD60PURX-64LZMY0_WD-WX31D65A2NU9 | ||
- | |||
- | errors: No known data errors | ||
- | </ | ||
- | |||
- | 4. If errors keep happening to this particular drive ZFS will mark it as faulty, and when/if that happens we just replace the disk. | ||
- | |||
- | |||
- | More info: | ||
- | |||
- | Looking at the previous emails we have the following IO errors reported by ZED on backup1. | ||
- | < | ||
- | 2018-01-29: / | ||
- | 2018-03-14: / | ||
- | 2018-04-10: / | ||
- | 2018-05-10: / | ||
- | 2018-05-17: / | ||
- | </ | ||
- | |||
- | Taking this last IO error as an example: | ||
- | < | ||
- | root@backup1: | ||
- | 5 Reallocated_Sector_Ct | ||
- | 197 Current_Pending_Sector | ||
- | 198 Offline_Uncorrectable | ||
- | </ | ||
- | |||
- | Because SMART values differ from drive to drive / manufacturer to manufacturer interpreting SMART values is HARD! Based on the Backblaze data releases we can use the SMART values 5, | ||
- | |||
- | Probably we are dealing with firmware that isn't optimized for how we are using these drives. Also they are cheaper drives so I would expect these IO errors to be normal for these WD purples. | ||
- | |||
- | There is a scrub still running so we should find out more when it's done. | ||
- | < | ||
- | root@backup1: | ||
- | pool: tank | ||
- | | ||
- | scan: scrub in progress since Sun May 13 00:24:01 2018 | ||
- | 12.9T scanned out of 19.0T at 35.7M/s, 49h46m to go | ||
- | 0 repaired, 67.97% done | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== send/recv tools ====== | ||
- | |||
- | ==== Using unprivileged accounts ==== | ||
- | |||
- | * [[https:// | ||
- | ]] | ||
- | < | ||
- | root@sendbox: | ||
- | root@recvbox: | ||
- | </ | ||
- | ==== sanoid/ | ||
- | |||
- | ==== zrepl ==== | ||
- | |||
- | ==== znapzend ==== | ||
- | |||
- | * [[https:// | ||
- | |||
- | |||
- | === Bugs === | ||
- | * https:// | ||
- | * https:// | ||
- | |||
- | |||
- | |||
- | ==== Monitor ==== | ||
- | * https:// | ||
- | |||
- | |||
- | ===== zfs holds ===== | ||
- | |||
- | Prevent snapshots from being destroyed. https:// | ||
- | |||
- | |||
- | |||
- | List all holds in all pools. | ||
- | < | ||
- | zfs get -Ht snapshot userrefs | grep -v $' | ||
- | </ | ||
- | |||
- | List holds in specific dataset. | ||
- | < | ||
- | zfs list -H -r -d 1 -t snapshot -o name nameoffilesystem | xargs zfs holds | ||
- | </ | ||
- | |||
- | ===== zfs snapshots - show space used ===== | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | { echo -e " | ||
- | for snapshot in $(zfs list -Hpr " | ||
- | echo -ne " | ||
- | zfs destroy -nv " | ||
- | done } | column -t | ||
- | </ | ||
- | |||
- | |||
- | ===== zfs - docker ===== | ||
- | |||
- | * https:// |