Setting sysctl variables BEFORE the kernel boots and runs init?

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Aug 28 03:27:04 PDT 2003


On Thu, Aug 28, 2003 at 10:09:06AM +0200, David Landgren wrote:
> Micheal Patterson wrote:
> 
> >
> >----- Original Message ----- 
> >From: "Donald Burr" <dburr at borg-cube.com>
> >To: "FreeBSD Questions List" <freebsd-questions at freebsd.org>
> >Sent: Wednesday, August 27, 2003 6:11 PM
> >Subject: Setting sysctl variables BEFORE the kernel boots and runs init?
> >
> >
> >
> >>I would like to be able to set certain sysctl variables in the kernel,
> >>preferably BEFORE the kernel finishes booting and runs init, etc. (or
> >>at the worst case, very shortly after init runs)  I thought I
> >>remembered that there was a way to do this through the boot loader.
> >>Can anyone enlighten me?  Thanks.
> [...]
> >You can configure sysctl options if you create the file /etc/sysctl.conf 
> >and
> >put your changes there. Is this what you're looking for?
> 
> That happens in the late stages if the game. init is running the main 
> rc script, disks have been fscked and mounted, swap is up. It does 
> happen before network setup, IIRC. It depends on what variables the OP 
> is talking about I guess.

Yes -- however /etc/sysctl.conf is still too late compared to what the
OP was asking for.

You can modify some kernel tunables very early in the boot process by
setting variables in the loader.  According to loader(8) the tunables
that are available are:

    kern.maxusers
    kern.ipc.nmbclusters
    kern.vm.kmem.size
    kern.maxswzone
    kern.maxbcache
    machdep.pccard.pcic_irq
    net.inet.tcp.tcbhashsize

(This is on 4.9-PRERELEASE, other OS versions may differ)

These are normally set using compiled-in values derived from settings
like MAXUSERS, NMBCLUSTERS, TCBHASHSIZE in the kernel config.  These
values have to be set early because they define the size of various
critical memory structures within the kernel that can't be modified
while the system is running.

You can set these values by editing /boot/loader.conf -- eg, add:

   kern.maxusers="32"

to that file.  The operation of loader.conf deliberately parallels the
way that /etc/rc.conf works.  See /boot/defaults/loader.conf for
default settings for the available variables.

Any other modifications to sysctl settings can and should be made via
/etc/sysctl.conf

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030828/e9867771/attachment.bin


More information about the freebsd-questions mailing list