Thank you for reading this post, don't forget to subscribe!
Вопрос: для правильной работы установленной службе необходимо смонтировать определенную файловую систему (например, NFS). Попытка запустить указанную службу до правильного монтирования файловой системы приводит к сбою. (если это происходит во время загрузки, время загрузки задерживается, а служба не запускается после последовательности загрузки).
Как настроить служебный файл так, чтобы sytemd всегда ожидал, что указанное монтирование запустит службу?
1. Может быть использована опция requireMountsFor. Согласно справочной странице systemd.unit:
1 2 3 4 5 6 |
# man systemd.unit ... RequiresMountsFor= Takes a space-separated list of absolute paths. Automatically adds dependencies of type Requires= and After= for all mount units required to access the specified path. Mount points marked with noauto are not mounted automatically and will be ignored for the purposes of this option. If such a mount should be a requirement for this unit, direct dependencies on the mount units may be added (Requires= and After= or some other combination). |
2. Добавьте requireMountsFor в раздел [Unit] в файле модуля /etc/systemd/system/[UNITFILE].service. Например:
1 2 3 4 5 6 |
# /etc/systemd/system/example.service [Unit] Description=Example System Service RequiresMountsFor=/mnt/foo […] |