Difference between revisions of "Creating an Automated Installation with pc-sysinstall/9.2"

From PC-BSD Wiki
Jump to: navigation, search
(Additional Reading)
(Create a Customized Configuration)
Line 301: Line 301:
 
|-
 
|-
 
|}
 
|}
 +
 +
=== Sample pc-sysinstall.cfg ===
 +
<nowiki>
 +
# Sample configuration file for an installation using pc-sysinstall
 +
 +
installMode=fresh
 +
installInteractive=no
 +
hostname=myhost.mydomain.com
 +
 +
# Set the disk parameters - 1st disk
 +
disk0=da0
 +
partition=all
 +
bootManager=none
 +
commitDiskPart
 +
 +
# Set the disk parameters - 2nd disk
 +
disk1=da1
 +
partition=all
 +
bootManager=none
 +
commitDiskPart
 +
 +
# Setup the disk label - 1st disk
 +
# All sizes are expressed in MB
 +
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
 +
disk0-part=UFS+S 1024 /
 +
disk0-part=SWAP.eli 2048 none
 +
disk0-part=UFS+S 1024 /tmp
 +
disk0-part=UFS+S 1024 /var
 +
disk0-part=UFS+S 0 /usr
 +
# Size 0 means use the rest of the slice size
 +
# Do it now!
 +
commitDiskLabel
 +
 +
# Setup the disk label - 2nd disk
 +
# All sizes are expressed in MB
 +
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
 +
disk1-part=UFS+S 1024 /usr/src
 +
disk1-part=UFS+S 4096 /usr/local
 +
disk1-part=UFS+S 0 /usr/ports
 +
# Size 0 means use the rest of the slice size
 +
# Do it now!
 +
commitDiskLabel
 +
 +
netDev=em1
 +
netIP=172.16.80.250
 +
netMask=255.255.240.0
 +
netNameServer=172.16.80.1
 +
netDefaultRouter=172.16.80.1
 +
netSaveDev=em0 em1
 +
netSaveIP_em0=192.168.101.42
 +
netSaveIP_em1=172.16.80.156
 +
netSaveMask_em0=255.255.252.0
 +
netSaveMask_em1=255.255.240.0
 +
netSaveNameServer=172.16.80.1
 +
netSaveDefaultRouter=192.168.100.1
 +
 +
# Set if we are installing via optical, USB, or FTP
 +
installType=FreeBSD
 +
installMedium=ftp
 +
ftpPath=http://pkgbuilder.mydomain.com/images/freebsd/8.2/
 +
packageType=tar
 +
 +
# List our components to install
 +
#installComponents=ports,src
 +
 +
# Set the root pass
 +
rootPass=root
 +
 +
# Setup our users
 +
userName=demo
 +
userComment=Demo User
 +
userPass=demo
 +
userShell=/bin/sh
 +
userHome=/home/demo
 +
commitUser
 +
 +
# Set up date/time
 +
runCommand=cp /usr/share/zoneinfo/EST5EDT /etc/localtime
 +
runCommand=touch /etc/wall_cmos_clock
 +
runCommand=adjkerntz -a
 +
 +
# Install packages required for VMware Tools installation/configuration
 +
runCommand=pkg_add -r compat6x-amd64
 +
runCommand=pkg_add -r perl
 +
runCommand=pkg_add -r pcre
 +
runCommand=pkg_add -r puppet
 +
runCommand=pkg_add -r sysrc
 +
 +
# Fetch/install VMware Tools
 +
runCommand=fetch -o /tmp/vmtools.tar.gz http://pkgbuilder.mydomain.com/images/freebsd/vmware-freebsd-tools.tar.gz
 +
runCommand=zcat /tmp/vmtools.tar.gz | tar -C /tmp -xvf -
 +
runCommand=/tmp/vmware-tools-distrib/vmware-install.pl -d
 +
runCommand=rm -rf /tmp/vmware-tools-distrib
 +
runCommand=/usr/local/sbin/sysrc puppet_enable=YES
 +
# Generate the certificate to be signed by the master
 +
runCommand=/usr/local/bin/puppet agent -t
 +
</nowiki>
  
 
=== Create a Custom Installation Media ===
 
=== Create a Custom Installation Media ===

Revision as of 11:43, 22 August 2012

(Sorry for the inconvenience)

PC-BSD provides a set of Bourne shell scripts that allow advanced users to create automatic or customized PC-BSD installations. pc-sysinstall is the name of the master script; it reads a customizable configuration file and uses dozens of backend scripts to perform the installation. You can read more about this utility by typing man pc-sysinstall.

Here is a quick overview of the components used by pc-sysinstall:

  • /usr/share/pc-sysinstall/backend/ contains the scripts used by the PC-BSD installer. Scripts have been divided by function such as functions-bsdlabel.sh and functions-installcomponents.sh. If you have ever wondered how the PC-BSD installer works, read through these scripts. This directory also contains the parseconfig.sh and startautoinstall.sh scripts which pc-sysinstall uses to parse the configuration file and begin the installation.
  • /usr/share/pc-sysinstall/backend-partmanager/ contains the scripts which are used by the installer to create and delete partitions.
  • /usr/share/pc-sysinstall/backend-query/ contains the scripts which are used by the installer to detect (e.g. detect-nics.sh) and configure (e.g. enable-net.sh) hardware.
  • /usr/share/pc-sysinstall/components/ contains FreeBSD ports and src and the PBIs for chromium, firefox, opera, and thunderbird.
  • /usr/share/pc-sysinstall/conf/ contains the configuration file pc-sysinstall.conf. It also contains a file indicating which localizations are available (avail-langs), a list of files which are not touched during an upgrade (exclude-from-upgrade), and a license/ subdirectory containing text files of applicable licenses (e.g. bsd-en.txt and nvidia-en.txt).
  • /usr/share/pc-sysinstall/doc/ contains the help text that is seen if you run pc-sysinstall without any arguments.
  • /usr/share/examples/pc-sysinstall/ contains several example configuration files for different scenarios (e.g. upgrade, fbsd-netinstall). The README file in this directory should be considered as mandatory reading before using pc-sysinstall.
  • /usr/sbin/pc-sysinstall this is the script that is used to perform a customized installation.

To create a custom installation, perform the following steps:

1. Determine which variables you wish to customize.

2. Create a customized configuration.

3. Create a custom installation media.

These steps are discussed in more detail below.

Contents

Determine Which Variables you Wish to Customize

A list of possible variables can be found in /usr/share/examples/pc-sysinstall/README and in Table 5.4a. Note that the Table is meant as a quick reference to determine which variables are available. The README file contains more complete descriptions for each variable.

Table 5.4a: Available Variables for Customizing a PC-BSD Installation

Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates. Please use alternative templates.
Table 5.5needs a caption: {{tbl-init|caption=a. is the caption}} Please use alternative templates. Please use alternative templates. Please use alternative templates.

Create a Customized Configuration

One way to create this file is to read through the configuration examples in /usr/share/examples/pc-sysinstall/ to find the one that most closely matches your needs. Copy that file (to any location) and customize it so that it includes the variables and values you would like to use in your installation.

An alternate way to create this file is to perform an installation of the version that you wish to customize. The installer will automatically create a file containing the settings you selected during the installation to /root/pc-sysinstall.cfg. You can use that configuration file as-is or customize it to meet an installation's needs. This method may prove easier to use if you are performing complex disk layouts.

If you wish to perform a fully automated installation that does not prompt for any user input, you will also need to review /usr/share/examples/pc-sysinstall/pc-autoinstall.conf and place a customized copy of that file into /boot/pc-autoinstall.conf on your installation media.

Table 5.4b summarizes the additional variables that are available for fully automatic installations. More detailed descriptions can be found in the /usr/share/examples/pc-sysinstall/pc-autoinstall.conf file. Note that the variables in this file use a different syntax than those in Table 5.4a in that the values follow a colon and space rather than the equals sign.

Table 5.4b.: Additional Variables for Automated Installations

Table 5.5needs a caption: {{tbl-init|caption=a. is the caption}} Please use alternative templates. Please use alternative templates. Please use alternative templates.
pc_config URL or /path/to/file location of customized pc-sysinstall.conf
confirm_install yes or no should be set to yes, otherwise booting the wrong disk will result in a system wipe
shutdown_cmd e.g. shutdown -p now good idea to run a shutdown, but can be any command/script you wish to execute post-install
nic_config dhcp-all or <interface name> <IP address> <subnet mask> will attempt dhcp on all found NICs until the installation file can be fetched or will setup specified interface
nic_dns IP address DNS server to use
nic_gateway IP address default gateway to use

Sample pc-sysinstall.cfg

# Sample configuration file for an installation using pc-sysinstall

installMode=fresh
installInteractive=no
hostname=myhost.mydomain.com

# Set the disk parameters - 1st disk
disk0=da0
partition=all
bootManager=none
commitDiskPart

# Set the disk parameters - 2nd disk
disk1=da1
partition=all
bootManager=none
commitDiskPart

# Setup the disk label - 1st disk
# All sizes are expressed in MB
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
disk0-part=UFS+S 1024 / 
disk0-part=SWAP.eli 2048 none
disk0-part=UFS+S 1024 /tmp
disk0-part=UFS+S 1024 /var
disk0-part=UFS+S 0 /usr
# Size 0 means use the rest of the slice size
# Do it now!
commitDiskLabel

# Setup the disk label - 2nd disk
# All sizes are expressed in MB
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
disk1-part=UFS+S 1024 /usr/src 
disk1-part=UFS+S 4096 /usr/local
disk1-part=UFS+S 0 /usr/ports
# Size 0 means use the rest of the slice size
# Do it now!
commitDiskLabel

netDev=em1
netIP=172.16.80.250
netMask=255.255.240.0
netNameServer=172.16.80.1
netDefaultRouter=172.16.80.1
netSaveDev=em0 em1 
netSaveIP_em0=192.168.101.42
netSaveIP_em1=172.16.80.156
netSaveMask_em0=255.255.252.0
netSaveMask_em1=255.255.240.0
netSaveNameServer=172.16.80.1
netSaveDefaultRouter=192.168.100.1

# Set if we are installing via optical, USB, or FTP
installType=FreeBSD
installMedium=ftp
ftpPath=http://pkgbuilder.mydomain.com/images/freebsd/8.2/
packageType=tar

# List our components to install
#installComponents=ports,src

# Set the root pass
rootPass=root

# Setup our users
userName=demo
userComment=Demo User
userPass=demo
userShell=/bin/sh
userHome=/home/demo
commitUser

# Set up date/time
runCommand=cp /usr/share/zoneinfo/EST5EDT /etc/localtime
runCommand=touch /etc/wall_cmos_clock
runCommand=adjkerntz -a

# Install packages required for VMware Tools installation/configuration
runCommand=pkg_add -r compat6x-amd64
runCommand=pkg_add -r perl
runCommand=pkg_add -r pcre
runCommand=pkg_add -r puppet
runCommand=pkg_add -r sysrc

# Fetch/install VMware Tools
runCommand=fetch -o /tmp/vmtools.tar.gz http://pkgbuilder.mydomain.com/images/freebsd/vmware-freebsd-tools.tar.gz
runCommand=zcat /tmp/vmtools.tar.gz | tar -C /tmp -xvf -
runCommand=/tmp/vmware-tools-distrib/vmware-install.pl -d
runCommand=rm -rf /tmp/vmware-tools-distrib
runCommand=/usr/local/sbin/sysrc puppet_enable=YES
# Generate the certificate to be signed by the master
runCommand=/usr/local/bin/puppet agent -t
 

Create a Custom Installation Media

The installation media can be a CD, DVD, USB, or a directory on an HTTP, FTP, or SSH+rsync server.

The easiest way to create a custom installation media is to modify an existing installation image. For example, if you have downloaded an ISO for the PC-BSD version that you wish to customize, the superuser can access the contents of the ISO as follows:

mdconfig -a -t vnode -f PCBSD9.0-x86-DVD.iso -u 1
mount -t cd9660 /dev/md1 /mnt

Make sure you have cd 'd into a directory where you would like to copy the contents of the ISO. In the following examples, /tmp/custominstall/ was created for this purpose:

cd /tmp/custominstall
tar -C /mnt -cf - . | tar -xvf -
umount /mnt

Alternately, if you have inserted an installation CD or DVD, you can mount the media and copy its contents to your desired directory:

mount -t cd9660 /dev/cd0 /mnt
cp -R /mnt/* /tmp/custominstall/
umount /mnt

NOTE: if you are using an HTTP, FTP, or SSH server as the installation media, untar or copy the files to a directory on the server that is accessible to users. Be sure to configure the server so that the installation files are accessible to the systems that you wish to install.

If you are creating an automated installation, copy your customized pc-autoinstall.conf to /tmp/custominstall/boot/.

Copy your customized configuration file to /tmp/custominstall/. Double-check that the installMedium= variable in your customized configuration file is set to the type of media that you will be installing from.

You may also need to add some extra files if you set the following variables in your custom configuration file:

  • installComponents= make sure that any extra components you wish to install exist in extras/PBI/ (if they end in the .pbi extension) or extras/components/ (if they end in .tbz)
  • runCommand= make sure the command exists in the specified path
  • runScript= make sure the script exists in the specified path
  • runExtCommand= make sure the command exists in the specified path

If the installation media is a CD or DVD, you will need to create a bootable media that contains the files in your directory. To create a bootable ISO:

cd /tmp/custominstall
mkisofs -V mycustominstall -J -R -b boot/cdboot -no-emul-boot -o myinstall.iso

You can then use your favorite burning utility to burn the ISO to the media.

To begin an installation that requires user interaction:

pc-sysinstall -c /path_to_your_config_file

To begin a fully automated installation, insert the installation media and reboot.

In a PXE boot environment, cp your pc-sysinstall.conf file to /boot/ on the PXE Boot Install Server. Then, setup a call in /etc/rc.local that runs this command:

pc-sysinstall start-autoinstall /boot/pc-autoinstall.conf

That will start the installation process, fetch your main configuration file, and perform the actual installation.

Additional Reading

References

  1. http://bsdmag.org/magazine/1741-nanobsd-and-alix/
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox