summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Dahl <ada@thorsis.com>2021-09-09 12:16:52 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2021-09-29 13:45:50 +0200
commit434bd8a2cee93a599e2d282a152842447aa45cb4 (patch)
treedd7a9f8dda3a09da9e65069083bdb41e77f59eff
parent943b1effc28055c072e20aaab772ff80576f9443 (diff)
downloadptxdist-434bd8a2cee93a599e2d282a152842447aa45cb4.tar.gz
ptxdist-434bd8a2cee93a599e2d282a152842447aa45cb4.tar.xz
mtd-utils: Introduce systemd unit for ubihealthd
It's possible to run multiple instances for multiple ubi devices by creating multiple symlinks. One symlink for the first device ubi0 is already created. Signed-off-by: Alexander Dahl <ada@thorsis.com> Message-Id: <20210909101652.9288-3-ada@thorsis.com> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--projectroot/usr/lib/systemd/system/ubihealthd@.service13
-rw-r--r--rules/mtd-utils.in12
-rw-r--r--rules/mtd-utils.make6
3 files changed, 30 insertions, 1 deletions
diff --git a/projectroot/usr/lib/systemd/system/ubihealthd@.service b/projectroot/usr/lib/systemd/system/ubihealthd@.service
new file mode 100644
index 000000000..f3f0ba25f
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/ubihealthd@.service
@@ -0,0 +1,13 @@
+# enable with `systemctl enable ubihealthd@ubi0.service`
+
+[Unit]
+Description=ubihealthd UBI device PEB scan daemon for %I
+BindsTo=dev-%i.device
+After=dev-%i.device
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/ubihealthd -d /dev/%I -i 120
+
+[Install]
+WantedBy=multi-user.target
diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
index 11b0be23f..0d8fb5f5a 100644
--- a/rules/mtd-utils.in
+++ b/rules/mtd-utils.in
@@ -294,13 +294,23 @@ config MTD_UTILS_UBIFS_MOUNTHELPER
help
Simplifies attaching an ubi and mounting an ubifs via /etc/fstab.
-config MTD_UTILS_UBIHEALTHD
+menuconfig MTD_UTILS_UBIHEALTHD
bool
prompt "ubihealthd"
help
Daemon that randomly scans each PEB of a UBI device to ensure that
filesystems with little reading do enough wear leveling.
+if MTD_UTILS_UBIHEALTHD
+
+config MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT
+ bool
+ prompt "install systemd unit files"
+ default y
+ depends on SYSTEMD
+
+endif
+
config MTD_UTILS_UBIMKVOL
bool
prompt "ubimkvol"
diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
index 15288acd7..d96ab02b0 100644
--- a/rules/mtd-utils.make
+++ b/rules/mtd-utils.make
@@ -205,6 +205,12 @@ endif
ifdef PTXCONF_MTD_UTILS_UBIHEALTHD
@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
/usr/sbin/ubihealthd)
+ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT
+ @$(call install_alternative, mtd-utils, 0, 0, 0644, \
+ /usr/lib/systemd/system/ubihealthd@.service)
+ @$(call install_link, mtd-utils, ../ubihealthd@.service, \
+ /usr/lib/systemd/system/multi-user.target.wants/ubihealthd@ubi0.service)
+endif
endif
ifdef PTXCONF_MTD_UTILS_UBIMKVOL
@$(call install_copy, mtd-utils, 0, 0, 0755, -, \