Problem trying run command before stopping systemd target

aug7744

Member
Joined
Aug 12, 2020
Messages
103
Reaction score
13
Credits
1,069
Hello.
Thanks for reading my question.

I need run an command before stopping target local-fs-pre.target.
The command is used by an systemd service

The command is for flush dmwritecache in disk partition before unmounting file system
/usr/sbin/dmsetup message /dev/mapper/rc-wb_sda5 0 flush

The systemd service created to run before umount.target works correctly

====
[Unit]
Description=Cache Flush
DefaultDependencies=no
Before=umount.target

[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/local/bin/flush.sh
TimeoutStartSec=0

[Install]
WantedBy=umount.target
====

However umount.target is related with umounting root. Other partitions are related with
local-fs.target
local-fs-pre.target
both targets are dependencies of sysinit.target and basic.target

Both targets above are running in OS. Only are stopped when done an shutdown.
Thus I need configure the systemd service to run the command exactly before both local-fs.target and local-fs-pre.target are being stopped doing an flush data in disk partitions.

What config to use in systemd service ?
Where see any information about it ?

Thanks for reply.
 

Members online


Latest posts

Top