Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Nov 1998 11:31:48 +1030
From:      Greg Lehey <grog@lemis.com>
To:        "Marko's Work" <marko@websorcery.com>, freebsd-questions@FreeBSD.ORG
Subject:   Re: Curious about what happens during boot.
Message-ID:  <19981130113148.H831@freebie.lemis.com>
In-Reply-To: <01be1bfa$fdc6f100$ba80b7d1@vidbox>; from Marko's Work on Sun, Nov 29, 1998 at 07:47:22PM -0500
References:  <01be1bfa$fdc6f100$ba80b7d1@vidbox>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday, 29 November 1998 at 19:47:22 -0500, Marko's Work wrote:
> With FreeBSD, what script is run first (upon boot) in the /etc directory?
> With dos, config.sys and autoexec.bat are run after
> command.com, but in FreeBSD what comes after running the kernel?
> I would like to trace the whole procedure to become familiar with it.

This is a borderline -questions/-hackers question.  I'll deal with it
here.

The first process that UNIX starts is process 0 (strangely enough).
Nowadays it doesn't do much more than spawn process 1, which is called
init.  From the source code (/usr/src/sbin/init/init.c):

  /*
   * The mother of all processes.
   */

Roughly, init performs the following functions on startup:

1.  Initializes itself, including ensuring that it's process 1,
    setting the way it opens the system log file, ensuring that it's a
    session leader and running as root, and looking at some of the
    boot flags, including -s (single user) and -f (fast boot).

2.  If you specify -s, it will go into single user mode by spawning a
    copy of itself, which will start a shell.  You do what you want
    and exit the shell.  Then the original init continues.

3.  Next it starts a shell which runs the script /etc/rc, and waits
    for it to complete.  You can take a look at /etc/rc to see what it
    does: it reads in the following scripts:

       /etc/rc.conf to get configuration variables
       /etc/rc.serial to configure serial devices,
       /etc/rc.pccard to set up PC-cards (laptop plugin cards),
       /etc/rc.network to start the network services
       /etc/rc.i386 for processor-specific startup
       /etc/rc.local for site-related startup files

4.  Finally it looks at the file /etc/ttys and starts all the gettys
    described there.

Greg
--
See complete headers for address, home page and phone numbers
finger grog@lemis.com for PGP public key

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981130113148.H831>