DESCRIPTION
newbtconf is used to set up the system in such a way that the user is offered a selection of environments in which to boot the system up into. The most obvious application being for laptops to provide a network and non-network environment after a successful boot into multi-user mode.
Background
In order to accomplish this task, the files usually associated with establishing the current system's running configuration are replaced with symbolic links which are adjusted with each boot to point to the appropriate file for the desired run-time environment. This is accomplished by directing all of the symbolic links through a directory which itself is a symbolic link (
/etc/etc.current), to the destination files. At each bootup, the selection made changes which directory
/etc/etc.current points to.
Through doing this and reloading /etc/rc.conf in /etc/rc after the link has been established, the resulting run-time configuration is effectively controlled without the need to directly edit any files. The default boot-up environment is selected by manually directing which configuration directory /etc/etc.default points to. As opposed to /etc/etc.current (which is updated with every boot), /etc/etc.default is not automatically updated.
Getting Started
By default,
NetBSD only has one boot-up configuration - that set in the file
/etc/rc.conf. In order to initialize the system for operating in a manner which supports multiple boot configurations,
newbtconf must be run with an argument of ‘init'. This will create two symbolic links
/etc/etc.current and
/etc/etc.default to the directory
/etc/etc.network. The following files are all moved into that directory and symbolic links put in their place, in
/etc, pointing to
/etc/etc.current/<filename>:
/etc/defaultdomain
/etc/fstab
/etc/ifconfig.*
/etc/inetd.conf
/etc/mrouted.conf
/etc/mygate
/etc/myname
/etc/netstart
/etc/nsswitch.conf
/etc/ntp.conf
/etc/rc.conf
/etc/rc.conf.d
/etc/resolv.conf
To test that this has been performed correctly, reboot your system into NetBSD. After the kernel has autoconfigured and tty flags have been set, a prompt should appear, preceded by the following like, looking like this:
[network]
Which configuration [network] ?
The []'s are used to indicate the default configuration, which can be selected by just pressing return. If there were other configurations available at this stage, you would have 30 seconds to enter that name and press RETURN.
Multiple Configurations
Once an initial configuration has been set up, we can proceed to set up further run time environments. This is done by invoking
newbtconf with the name of the new configuration to be created. By default, this step will use the current configuration files as the basis for this setup unless a second parameter is given - that of the configuration to use as the basis for the new one. Upon completion, a new directory,
/etc/etc.<newname>, will have been created, priming the directory with the appropriate files for editing. For example, if we do
newbtconf nonet network it would create a directory named
/etc/etc.nonet and copy all the files from
/etc/etc.network into that directory. Upon rebooting, we should see:
[network] nonet
Which configuration [network] ?
To set up the system for booting into the “nonet” configuration, the files in /etc/etc.nonet need be edited.
If you wanted to make “nonet” the default configuration when booting, you would need delete the symbolic link /etc/etc.default and create a new symbolic link (with the same name) to /etc/etc.nonet. Booting up after having made such a change would result in the following being displayed:
network [nonet]
Which configuration [nonet] ?
No Network
Assuming that we performed the above command successfully, in order to successfully configure
NetBSD to not configure interfaces (or generate no errors from attempting to do so), the following settings (at least) should be used in
/etc/etc.nonet/rc.conf:
auto_ifconfig=NO
net_interfaces=NO
Of course other networking services, such as NTP, routed, etc, are all expected to be “NO”. In general, the only setting that should be “YES” is syslogd, and perhaps cron (if your cron scripts don't need the network) or screenblank/wscons (if applicable). Other actions such as deleting any NFS mounts from /etc/etc.nonet/fstab would also need to be undertaken.
Reverting multiple boot configurations
Multiple boot configurations can be deactivated by running newbtconf with an argument of revert. All the symlinks mentioned above are then removed and the files they point to are copied to their default place. This effectively makes the currently selected configuration the only one active. The symbolic links /etc/etc.current and /etc/etc.default are also removed so upon rebooting no configuration selection menu is displayed. Note that the previously created configurations (in /etc/etc.<name>) are not removed.