Debian: Add a work-around to preserve zpool.cache

The zpool.cache file is getting cleared by zfs-import-bpool.service.  A
work-around is to move the cache file out of the way before the import
and restore it after:
https://github.com/openzfs/zfs/discussions/8549#discussioncomment-231334

The suggestion there is suppressing errors with `|| true`, which can
also be done by prefixing the command with `-`.  (I verified that the
systemd in Buster is new enough to support that.)  If we are
suppressing errors anyway, I'm not sure there's a benefit to checking
for the file rather than just trying the move and letting it fail.  The
latter approach avoids the shell entirely.  So I changed it.

Closes #97
Suggested-by: Andrey Prokopenko <9478806+terem42@users.noreply.github.com>
Tested-by: Hevisko <hvjunk@gmail.com>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
This commit is contained in:
Richard Laager
2020-12-31 10:48:42 -06:00
parent f1721edda7
commit 66233a1138

View File

@@ -691,6 +691,9 @@ Step 4: System Configuration
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=/sbin/zpool import -N -o cachefile=none bpool ExecStart=/sbin/zpool import -N -o cachefile=none bpool
# Work-around to preserve zpool cache:
ExecStartPre=-/bin/mv /etc/zfs/zpool.cache /etc/zfs/preboot_zpool.cache
ExecStartPost=-/bin/mv /etc/zfs/preboot_zpool.cache /etc/zfs/zpool.cache
[Install] [Install]
WantedBy=zfs-import.target WantedBy=zfs-import.target