init and Boot scripts in Linux

init and boot scripts:

The main startup process is initiated by the program init, which spawns all other processes. The purpose of init is to bring the system into a usable state. init reads the file /etc/inittab

■First, the main initialization script is run, /etc/rc.sysinit (a Bash script).

■If started in single user mode (runlevel 1 or S), the script /etc/rc.single is run.

■If in any other runlevel (2-5), /etc/rc.multi is run instead.

■The last script to run is /etc/rc.local (via /etc/rc.multi), which is empty by default


/etc/rc.sysinit is a script and not a place for settings. It sources (i.e. reads and inherits variables and functions) rc.conf for settings and /etc/rc.d/functions for the functions that produce its graphical output (nice colors, alignments, switching 'busy' to 'done', etc.). This file should not be edited as it is overwritten on upgrade.

The tasks of rc.sysinit are:

1.sources the /etc/rc.conf and /etc/rc.d/functions scripts.

2.displays a welcome message.

3.mounts various virtual file systems.

4.make sure rootfs is mounted read-only (if needed).

5.starts bootlogd.

6.print deprecation warnings.

7.configures the hardware clock.

8.starts udev, loads modules from the MODULES array defined in rc.conf, and waits for udev to finish processing coldplug events.

9.starts the loopback interface.

10.configures RAID, btrfs and encrypted filesystem mappings.

11.check partitions (fsck).

12.remount the rootfs in order to apply the options from /etc/fstab.

13.mounts local filesystems (networked drives are not mounted before a network profile is up).

14.start monitoring lvm groups.

15.activates swap areas.

16.configure timezone.

17.initialize the random seed.

18.removes various leftover/temporary files, such as /tmp/*.

19.sets the hostname, locale and system clock as defined in rc.conf.

20.configures the locale, console, and keyboard mappings.

21.sets the console font.

22.writes output from dmesg to /var/log/dmesg.log.

B. /etc/rc.single:

/etc/rc.single Single-user mode boots straight into the root user account and should only be used if one cannot boot normally. This script ensures no daemons are running except for the bare minimum: syslog-ng and udev.

The single-user mode is useful for system recovery where preventing remote users from doing anything that might cause data loss or damage is necessary

C. /etc/rc.multi :

/etc/rc.multi is run on any multi-user (i.e. normal) runlevel (i.e. 2, 3, 4, and 5). Typically, users do not notice the transition from rc.sysinit to rc.multi because rc.multi also uses /etc/rc.d/functions for handling output. This script:

1.runs sysctl to apply the settings in /etc/sysctl.conf, modifying kernel parameters at runtime; Arch has very few of these by default (mainly networking settings).

2.starts the daemons, as per the DAEMONS array in rc.conf.

3.runs /etc/rc.local to handle user customizations.

D. /etc/rc.local:

/etc/rc.local is the local multi-user startup script. Empty by default, it is a good place to put any last-minute commands the system should run at the very end of the boot process.

Most common system configuration tasks (like loading modules, changing the console font, or setting up devices) usually have a dedicated place where they are entered.

To avoid confusion, ensure that commands entered in rc.local are not better suited elsewhere, such as /etc/profile.d.


Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks