]> git.proxmox.com Git - zfsonlinux.git/blob - debian/patches/0007-Add-systemd-unit-for-importing-specific-pools.patch
cherry-pick fix for data corruption
[zfsonlinux.git] / debian / patches / 0007-Add-systemd-unit-for-importing-specific-pools.patch
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
5
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
8 /etc/zfs/zpool.cache.
9
10 the instance name is used unescaped (see systemd.unit(5)), since zpool names
11 can contain characters which will be escaped by systemd.
12
13 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
14 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
15 ---
16 etc/Makefile.am | 1 +
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
21
22 diff --git a/etc/Makefile.am b/etc/Makefile.am
23 index 7187762d3..de131dc87 100644
24 --- a/etc/Makefile.am
25 +++ b/etc/Makefile.am
26 @@ -54,6 +54,7 @@ dist_systemdpreset_DATA = \
27 systemdunit_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
38 @@ -1,6 +1,7 @@
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
47 new file mode 100644
48 index 000000000..9b4ee9371
49 --- /dev/null
50 +++ b/etc/systemd/system/zfs-import@.service.in
51 @@ -0,0 +1,16 @@
52 +[Unit]
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
60 +
61 +[Service]
62 +Type=oneshot
63 +RemainAfterExit=yes
64 +ExecStart=@sbindir@/zpool import -N -d /dev/disk/by-id -o cachefile=none %I
65 +
66 +[Install]
67 +WantedBy=zfs-import.target