1.\" $NetBSD: newbtconf.8,v 1.18 2004/08/31 17:08:06 uwe Exp $ 2.\" 3.\" Copyright (c) 1999 Darren Reed. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. Neither the name of the author nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd January 6, 2003 30.Dt NEWBTCONF 8 31.Os 32.Sh NAME 33.Nm newbtconf 34.Nd multiple boot-up configurations 35.Sh SYNOPSIS 36.Nm 37.Ar new-conf-name 38.Op Ar orig-conf-name 39.Nm 40.Cm init 41.Nm 42.Cm revert 43.Sh DESCRIPTION 44.Nm 45is used to set up the system in such a way that the user is offered a 46selection of environments in which to boot the system up into. 47The most obvious application being for laptops to provide a network 48and non-network environment after a successful boot into multi-user mode. 49.Ss Background 50In order to accomplish this task, the files usually associated with 51establishing the current system's running configuration are replaced with 52symbolic links which are adjusted with each boot to point to the appropriate 53file for the desired run-time environment. 54This is accomplished by directing all of the symbolic links through a 55directory which itself is a symbolic link 56.Pq Pa /etc/etc.current , 57to the destination files. 58At each bootup, the selection made changes which directory 59.Pa /etc/etc.current 60points to. 61.Pp 62Through doing this and reloading 63.Pa /etc/rc.conf 64in 65.Pa /etc/rc 66after the link has 67been established, the resulting run-time configuration is effectively 68controlled without the need to directly edit any files. 69The default boot-up environment is selected by manually directing which 70configuration directory 71.Pa /etc/etc.default 72points to. 73As opposed to 74.Pa /etc/etc.current 75(which is updated 76with every boot), 77.Pa /etc/etc.default 78is not automatically updated. 79.Ss Getting Started 80By default, 81.Dx 82only has one boot-up configuration - that set in the 83file 84.Pa /etc/rc.conf . 85In order to initialize the system for operating in a 86manner which supports multiple boot configurations, 87.Nm 88must be run with an argument of 89.Sq init . 90This will create two symbolic links 91.Pa /etc/etc.current 92and 93.Pa /etc/etc.default 94to the directory 95.Pa /etc/etc.network . 96The following files are all moved into 97that directory and symbolic links put in their place, in 98.Pa /etc , 99pointing to 100.Pa /etc/etc.current/\*[Lt]filename\*[Gt] : 101.Bd -literal -offset indent 102/etc/defaultdomain 103/etc/dntpd.conf 104/etc/fstab 105/etc/ifconfig.* 106/etc/inetd.conf 107/etc/mrouted.conf 108/etc/mygate 109/etc/myname 110/etc/netstart 111/etc/nsswitch.conf 112/etc/rc.conf 113/etc/rc.conf.d 114/etc/resolv.conf 115.Ed 116.Pp 117To test that this has been performed correctly, reboot your system into 118.Dx . 119After the kernel has autoconfigured and tty flags have been set, 120a prompt should appear, preceded by the following like, looking like this: 121.Bd -literal 122[network] 123Which configuration [network] ? 124.Ed 125.Pp 126The []'s are used to indicate the default configuration, which can be 127selected by just pressing return. 128If there were other configurations available at this stage, you would 129have 30 seconds to enter that name and press 130.Sy RETURN . 131.Ss Multiple Configurations 132Once an initial configuration has been set up, we can proceed to set up further 133run time environments. 134This is done by invoking 135.Nm 136with the name of the new configuration to be created. 137By default, this step 138will use the current configuration files as the basis for this setup unless 139a second parameter is given - that of the configuration to use as the basis 140for the new one. 141Upon completion, a new directory, 142.Pa /etc/etc.\*[Lt]newname\*[Gt] , 143will have been created, 144priming the directory with the appropriate files for editing. 145For example, if we do 146.Nm 147.Ar nonet network 148it would create a directory named 149.Pa /etc/etc.nonet 150and copy all the files from 151.Pa /etc/etc.network 152into that directory. 153Upon rebooting, we should see: 154.Bd -literal 155[network] nonet 156Which configuration [network] ? 157.Ed 158.Pp 159To set up the system for booting into the 160.Dq nonet 161configuration, the files in 162.Pa /etc/etc.nonet 163need be edited. 164.Pp 165If you wanted to make 166.Dq nonet 167the default configuration when booting, you 168would need delete the symbolic link 169.Pa /etc/etc.default 170and create a new symbolic link (with the same name) to 171.Pa /etc/etc.nonet . 172Booting up after having made such a change would 173result in the following being displayed: 174.Bd -literal 175network [nonet] 176Which configuration [nonet] ? 177.Ed 178.Ss \&No Network 179Assuming that we performed the above command successfully, in order to 180successfully configure 181.Dx 182to not configure interfaces (or generate no 183errors from attempting to do so), the following settings (at least) should 184be used in 185.Pa /etc/etc.nonet/rc.conf : 186.Bd -literal 187auto_ifconfig=NO 188net_interfaces=NO 189.Ed 190.Pp 191Of course other networking services, such as NTP, routed, etc, are all 192expected to be 193.Dq NO . 194In general, the only setting that should be 195.Dq YES 196is syslogd, and perhaps cron (if your cron scripts don't 197need the network) or screenblank/wscons (if applicable). 198Other actions such as deleting any NFS mounts from 199.Pa /etc/etc.nonet/fstab 200would also need to be undertaken. 201.Ss Reverting multiple boot configurations 202Multiple boot configurations can be deactivated by running 203.Nm 204with an argument of 205.Cm revert . 206All the symlinks mentioned above are then removed and the files they point to 207are copied to their default place. 208This effectively makes the currently selected 209configuration the only one active. 210The symbolic links 211.Pa /etc/etc.current 212and 213.Pa /etc/etc.default 214are also removed so upon rebooting no configuration selection menu is 215displayed. 216Note that the previously created configurations (in 217.Pa /etc/etc.\*[Lt]name\*[Gt] ) 218are not removed. 219.Sh FILES 220.Bl -tag -width /etc/mrouted.current -compact 221.It Pa /etc/etc.current 222Symbolic link to current config directory. 223.It Pa /etc/etc.default 224Symbolic link to default config directory. 225.Pp 226.It Pa /etc/defaultdomain 227These files all become symbolic links. 228.It Pa /etc/dntpd.conf 229.It Pa /etc/fstab 230.It Pa /etc/ifconfig.* 231.It Pa /etc/inetd.conf 232.It Pa /etc/mrouted.conf 233.It Pa /etc/mygate 234.It Pa /etc/myname 235.It Pa /etc/netstart 236.It Pa /etc/nsswitch.conf 237.It Pa /etc/rc.conf 238.It Pa /etc/rc.conf.d 239.It Pa /etc/resolv.conf 240.El 241.Sh SEE ALSO 242.Xr rc.conf 5 , 243.Xr rc 8 244.Sh HISTORY 245The 246.Nm 247program first appeared in 248.Nx 1.5 . 249.Sh AUTHORS 250.An -nosplit 251This shell script was written by 252.An Darren Reed Aq Mt darrenr@NetBSD.org 253with initial input from 254.An Matthew Green Aq Mt mrg@NetBSD.org 255on how to approach this problem. 256.Sh BUGS 257It presently does not display a count down timer whilst waiting for input 258to select which configuration and nor does it abort said timer when a key 259is first pressed. 260.Pp 261The management of the overall collection of multiple configurations is much 262more manual than it ought to be. 263A general system configuration tool needs to be written to ease their 264management. 265