Manage Startup
How Do I... Manage services and issue commands during startup
To add a service to startup use the syntax below. Substitute service with the service you require, and runlevel with the desired runlevel (such as defaul, boot or battery). In most cases, you'll want to target the default runlevel.
$ sudo rc-update add service runlevel
Likewise, to remove a service from startup,
$ sudo rc-update del service runlevel
To stop, start, or restart a service once your system is running, you'll need to call the initialization script for the service in question. To stop a service,
$ sudo /etc/init.d/service stop
To start a service,
$ sudo /etc/init.d/service start
To restart a service,
$ sudo /etc/init.d/service restart
Some services, such as apache, have additional parameters that you can use to restart them. The following command restarts apache without providing any service interruption for existing connections.
$ sudo /etc/init.d/apache2 graceful
In addition to configuring services, you may want to issue certain commands during the startup process. Many Linux distributions do this by means of the /etc/rc.conf file, but with openrc, Gentoo suggests doing this using /etc/local.d/local.start.
$ sudo nano -w /etc/local.d/local.start
/etc/local.d/local.start
For example, to mount the boot partition during startup so you needn't mount it every time you try a new kernel configuration, add the directive below. If your boot partition is different than /dev/sda1, be sure to make the appropriate substitution.
# mount the boot partition mount /dev/sda1 /boot
This is also an excellent place to list other commands, such as mounting a network drive not required for your bootup process, setting your desired cpu frequency governor, connect to network shares, and more.