0008-Add-systemd-unit-for-importing-specific-pools.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Stoiko Ivanov <[email protected]>
  3. Date: Tue, 15 Sep 2020 19:07:24 +0200
  4. Subject: [PATCH] Add systemd-unit for importing specific pools
  5. The unit can be instantiated with a specific poolname, which will get imported
  6. by scanning /dev/disk/by-id, irrespective of the existence and content of
  7. /etc/zfs/zpool.cache.
  8. the instance name is used unescaped (see systemd.unit(5)), since zpool names
  9. can contain characters which will be escaped by systemd.
  10. Signed-off-by: Stoiko Ivanov <[email protected]>
  11. ---
  12. etc/systemd/system/50-zfs.preset.in | 1 +
  13. etc/systemd/system/Makefile.am | 1 +
  14. etc/systemd/system/[email protected] | 16 ++++++++++++++++
  15. 3 files changed, 18 insertions(+)
  16. create mode 100644 etc/systemd/system/[email protected]
  17. diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset.in
  18. index e4056a92c..030611419 100644
  19. --- a/etc/systemd/system/50-zfs.preset.in
  20. +++ b/etc/systemd/system/50-zfs.preset.in
  21. @@ -1,6 +1,7 @@
  22. # ZFS is enabled by default
  23. enable zfs-import-cache.service
  24. disable zfs-import-scan.service
  25. +enable [email protected]
  26. enable zfs-import.target
  27. enable zfs-mount.service
  28. enable zfs-share.service
  29. diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am
  30. index 5e65e1db4..8e6baeb68 100644
  31. --- a/etc/systemd/system/Makefile.am
  32. +++ b/etc/systemd/system/Makefile.am
  33. @@ -7,6 +7,7 @@ systemdunit_DATA = \
  34. zfs-zed.service \
  35. zfs-import-cache.service \
  36. zfs-import-scan.service \
  37. + [email protected] \
  38. zfs-mount.service \
  39. zfs-share.service \
  40. zfs-volume-wait.service \
  41. diff --git a/etc/systemd/system/[email protected] b/etc/systemd/system/[email protected]
  42. new file mode 100644
  43. index 000000000..9b4ee9371
  44. --- /dev/null
  45. +++ b/etc/systemd/system/[email protected]
  46. @@ -0,0 +1,16 @@
  47. +[Unit]
  48. +Description=Import ZFS pool %i
  49. +Documentation=man:zpool(8)
  50. +DefaultDependencies=no
  51. +After=systemd-udev-settle.service
  52. +After=cryptsetup.target
  53. +After=multipathd.target
  54. +Before=zfs-import.target
  55. +
  56. +[Service]
  57. +Type=oneshot
  58. +RemainAfterExit=yes
  59. +ExecStart=@sbindir@/zpool import -N -d /dev/disk/by-id -o cachefile=none %I
  60. +
  61. +[Install]
  62. +WantedBy=zfs-import.target