Systemd vs init.d Specify systemd dependencies in LSB headers

systemd

I have a systemd based system which contains one System V style init.d script with LSB headers. The init.d script must only be started after all filesystems in fstab are mounted. How can I specify this type of dependency in the LSB headers?

Best Answer

When you say you check for a file system mount, it's clear you'll run it if found and mounted, but what's not clear is that if it's not found, what do you want it to do?

I ask because one possible answer is yes, in LSB, it is the run level that determines this. In Linux/Unix boot up, file systems are available at run level 1. So, set in your LSB header "Default-Start: 2 3 4 5". Then, put the filesystem mount entry in /etc/fstab and optionally set it to 'bootwait' to hang your system and prevent transitioning to run level two until it mounts, no matter how long it takes. This is actually how some systems are configured when the (remote) file system is super critical.

Otherwise, the answer is no, you cannot check the existence of a mounted partition ONLY within an LSB header entry itself. And, since you allow this particular system to boot without this particular file system, the file system is obviously not 'important' enough to hang the system awaiting mount availability.

A consideration is if you want it to not run at all when the file system is not mounted because you're trying to satisfy a "Required-Start:" dependency in another init script? Hopefully not as you can see you are sliding down a very slippery slope of init script dependencies.

Hopefully, you want it to not run because if it did, it messes stuff up like filling the root file system (as opposed to being an init dependency)? Then, you can let it run, but just code the init script to check and exit gracefully, as appropriate. The logic to check a file system mount and, if not found, exit, is probably one line of code. It can be inserted just after of the LSB header.

Related Topic