1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stoiko Ivanov <s.ivanov@proxmox.com>
3 Date: Tue, 15 Sep 2020 19:07:24 +0200
4 Subject: [PATCH] Add systemd-unit for importing specific pools
6 The unit can be instantiated with a specific poolname, which will get imported
7 by scanning /dev/disk/by-id, irrespective of the existence and content of
10 the instance name is used unescaped (see systemd.unit(5)), since zpool names
11 can contain characters which will be escaped by systemd.
13 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
14 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 etc/systemd/system/50-zfs.preset | 1 +
18 etc/systemd/system/zfs-import@.service.in | 16 ++++++++++++++++
19 3 files changed, 18 insertions(+)
20 create mode 100644 etc/systemd/system/zfs-import@.service.in
22 diff --git a/etc/Makefile.am b/etc/Makefile.am
23 index 7187762d3..de131dc87 100644
26 @@ -54,6 +54,7 @@ dist_systemdpreset_DATA = \
28 %D%/systemd/system/zfs-import-cache.service \
29 %D%/systemd/system/zfs-import-scan.service \
30 + %D%/systemd/system/zfs-import@.service \
31 %D%/systemd/system/zfs-import.target \
32 %D%/systemd/system/zfs-mount.service \
33 %D%/systemd/system/zfs-scrub-monthly@.timer \
34 diff --git a/etc/systemd/system/50-zfs.preset b/etc/systemd/system/50-zfs.preset
35 index e4056a92c..030611419 100644
36 --- a/etc/systemd/system/50-zfs.preset
37 +++ b/etc/systemd/system/50-zfs.preset
39 # ZFS is enabled by default
40 enable zfs-import-cache.service
41 disable zfs-import-scan.service
42 +enable zfs-import@.service
43 enable zfs-import.target
44 enable zfs-mount.service
45 enable zfs-share.service
46 diff --git a/etc/systemd/system/zfs-import@.service.in b/etc/systemd/system/zfs-import@.service.in
48 index 000000000..9b4ee9371
50 +++ b/etc/systemd/system/zfs-import@.service.in
53 +Description=Import ZFS pool %i
54 +Documentation=man:zpool(8)
55 +DefaultDependencies=no
56 +After=systemd-udev-settle.service
57 +After=cryptsetup.target
58 +After=multipathd.target
59 +Before=zfs-import.target
64 +ExecStart=@sbindir@/zpool import -N -d /dev/disk/by-id -o cachefile=none %I
67 +WantedBy=zfs-import.target