Some services are configured to start in your Xen virtual machine out of the box. The scripts that run on start up are stored in the /etc/init.d/ directory. You can start/stop/restart services with out rebooting your Xen virtual machine by running the script with the argument of start, stop, or restart. For example:
Adding a script to run at startup
To make a script run at startup of your Xen virtual machine you need to put the script in /etc/init.d and make sure it will take the start and stop arguements. Once the script is in /etc/init.d you need to tell the system when to run the script. You can use the following command:
chkconfig –level 345 scriptname on
The above command tells the system what runlevel the script needs to be run at. For most scipts the you will want the runlevels of 3, 4, and 5.
for more info on runlevels check out http://en.wikipedia.org/wiki/Runlevel.
The runlevel for a script is not something to play with, please know what you are doing before changing the runlevel for scripts.
Stopping a script from running at startup
If you wish to stop a script in the /etc/init.d directory from running on startup you can use the following command:
chkconfig scriptname off
Services you may want off
If you feel that your vm is running too many services, here is a list of services that may be enabled, but you can probably turn off without issues:
- atd (not often used)
- auditd (you may or may not need this)
You may also want to comment out the lines in /etc/inittab that look like this:
#2:2345:respawn:/sbin/mingetty tty2 #3:2345:respawn:/sbin/mingetty tty3 #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6
WARNING: Don’t comment out the mingetty that starts with 1, that is needed for accessing the console of the VM.