Jacobs "Blog"

CentOS 6 - Managing Boot Order

This is a bit of a weird one for me because CentOS 6 is absolutely obsolete, however I'm forced to use it for the time being and a major issue for me is the boot order. I can't remember exactly what was breaking, but it was something about the network not being available when iscsi is called - i believe.

Because I don't know, I have to investigate the order in how things boot. A quick Google search on the topic brought me to a 404 immediately: https://docs.centos.org/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-process.html

So let's dive into this a little bit.

ELI5: CentOS 6 Boot Process

When the machine boots, init will pull the runlevel from /etc/inittab. It will then look towards the /etc/rc#.d/ directory for that particular number. For example, run level 3 will run services in /etc/rc3.d/

Diving into this directory you'll see a number of files, but all will match regex similar to (S|K)[0-9]{2}*

Files starting with S are for "starting" scripts, which start stuff. Files starting with K are "killing" scripts, which kill stuff. Simple enough? If you want to see what's starting at run level 3 (most likely where you sit), simply ls /etc/rc3.d/S*

Add an -la into this and you'll see that they're all symlinks to their init.d scripts. This makes sense because you don't want to maintain two code bases for the same actions.

You'll notice the number after the S as well; this is the order in which things are booted.

WOOOAAHHHH hold your horses there buddy; you can't go moving the links! They're all managed by chkconfig! Every time chkconfig is run (ie chkconfig off ; chkconfig on), they won't go by where you've moved links around to, it'll go by something else.

Before I show you that, let's look at chkconfig --list:

# chkconfig --list
acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:off   4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:off   4:off   5:off   6:off
blk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:off
cgconfig        0:off   1:off   2:off   3:off   4:off   5:off   6:off
cgred           0:off   1:off   2:off   3:off   4:off   5:off   6:off

This is actually a much nicer view than the files, and you'll be able to see what each service is doing just not the order... hm.

So before you go changing symlink directories, check out where the symlinks go then open the file of hte services order you want to adjust (for example, /etc/init.d/httpd). Find the line "chkconfig..." and change the numbers accordingly. The numbers themselves represent run level, order and kill position respectively.

chkconfig: 345 7 89 will run the script (in this case iscsid) in runlevels 3, 4 and 5 (standard shell, unused, x11), will take the 7th place in the boot order and the 89th place when the run level is exited (either entirely or for another run level).

See: https://serverfault.com/questions/176055/how-to-change-linux-services-startup-boot-order