Systemd
Systemd:在 ZFS 導入之前解鎖驅動器
除此之外,我還有 LUKS 加密驅動器和 ZFS。我使用腳本在啟動時解鎖驅動器。我為此做了一個 systemd 服務,但是腳本需要一些時間,並且 zfs-import-cache.service 在我的腳本完成之前啟動。
- zfs-import-cache.service Journalctl
# journalctl -e -u cryptdisks-unlock.service -u zfs-import-cache.service Sep 25 15:53:45 server systemd[1]: Starting Unlock LUKS drives... Sep 25 15:53:45 server boot[1216]: Decrypting evo850m21-crypt ... Sep 25 15:53:47 server systemd[1]: Starting Import ZFS pools by cache file... Sep 25 15:53:47 server boot[1216]: Device evo850m21-crypt decrypted. Sep 25 15:53:47 server boot[1216]: Decrypting evo850m22-crypt ... Sep 25 15:53:49 server boot[1216]: Device evo850m22-crypt decrypted. Sep 25 15:53:49 server boot[1216]: Decrypting st30001-crypt ... Sep 25 15:53:50 server zpool[1390]: cannot import 'data': no such pool or dataset Sep 25 15:53:51 server zpool[1390]: Destroy and re-create the pool from Sep 25 15:53:51 server zpool[1390]: a backup source. Sep 25 15:53:51 server systemd[1]: zfs-import-cache.service: Main process exited, code=exited, status=1/FAILURE Sep 25 15:53:51 server systemd[1]: zfs-import-cache.service: Failed with result 'exit-code'. Sep 25 15:53:51 server systemd[1]: Failed to start Import ZFS pools by cache file. Sep 25 15:53:52 server boot[1216]: Device st30001-crypt decrypted. Sep 25 15:53:52 server boot[1216]: Decrypting st30002-crypt ... Sep 25 15:53:54 server boot[1216]: Device st30002-crypt decrypted. Sep 25 15:53:54 server systemd[1]: cryptdisks-unlock.service: Succeeded. Sep 25 15:53:54 server systemd[1]: Finished Unlock LUKS drives.
cryptdisks-unlock.service
[Unit] Description=Unlock LUKS drives Before=zfs-import.target [Service] Type=oneshot ExecStart=/usr/local/cryptdisks-tools/boot [Install] WantedBy=zfs-import-cache.service
這是我解決它的方法:
[Unit] Description=Unlock LUKS drives Before=zfs-import-cache.service DefaultDependencies=no [Service] Type=oneshot ExecStart=/usr/local/cryptdisks-tools/boot [Install] WantedBy=cryptsetup.target zfs.target