I'm running a raspbian (based on debian). I want to change the priority of the init services so the very first script which is run by init is one made for me. How can I do it?

On runlevel S I have 3 scripts with priortity 01: hostname.sh, fake-hwclock and mountkernfs.sh. If I just put my script on runlevel S with priority 01, it's not the first one to be executed. I have tried to change the priortiy of all these scripts to 02 using (for example in the case of mountkernfs.sh)

sudo update-rc.d -f mountkernfs.sh remove
sudo update-rc.d mountkernfs.sh start 02 S

The first command effectively removes the script from /etc/rcS.d. The second command puts again mountkernfs.sh with priority 01.

Any idea? Thank you!


The init scripts on /etc/init.d/ specify some information on it's LSB header, which in essence are just some lines at the beginning of the script. The field "Required-Start" of some script allows you to specify services that must be initialized before this script. insserv automatically add init scripts regarding LSB header.

Therefore, to solve the problem:

  • Name your script "X" using "Provides" field on LSB header.
  • Add the runlevels where the script has to be started and stopped using "Default-Start" and "Default-Stop" fields respectively on LSB header.
  • Set "X" to the field "Required-Start" on the LSB header of the scripts with priority 01: hostname.sh, fake-hwclock and mountkernfs.sh.
  • Add the service using sudo insserv name_of_your_script_file (not the name you give to "Provides" field)

This moves all the necessary script priorities of the involved scripts to match the dependencies. In my case:

  • S01X.sh
  • S02mountkernfs.sh
  • S02hostname.sh
  • S02fake-hwclock
  • S03udev

Source: http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot


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.