ECE-ITS FAI (Fully Automatic Installation) Docs


$Id: index.html,v 1.4 2005/06/06 02:24:18 credmon Exp credmon $
What is FAI?
Why use FAI?
Scripting
Install Process
Classes
RAID
RAID Scripts

What is FAI?

FAI (Fully Automatic Installation) is an installer for Linux, as well as other *nixes, which can be extensively customized using scripts that change the way the install process works. This allows not only for the automation of an install process, but the possibility for dynamic install types. You could use FAI to automate the deployment of servers, lab machines, or even the installation of particular machines on the event of a hardware failure.

If you are interested to learn more about FAI, you can visit the official website here: FAI (Fully Automatic Installation) Home Page.

Why use FAI?

Generally, you will need to use an automated installer if you are working in an environment which has many machines that need to be installed in a timely manner, and configured to do specific tasks. Since FAI can be heavily scripted, you can rely on installs to be consistently to your specifications, so long as you have correctly scripted the actions that need to take place to configure and install that system.

One main eason to install FAI is that it is fast. It is based off of a Debian base system, so the intial footprint is not much larger than 200MB. The user can then script in which packages should be added. This allows for the elimination of unnecessary software.

Overview

FAI is an automated installer. You can use FAI to install and completely configure your operating system to your likings. To do this, FAI uses a system of scripting to classify machines, and then to install and configure the packages.

The packaging system uses basic Debian packages, and FAI depends on a Debian mirror to install the packages. You can either use an official Debian mirror, or a local Debian mirror.

An FAI installation can be initialized by booting from a boot cd. The client will then retrieve an IP address, and mount the root disk over NFS. Therefore, an NFS server is required by FAI so clients can install.

Scripting

FAI uses scripts to accomplish the task of installing and configuring systems. These scripts can be written in most any scripting language, so long as you have the requred packages present on the NFS server. Scripts can either be executed on all machines, or on specific machines, depending on the classes which your machine is assigned on install. Scripts usually reside in your /usr/share/fai/scripts directory, from this directory, there are directories based on classes. FAI will enter the directories of which your machine is a class. If your machine was of class DEFAULT, then it would run the scripts in /usr/share/fai/scripts/DEFAULT. FAI runs scipts which are of name S**

  • many different scripting languages in which to program
  • 	bash, perl, cfengine, etc.
  • pretty much anything which is executable can be run
  • requires a certain level of understading of language and utilities
  • 	#!/bin/sh
    	# dump the partition table for these disks to standard output
    	disks=(/dev/hda /dev/hdb /dev/hdc /dev/hdd)
    	for $disk in ${disks[@]}; do
    		sfdisk -d $disk
    	done
    	
    	
    		

    Install Process

    FAI has its own init scripts and subroutines which it uses to install and configure a base system. tasks are actions which can be taken, and rcS_fai is the system init script. Below is a breakdown of the normal actions and tasks which can be taken by FAI.

    	FAI_ACTION=install
    		rcS_fai
    		fai_init
    		task_action
    		task_install
    		task_partition		- partition harddisks
    		task_mountdisks		- mount harddisks
    			- raidpartition
    		task_extrbase		- extract the base system
    		task_mirror		- mount debian mirror
    		task_updatebase		- update base system
    		task_instsoft		- install software packages
    		task_configure
    		task_finish		- installation finished
    		date
    		task_chboot		-
    		task_savelog
    		class
    
    	FAI_ACTION=sysinfo
    		task_sysinfo
    		task_faiend
    		die (spawn shell)
    

    Classes

    FAI uses classes to break down the install process. Classes can be assigned a variety of ways, by user choice, by hardware type, or IP address. Machines can also belong to more than one class, so a variety of types of installs can be created. Below are some examples of basic classes and subclasses which can be put into FAI.

  • ECE_SERVER - default system configuration
  • ECE_STAFF - system configured for ECE staff (ex. it support)
  • ECE_LABS - general lab systems, includes lab software (ex. matlab)
  • 	FH602 - Ferris Hall 602 lab machines, includes specific configurations, scripts, files
    	FH602_TA - Ferris Hall 602 TA machine, includes specific scrips differing from 602 lab
    	OTHER 
    
  • RAID - software raid
  • 	RAID0 - Striping mode, suggested 2 disks minimum 
    	RAID1 - Disk mirroring support, suggested 2 disks minimum
    	RAID4/5
    
  • PRESERVE - preserve files which are on an existing hard drive, and will be installed over with FAI, this is beneficial when you wan to preserve ssh keys after a reinstallation

  • RAID

    The following is a summary of the process which is used to script software RAId installation with FAI. See also the RAID scripts which were derived from this information.

    To install RAID on a host, first install the nescessary software.

    	aptitude install mdadm
    

    Then decide which mode you are going to do RAID with. If you are going to be using RAID1, for example, make sure your kernel is compiled with RAID1 support.

    	modprobe md lvm-mod raid1
    

    To create a RAID array on a disk which is not mounted on /, with two partitions on hda and hdb to be mirrors, chunk size 32, and 2 disks in the array, in RAID1 mode:

    	sfdisk -d /dev/hda > /tmp/hda.sfdisk
    	sfdisk --force /dev/hdb < /tmp/hda.sfdisk
    	mdadm --create --verbose /dev/md0 -l 1 -c 32 -n 2 /dev/hda1 /dev/hdb1
    	mke2fs -j -b 4096 -R stride=8 /dev/md0
    

    This will partition disk hdb the same as hda and the create a 2 disk RAID1 array, using partitions /dev/hda1 and /dev/hdb1. Specify other partitions as needed.

    To create a RAID array on /, there needs to be an intermediate step which you must take to boot off of the disk. To do this, you need and initrd. Install the needed packages to create an initrd, mount the initrd on loopback, and edit the linuxrc.

    	aptitde install initrd-tools
    	mkdir /var/tmp/initrd
    	mount -o loop /path/to/initrd.img /var/tmp/initrd
    

    Edit the linuxrc to reflect your system devices and init process. RAID arrays should be assembled on init, even the root array, and then root should pivoted so that root is on the desired RAID array.

    	#!/bin/bash
    	# : linuxrc,v 1.1 2004/07/16 21:07:36 credmon Exp $
    	if [ -e /proc/mounts ]; then
    		:
    	else
    		/bin/mount -nt proc proc proc
    	fi
    	
    	# fallback to creating array with less disks if some cannot be initialized ...
    	mdadm --assemble --run --force /dev/md0 /dev/hda1 /dev/hdc1 ||\
    	mdadm --assemble --run --force /dev/md0 /dev/hda1 ||\
    	mdadm --assemble --run --force /dev/md0 /dev/hdc1
    	
    	mdadm --assemble --run --force /dev/md1 /dev/hda6 /dev/hdc6 ||\
    	mdadm --assemble --run --force /dev/md1 /dev/hda6 ||\
    	mdadm --assemble --run --force /dev/md1 /dev/hdc6
    	
    	mdadm --assemble --run --force /dev/md2 /dev/hda7 /dev/hdc7 ||\
    	mdadm --assemble --run --force /dev/md2 /dev/hda7 ||\
    	mdadm --assemble --run --force /dev/md2 /dev/hdc7
    	
    	mdadm --assemble --run --force /dev/md3 /dev/hda8 /dev/hdc8 ||\
    	mdadm --assemble --run --force /dev/md3 /dev/hda8 ||\
    	mdadm --assemble --run --force /dev/md3 /dev/hdc8
    
    	mdadm --assemble --run --force /dev/md4 /dev/hda9 /dev/hdc9 ||\
    	mdadm --assemble --run --force /dev/md4 /dev/hda9 ||\
    	mdadm --assemble --run --force /dev/md4 /dev/hdc9
    	
    	/bin/mount -n -o rw /dev/md0 /md0
    	cd /md0
    	/sbin/pivot_root . initrd
    	cd /
    	# need the chroot which is not on ramdisk
    	exec sbin/chroot . sbin/init <dev/console >dev/console 2>&1
    
    Your can monitor the progress of your array from /proc/mdstat. Below is an example of an array that has just been created, and the disks are syncing.
    	
    	Personalities : [raid1] 
    	read_ahead 1024 sectors
    	md4 : active raid1 sdb9[1] sda9[0]
    	      3317312 blocks [2/2] [UU]
    	      [=>...................]  resync =  7.5% (250604/3317312) finish=5.0min speed=10024K/sec
    	md3 : active raid1 sdb8[1] sda8[0]
    	      28756224 blocks [2/2] [UU]
    	      	resync=DELAYED
    	md2 : active raid1 sdb7[1] sda7[0]
    	      843264 blocks [2/2] [UU]
    	      	resync=DELAYED
    	md1 : active raid1 sdb6[1] sda6[0]
    	      2048192 blocks [2/2] [UU]
    	      	resync=DELAYED
    	md0 : active raid1 sdb1[1] sda1[0]
    	      160512 blocks [2/2] [UU]
          
    	unused devices: <none>
    

    When the arrays are done syncing, you should unmount and stop the arrays. Also unmounting the initrd if you have not already done so. And then make the disks bootable.

    	umount /path/to/initrd
    	losetup -d /dev/loop0
    	umount /dev/md0
    	mdadm --stop /dev/md0
    
    	mount /dev/hda1 /path/to
    	grub-install --root-directory=/path/to /dev/hda
    	umount /dev/hda1
    
    	mount /dev/hdb1 /path/to
    	grub-install --root-directory=/path/to /dev/hdb
    	umount /dev/hdb1
    

    RAID Scripts

    Serveral scripts were written so that one could setup a system to use software RAID from an FAI installation. You can download some examples here. They have been developed and used with a 2.4 based Linux Kernel, slight modification may be needed for 2.6.