Installing Ubuntu Linux with FAI: Difference between revisions
m (RobertMarkula moved page Installing Ubuntu Linux with FAI to Installing Ubuntu 12.04 with FAI 3.4.8: This page is describing an old version of Ubuntu and is mising some information.) |
m (RobertMarkula moved page Installing Ubuntu 12.04 with FAI 3.4.8 to Installing Ubuntu Linux with FAI over redirect) |
Revision as of 19:43, 22 September 2014
FAI works on Ubuntu out-of-the-box. Packages are available in Ubuntu. Have a look at http://fai-project.org/download/
This Document will explain how to use FAI on Ubuntu to install an Ubuntu-based host. For the sake of this example it is assumed you will use Ubuntu 12.04 64-Bit [1] as the FAI server and the stock Ubuntu FAI packages (which should be fai-server 3.4.8ubuntu2 at the time of this writing) [2]. Once done you should be able to install not only Ubuntu-based hosts, but basically any other debian-based distribution using a single NFSroot.
You need the following prerequisites in your network:
- Working DNS and DHCP infrastructure (plus DHCP configured to point to your TFTP server)
- Ubuntu 12.04 (64-bit) on the FAI server
- TFTP on the FAI server
- Adequate knowledge on the workings of DNS, DHCP, PXE and TFTP.
I won't be explaining all the details on how to setup FAI as this is pretty much explained in the FAI docs.
Basic installation
On your Ubuntu 12.04 host, install the following packages:
apt-get install tftpd-hpa apt-get install fai-server fai-doc apt-get install nfs-kernel-server
Configuring TFTP
You need to point the TFTP server to where the PXE environment will be placed later on. Open the file /etc/default/tftpd-hpa
and change the line
TFTP_DIRECTORY="/var/lib/tftpboot"
to:
TFTP_DIRECTORY="/srv/tftp/fai"
Create this directory:
mkdir -p /srv/tftp/fai chmod 755 /srv/tftp/fai
Restart the TFTP server to enable the new settings:
service tftpd-hpa restart
Configuring FAI
You will configure FAI so you will be able to install different distributions, versions and architectures using a single FAI instance.
It basically works like this: You will use a single NFSroot. The NFSroot basically is the installer that will later install the target environment. It is only temporarily used during install of the host and will be discarded with the first reboot after the host has been successfully installed.
To install different target environments (architectures, versions and distributions) you will use custom basefiles and custom sources.lists.
Configuring FAI and preparing the NFS root
Configure fai. Open the file /etc/fai/fai.conf
and set/add the following options:
SERVER=faiserver.example.com FAI_CONFIGDIR=/srv/fai/config FAI_CONFIG_SRC=nfs://$SERVER$FAI_CONFIGDIR LOGUSER=fai LOGSERVER=$SERVER monserver=$SERVER
Next you will create a 'precise' NFSroot. Open the file /etc/fai/make-fai-nfsroot.conf
and change the line
FAI_DEBOOTSTRAP="squeeze http://cdn.debian.net/debian"
to:
FAI_DEBOOTSTRAP="precise http://archive.ubuntu.com/ubuntu"
You still need to configure the sources.list in order to get the correct packages. Open the file /etc/fai/apt/sources.list
and replace the contents with these lines:
deb http://de.archive.ubuntu.com/ubuntu/ precise main restricted deb-src http://de.archive.ubuntu.com/ubuntu/ precise main restricted deb http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted deb http://de.archive.ubuntu.com/ubuntu/ precise universe deb-src http://de.archive.ubuntu.com/ubuntu/ precise universe deb http://de.archive.ubuntu.com/ubuntu/ precise-updates universe deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates universe deb http://de.archive.ubuntu.com/ubuntu/ precise multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ precise multiverse deb http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse deb http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu precise-security main restricted deb-src http://security.ubuntu.com/ubuntu precise-security main restricted deb http://security.ubuntu.com/ubuntu precise-security universe deb-src http://security.ubuntu.com/ubuntu precise-security universe deb http://security.ubuntu.com/ubuntu precise-security multiverse deb-src http://security.ubuntu.com/ubuntu precise-security multiverse deb http://extras.ubuntu.com/ubuntu precise main deb-src http://extras.ubuntu.com/ubuntu precise main
Finally you'll manually create a FAI user so the target host can copy the FAI install logs to the FAI server:
adduser --system --disabled-password --home /var/log/fai --gecos "FAI account for log files" fai
Next, create the logdir with the appropriate permissions:
mkdir /var/log/fai chown fai /var/log/fai
You're ready to start building the NFSroot:
fai-setup -v
Configuring the Configspace
The FAI configspace needs to be adapted in order to accomplish two goals: (1) compatibility with Ubuntu in general and (2) enabling different target environments. First, copy the example FAI configspace to the final directory:
cp -a /usr/share/doc/fai-doc/examples/simple/* /srv/fai/config
The kernel package is named differently in Ubuntu than in the examples provided. So open the file /srv/fai/config/package_config/DEFAULT
and replace all occurences of the linux kernel (i.e. linux-image-2.6-486 and linux-image-2.6-amd64) with:
linux-image-generic
The next, important step is to distribute custom apt sources.lists. Using these instructions you can deploy various sources.lists for various distributions and versions. This way, you can use FAI to install e.g. Ubuntu 12.04 and Ubuntu 14.04. In this example, you will use FAI to install Ubuntu 14.04 on the target systems.
Create a file called /srv/fai/config/files/etc/apt/sources.list/OS_UBUNTU_1404_X64
and paste the following contents to this file (which is basically a sources.list from an existing Ubuntu 14.04 machine):
#deb cdrom:[Ubuntu 14.04 LTS _Trusty Tahr_ - Release amd64 (20140417)]/ trusty main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://de.archive.ubuntu.com/ubuntu/ trusty main restricted deb-src http://de.archive.ubuntu.com/ubuntu/ trusty main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates main restricted deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://de.archive.ubuntu.com/ubuntu/ trusty universe deb-src http://de.archive.ubuntu.com/ubuntu/ trusty universe deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates universe deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://de.archive.ubuntu.com/ubuntu/ trusty multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ trusty multiverse deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://de.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu trusty-security main restricted deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted deb http://security.ubuntu.com/ubuntu trusty-security universe deb-src http://security.ubuntu.com/ubuntu trusty-security universe deb http://security.ubuntu.com/ubuntu trusty-security multiverse deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu trusty partner # deb-src http://archive.canonical.com/ubuntu trusty partner ## This software is not part of Ubuntu, but is offered by third-party ## developers who want to ship their latest software. deb http://extras.ubuntu.com/ubuntu trusty main deb-src http://extras.ubuntu.com/ubuntu trusty main
In order for the system to accept the above sources.list you need to distribute suitable apt GPG keys. Just copy over the following files from an existing Ubuntu 14.04 system (may just be a live CD) and rename them accordingly to:
/srv/fai/config/files/etc/apt/trustdb.gpg/OS_UBUNTU_1404_X64 /srv/fai/config/files/etc/apt/trusted.gpg/OS_UBUNTU_1404_X64
Now you need a hook that copies these files to the target system. Create a file called /srv/fai/config/hooks/updatebase.FAIBASE
and paste the following content:
#! /bin/bash # Import custom apt sources.list and apt keys. echo "Preparing apt" fcopy -v /etc/apt/sources.list fcopy -v /etc/apt/trustdb.gpg fcopy -v /etc/apt/trusted.gpg # Initialize apt-key before apt is called the first time if [ -x $target/usr/bin/apt-key ]; then echo "Apt: list of keys" $ROOTCMD /usr/bin/apt-key list fi # Copy the console-setup file early to avoid unnecessary # error messages fcopy -v /etc/default/console-setup
Creating the basefile
For each target environment - e.g. Ubuntu 12.04, Ubuntu 14.04 - and architecture - i386, amd64 - you need to create a separate basefile.
The easiest and fastest way to do so is downloading the desired target version (in this example it is assumed you want to use Ubuntu 14.04 64-bit as target environment) and create a Live USB with it.
Then you boot into the Live USB. You open a terminal and update the live system first:
apt-get update apt-get dist-upgrade
Then you install the required packages to create the basefile:
apt-get install pbuilder debootstrap
Important: Due to a bug [3] pbuilder will build a 'saucy' basefile by default. This is not what you want. So you need to open the file /usr/share/pbuilder/pbuilderrc
and change the line
DISTRIBUTION = saucy
to
DISTRIBUTION = trusty
Then you can start building the basefile:
pbuilder create
The finished basefile is in /var/cache/pbuilder/base.tgz
. Now copy this basefile to your FAI-Server:
scp /var/cache/pbuilder/base.tgz root@faiserver.example.com:
You can now shutdown and discard the live environment; you don't need it anymore.
On the FAI server, you create a 'basefile' directory in your FAI configspace and copy the basefile to this directory:
mkdir /srv/fai/config/basefiles cp /root/base.tgz /srv/fai/config/OS_UBUNTU_1404_X64.tar.gz
The basefile needs to have a certain filename extension, so the command above did the renaming already.
Final steps
And that's it. The last thing you need to do is tell FAI which hosts should get which operating system using the classes/50-hosts
file.
I.e. if you want to install Ubuntu 14.04 on the host 'cray', and - once you've prepared your system for the additional version using the steps above - Ubuntu 12.04 on the host 'sgi', then you simple add the corresponding classes to your 50-hosts
file:
cray) echo "FAIBASE DHCPC OS_UBUNTU_1404_X64" ;; sgi) echo "FAIBASE DHCPC OS_UBUNTU_1204_X64" ;;
The configspace can be edited anytime without the need to re-run fai-setup or makenfsroot.
Comments
[1] You could use Ubuntu 12.04 32-bit as well, but then you will be limited to installing 32-bit hosts only. With 64-bit on the FAI server, you have the freedom to install both 32- and 64-bit-hosts.
[2] For the sake of this article you won't use the FAI PPA and instead use stock FAI packages from the Ubuntu repositories.
[3] https://bugs.launchpad.net/ubuntu/+source/pbuilder/+bug/1316423