summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys-utils/.gitignore1
-rw-r--r--sys-utils/Makemodule.am6
-rw-r--r--sys-utils/fstrim.service.in6
-rw-r--r--sys-utils/fstrim.timer10
4 files changed, 23 insertions, 0 deletions
diff --git a/sys-utils/.gitignore b/sys-utils/.gitignore
index 8d8737a31..bcd6e0271 100644
--- a/sys-utils/.gitignore
+++ b/sys-utils/.gitignore
@@ -18,3 +18,4 @@ sparc32.8
sparc32bash.8
sparc64.8
x86_64.8
+fstrim.service
diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index ae254a3a1..1c2b210a1 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -53,8 +53,14 @@ dist_man_MANS += sys-utils/fstrim.8
fstrim_SOURCES = sys-utils/fstrim.c
fstrim_LDADD = $(LDADD) libcommon.la libmount.la
fstrim_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir)
+systemdsystemunit_DATA += \
+ sys-utils/fstrim.service \
+ sys-utils/fstrim.timer
endif
+PATHFILES += \
+ sys-utils/fstrim.service
+
if LINUX
#
# Linux-only utils with no another dependencies. All another dependencies have
diff --git a/sys-utils/fstrim.service.in b/sys-utils/fstrim.service.in
new file mode 100644
index 000000000..52155d0b3
--- /dev/null
+++ b/sys-utils/fstrim.service.in
@@ -0,0 +1,6 @@
+[Unit]
+Description=Discard unused blocks
+
+[Service]
+Type=oneshot
+ExecStart=@sbindir@/fstrim -a
diff --git a/sys-utils/fstrim.timer b/sys-utils/fstrim.timer
new file mode 100644
index 000000000..24eeee552
--- /dev/null
+++ b/sys-utils/fstrim.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Discard unused blocks once a day
+
+[Timer]
+OnCalendar=daily
+AccuracySec=1h
+Persistent=true
+
+[Install]
+WantedBy=multi-user.target