New to systemd and need help
by bellsal from LinuxQuestions.org on (#58BS6)
Hi All,
I am new to systemd, and I am having trouble understanding it. In the past I used init, and it was easier to understand.
Here is what I am trying to do; at shutdown (-h or -r), I need to unmount a veracrypt volume by issuing the following command: veracrypt -t -d. Very simple - nothing fancy!
I created the following systemd service:
[Unit]
Description=Umount Veracrypt Volume at shutdown
Requires=network.target
DefaultDependencies=no
Before=shutdown.target reboot.target poweroff.target
[Service]
Type=oneshot
RemainAfterExit=/bin/true
ExecStart=/bin/true
ExecStop=/usr/bin/veracrypt -t -d
[Install]
WantedBy=multi-user.target
- I named this service umount_veracrypt_volume.service
- Saved this file in /usr/lib/systemd/system
- Ran the following command: systemctl daemon-reload
- Enabled the service: systemctl enable umount_veracrypt_volume.service
Question:
1. Is my service script correct?
2. Did I save it in the right location?
3. How do I test it if it works? I really don't know how to test it since the machine shuts down, but I don't know if it umounted the veracrypt volume prior to completing the shutdown.
Please help me!
Sal


I am new to systemd, and I am having trouble understanding it. In the past I used init, and it was easier to understand.
Here is what I am trying to do; at shutdown (-h or -r), I need to unmount a veracrypt volume by issuing the following command: veracrypt -t -d. Very simple - nothing fancy!
I created the following systemd service:
[Unit]
Description=Umount Veracrypt Volume at shutdown
Requires=network.target
DefaultDependencies=no
Before=shutdown.target reboot.target poweroff.target
[Service]
Type=oneshot
RemainAfterExit=/bin/true
ExecStart=/bin/true
ExecStop=/usr/bin/veracrypt -t -d
[Install]
WantedBy=multi-user.target
- I named this service umount_veracrypt_volume.service
- Saved this file in /usr/lib/systemd/system
- Ran the following command: systemctl daemon-reload
- Enabled the service: systemctl enable umount_veracrypt_volume.service
Question:
1. Is my service script correct?
2. Did I save it in the right location?
3. How do I test it if it works? I really don't know how to test it since the machine shuts down, but I don't know if it umounted the veracrypt volume prior to completing the shutdown.
Please help me!
Sal