Hack 77 Automated Install


figs/moderate.gif figs/hack77.gif

If you're responsible for installing multiple systems, hopefully you've discovered the art of automating installs.

Most operating systems have some sort of scripting mechanism that allows you to predefine the answers to the questions asked by the install program. Once you've started the actual install, you can leave and return to a fully installed system. The alternative is to sit there, answering every prompt when it appears. No, thank you!

Even as a home user, it's well worth your while to spend a few minutes customizing the install script that comes with FreeBSD. Try this hack once and you'll never want to sit and watch an install again.

8.2.1 Preparing the Install Script

Before installing any system, you need to know the following:

  • The IP settings and hostname of the host you're installing

  • The FreeBSD name of that host's NIC

  • Which distributions, or parts of the OS, to install

  • Your desired partitioning scheme

  • Which packages (applications) to install

Of course, it's always a good idea to record this information and include it with the documentation for the system.

FreeBSD's install mechanism lives in /stand/sysinstall. Not surprisingly, man sysinstall describes all of the scriptable bits of this program. I'll go over some useful parameters, but you'll definitely want to skim through the manpage to see if there are additional parameters suited to your particular environment.

FreeBSD also comes with a commented, ready-to-customize install script, located in /usr/src/usr.sbin/sysinstall/install.cfg. Copy this file, then edit the copy in your favorite editor. Start by inserting your own network settings:

# This is the installation configuration file for my test machine, # crate.cdrom.com. # It is included here merely as a sort-of-documented example. # # $FreeBSD: src/usr.sbin/sysinstall/install.cfg,v 1.11 2001/09/06 10:04:27 murray Exp $ # Turn on extra debugging. debug=yes ################################ # My host specific data hostname=crate.cdrom.com domainname=cdrom.com nameserver=204.216.27.3 defaultrouter=204.216.27.228 ipaddr=204.216.27.230 netmask=255.255.255.240 ################################

Replace the example network information with the name and IP settings associated with the specific host you'd like to install. If you're using DHCP to obtain this information, fill in the hostname line and replace the other lines with:

tryDHCP=YES

Next, replace the name of the NIC and the path to the FTP site. In this example, the NIC is rl0 and I'm using the default FTP site:

################################ # Which installation device to use  _ftpPath=ftp://ftp.freebsd.org/pub/FreeBSD/ netDev=rl0 mediaSetFTP ################################

Next come the desired distributions. (See man sysinstall for more details.) Include them all on the one dists= line, separated by a space:

################################ # Select which distributions we want. dists=bin doc games manpages dict compat4x ports src sbase ssys Xbin Xcfg \       Xdoc Xlib Xman Xset Xfnt Servers/XS3V Xfsrv distSetCustom ################################

Note that distSetCustom allows you to customize which distributions to install. If you'd like to install the works, use distSetEverything and don't specify any dists=.


The partitioning scheme section is very important. If you don't want to use the default scheme which uses the entire disk, read this section of the manpage carefully.

Also, the default file gives examples for three disks. Make sure you remove the examples and replace them with your own partitioning scheme.

The following example is the equivalent of choosing a for "all," followed by a for "auto defaults":

############################################################# # Set the parameters for the partition editor # ad = IDE, da = SCSI disk=ad0 partition=exclusive diskPartitionEditor ############################################################# # - All sizes are expressed in 512 byte blocks! # - "Size in MB" = sectors * 512 / 1024 / 1024  # - "Number of blocks" = xsize in mb * 1024 * 1024 / 512 # The non-zero value after the mountpoint means enable soft updates # 256MB UFS ad0s1a ad0s1-1=ufs 524288 / # 240MB SWAP ad0s1b ad0s1-2=swap 491520 none # 256MB UFS ad0s1d ad0s1-3=ufs 524288 /var # 256MB UFS ad0s1e ad0s1-4=ufs 524288 /tmp # Rest of FreeBSD partition ad0s1f ad0s1-5=ufs 0 /usr diskLabelEditor # runs diskLabelCommit diskPartitionWrite installCommit

Finally, list which applications you would like to install. List each package on its own line, followed by the packageAdd command:

# Install some packages at the end. package=fetchmail-6.2.0 packageAdd package=pine-4.55 packageAdd package=lynx-2.8.5d14 packageAdd

The FreeBSD package list (ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/5.1-RELEASE/packages/All) has the exact names of each available package. Replace i386/5.1-RELEASE with your platform and desired operating system version.

8.2.2 Test-Drive

Now that you've created a customized version of install.cfg, prepare a freshly formatted UFS floppy:

# fdformat -f 1440 /dev/fd0 # bsdlabel -w /dev/fd0 fd1440 # newfs /dev/fd0

Once the floppy is ready, copy install.cfg onto it.

On a test system, start the install process either by booting from a FreeBSD CD-ROM/DVD or with the two install floppies. When you receive the sysinstall Main Menu screen, choose Load Config. Insert the floppy containing your customized install.cfg and press OK. Once the configuration file has been loaded, you'll receive the message You may remove the floppy from floppy drive unit A.

While this is meant to be an unattended install, you should be present during your first test install. This will give you the opportunity to ensure that your script runs smoothly, without hanging at any portion of the install. If it does hang, check your install.cfg for a typo in that section.

Once the install is complete, you'll return to the sysinstall Main Menu. At this point, you can either configure the system interactively by choosing Configure or use a prepared post-configuration script, as found in /usr/doc/en_US.ISO8859-1/articles/pxe/post.

install.cfg is not responsible for post-install configuration.


Once you're happy with your floppy, label it with your operating system version. Store it where you can find it the next time you're ready to install a version of that operating system.

8.2.3 See Also

  • man sysinstall

  • /usr/src/usr.sbin/sysinstall/install.cfg (the sample installation configuration file)



BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net