5

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?

  • Write a systemd unit file for the old service? This should take about five minutes. – Michael Hampton Dec 31 '14 at 14:26
  • Hmm, my init.d script contains more setup logic than will fit into a unit file. That means that I'd have to create a unit file that would start my init.d script as a forking service? – Hans Then Jan 2 '15 at 9:56
  • 1
    Yes, sure: setup logic goes to your script, dependency logic goes to unit file - separation of concerns as an added bonus. – god Nov 3 '16 at 23:44
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.