Skip to content

Commit

Permalink
Ensure to always cleanly unmount
Browse files Browse the repository at this point in the history
Ensure to always cleanly unmount (e.g., on shutdown) in mount-sd-service
by adding After=udisks2.service, Requires=udisks2.service and an
unconditional ExecStop= (by removing the "-" appended). This change has
been evaluated and tested for a year per mount-sdcard [1][2].

Note: Requisite (of dev-%i.device) should behave the same as BindsTo
except on certain failures with layered devices such as USB memory card
reader (UMS + memory card interface). However that should not be a
significant difference otherwise.

[1] https://github.com/Olf0/mount-sdcard
[2] https://openrepos.net/content/olf/mount-sdcard
  • Loading branch information
olf authored and Tomin1 committed Jun 7, 2021
1 parent 462266e commit 14b7e8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -45,18 +45,19 @@ new file mode 100644
index 00000000..c1aa7de3
--- /dev/null
+++ b/data/mount-sd@.service
@@ -0,0 +1,11 @@
@@ -0,0 +1,12 @@
+[Unit]
+Description=Handle udisks sd mount
+After=dev-%i.device start-user-session.service
+BindsTo=dev-%i.device
+After=udisks2.service dev-%i.device start-user-session.service
+Requisite=dev-%i.device
+Requires=udisks2.service
+Conflicts=rescue.target actdead.target factory-test.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/bin/udisksctl-user mount -b /dev/%i
+ExecStop=-/usr/bin/udisksctl-user unmount -b /dev/%i
+ExecStop=/usr/bin/udisksctl unmount -b /dev/%i
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 2118e6db..ee8fd06f 100644
--- a/tools/Makefile.am
Expand Down
4 changes: 2 additions & 2 deletions rpm/0013-Pass-extra-mount-options-to-mount-sd-service.patch
Expand Up @@ -11,14 +11,14 @@ diff --git a/data/mount-sd@.service b/data/mount-sd@.service
index c1aa7de3..22433391 100644
--- a/data/mount-sd@.service
+++ b/data/mount-sd@.service
@@ -7,5 +7,6 @@ Conflicts=rescue.target actdead.target factory-test.target
@@ -8,5 +8,6 @@ Conflicts=rescue.target actdead.target factory-test.target
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStart=/usr/bin/udisksctl-user mount -b /dev/%i
+EnvironmentFile=-/var/lib/environment/udisks2/*.conf
+ExecStart=/usr/bin/udisksctl-user mount $UDISKS2_MOUNT_OPTIONS -b /dev/%i
ExecStop=-/usr/bin/udisksctl-user unmount -b /dev/%i
ExecStop=/usr/bin/udisksctl unmount -b /dev/%i
--
2.25.1

0 comments on commit 14b7e8e

Please sign in to comment.