🇰🇲 Как настроить службу systemd для ожидания монтирования конкретной точки монтирования перед запуском

by itisgood

Вопрос: для правильной работы установленной службе необходимо смонтировать определенную файловую систему (например, NFS). Попытка запустить указанную службу до правильного монтирования файловой системы приводит к сбою. (если это происходит во время загрузки, время загрузки задерживается, а служба не запускается после последовательности загрузки).

Как настроить служебный файл так, чтобы sytemd всегда ожидал, что указанное монтирование запустит службу?

1. Может быть использована опция requireMountsFor. Согласно справочной странице systemd.unit:

# 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. Например:

# /etc/systemd/system/example.service
[Unit]
Description=Example System Service
RequiresMountsFor=/mnt/foo

[...]

 

You may also like

Leave a Comment