1.9 KiB
title | slug | date | draft | authors | tags | categories | ||||
---|---|---|---|---|---|---|---|---|---|---|
Maintaining a system build on ZFS | maintaining-a-system-build-on-zfs | 2025-08-02 | false |
|
|
|
ZFS opens up novel methods to safely maintain a system. In this blog entry we will outline these methods in the form of an update protocol. To keep your system healthy this protocol should be executed on a weekly/monthly basis.
Pre-update
To be able to rollback the system after a system update, one may create a snapshot
of the root filesystem:
=== "Alpine Linux"
``` shell-session
sh# zfs snapshot rpool/root/alpine@previous
```
=== "Gentoo Linux"
``` shell-session
sh# zfs snapshot rpool/root/gentoo@previous
```
Furthermore, zfs list -t snapshot
can be used to list snapshots and zfs destroy
can be used to remove snapshots.
Update
We may perform a system update:
=== "Alpine Linux"
``` shell-session
sh# apk upgrade
sh# reboot
```
=== "Gentoo Linux"
``` shell-session
sh# emerge -auDU @world
sh# reboot
```
If the system does not behave accordingly after reboot, one may rollback
to the previous snapshot:
=== "Alpine Linux"
``` shell-session
sh# zfs rollback -r rpool/root/alpine@previous
```
=== "Gentoo Linux"
``` shell-session
sh# zfs rollback -r rpool/root/gentoo@previous
```
Post-update
To maintain the performance of the SSDs in the system, perform a trim
on the ZFS-pool:
sh# zpool trim --secure --wait rpool #(1)!
- Some devices may not support the option
--secure
.
A scrub
on the ZFS-pool checks and repairs the data in the pool and is usually performed after a trim
:
sh# zpool scrub rpool
A scrub
may take a while, its progress can be checked with:
sh# zpool status rpool
A ZFS scrub only repairs if
mirror
or azraid
mode is set in the pool.