2024-10-08 18:15:52 +02:00
# Update protocol
ZFS opens up new methods to safely update the system. These methods are described in this section in combination with general practises to maintain ZFS filesystems.
## Pre-update
To be able to rollback the system after a system update one may create a snapshot of the root filesystem.
```
2025-02-21 23:34:01 +01:00
# zfs snapshot rpool/root/alpine@previous
2024-10-08 18:15:52 +02:00
```
2024-10-08 18:25:10 +02:00
> Tip:`zfs list -t snapshot` can be used to list snapshost and `zfs destroy` can be used to remove snapshots.
2024-10-08 18:15:52 +02:00
## Update
Perform a system update.
```
# apk upgrade
# reboot
```
2024-10-08 18:25:10 +02:00
If the system does not behave accordingly after reboot, one may rollback to the previous snapshot.
2024-10-08 18:15:52 +02:00
```
2025-02-21 23:34:01 +01:00
# zfs rollback -r rpool/root/alpine@previous
2024-10-08 18:15:52 +02:00
```
## Post-update
To maintain the performance of the SSDs in the system, perform a trim on the zfs-pool.
```
2025-02-21 23:34:01 +01:00
# zpool trim --secure --wait rpool
2024-10-08 18:15:52 +02:00
```
2024-10-08 18:25:10 +02:00
> Some devices may not support the option `--secure`.
2024-10-08 18:15:52 +02:00
Thereafter, perform a scrub on the zfs-pool which checks and repairs the data in the pool.
```
2025-02-21 23:34:01 +01:00
# zpool scrub rpool
2024-10-08 18:15:52 +02:00
```
This may take a while, the progress can be checked with:
```
2025-02-21 23:34:01 +01:00
# zpool status rpool
2024-10-08 18:15:52 +02:00
```
2024-10-08 18:25:10 +02:00
> A ZFS scrub only repairs if mirror or a zraid mode is set in the pool.