bundles/zfs: use zfs-import-scan instead of zfs-import-cache

Last night, rx300 rebooted. After a reboot, the disks were detected
in another order (but still, all were detected!), so the cachefile did
no longer match, leading to breaking the import.

Running `zpool import` manually worked, because that will ignore the
cachefile. So, why do we depend on the cache file on boot up? The added
reliability of zfs-import-scan beats the speed of zfs-import-cache in
any way.
This commit is contained in:
Franzi 2022-03-12 08:54:33 +01:00
parent 42a66751e1
commit 72cf616114
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,10 @@
[Unit]
ConditionPathExists=
[Service]
ExecStart=
% if node.os == 'arch':
ExecStart=/usr/bin/zpool import -aN -o cachefile=none
% else:
ExecStart=/usr/sbin/zpool import -aN -o cachefile=none
% endif

View file

@ -23,11 +23,6 @@ if node.os == 'debian':
'comment': 'If this fails, do a dist-upgrade, reinstall zfs-dkms, reboot',
},
}
elif node.os == 'arch':
for service in ('zfs-import-scan.service', 'zfs-mount.service'):
svc_systemd[service] = {}
for service in ('zfs.target', 'zfs-import.target'):
svc_systemd[service] = {'running': None}
files = {
'/etc/modprobe.d/zfs.conf': {
@ -35,6 +30,13 @@ files = {
'content_type': 'mako',
'mode': '0755',
},
'/etc/systemd/system/zfs-import-scan.service.d/bundlewrap.conf': {
'source': 'zfs-import-scan-override.service',
'content_type': 'mako',
'triggers': {
'action:systemd-reload',
},
},
'/etc/zfs-snapshot-config.json': {
'content': dumps(
node.metadata.get('zfs/snapshots', {}),
@ -75,7 +77,27 @@ files = {
}
svc_systemd = {
'zfs-import-scan.service': {
'needs': {
'file:/etc/systemd/system/zfs-import-scan.service.d/bundlewrap.conf',
},
'before': {
'svc_systemd:zfs-import-cache.service',
},
},
'zfs-import-cache.service': {
'running': None,
'enabled': False,
'masked': True,
},
'zfs-mount.service': {},
'zfs-zed': {},
'zfs.target': {
'running': None,
},
'zfs-import.target': {
'running': None,
},
}
for name, attrs in node.metadata.get('zfs/datasets', {}).items():
@ -90,8 +112,8 @@ for name, attrs in node.metadata.get('zfs/datasets', {}).items():
for name, attrs in node.metadata.get('zfs/pools', {}).items():
zfs_pools[name] = attrs
if node.os_version[0] > 10:
zfs_pools[name]['autotrim'] = attrs.get('autotrim', True)
if (not node.os == 'debian' or node.os_version[0] > 10) and 'autotrim' not in attrs:
zfs_pools[name]['autotrim'] = True
directories = {
"/etc/zfs-snapshot-backup-pre.d": {