Bare Metal Provisioning of Linux (Proxmox) using FAI

By Neelesh Gurjar

What is Remote unattended installation?

Remote unattended installation means installation of remote server without any human interference.

This process is very useful for bare metal provisioning, automated installation on multiple servers, etc.

What is Proxmox?

Proxmox is debian based OS, which provides Virtualization Platform like VMware.

https://www.proxmox.com/en/

What is FAI?

FAI is a non-interactive system to install, customize and manage Linux systems and software configurations on computers as well as virtual machines and chroot environments, from small networks to large-scale infrastructures like clusters and cloud environments. It’s a tool for unattended mass deployment of Linux.

I have used “FAI-Fully Automatic Installation” to automate headless installation of Proxmox or Debian. http://fai-project.org/

In this example I have done Bare Metal Provisioning of Proxmox OS. We can do with any other Linux as well.

Components:

fai-server

DHCP server

NFS Server

TFTP Server

Basic Process:

– Client machine (On which Proxmox is going to be installed.) boots from Network PXE.

– It searches for DHCP Server.

– DHCP Server on FAIserver provides Network Details to Client such as IP address, Netmask, Gateway, etc. It also points clients to TFTP & NFS server.

– TFTP trasfers the kernel to Client Machine

– NFS Server Mounts the nfsroot on Client machine

– FAI Scripts starts the installation

Important Configurations files and folders of FAI:

/etc/fai/ – FAI configuration folder

/etc/fai/fai.conf – FAI configuration file

/etc/fai/nfsroot.conf – NFSroot configuration file

/etc/fai/apt/ – FAI repositories which will be used while installation

/srv/fai/config/ – FAI Client configuration space. It has scripts which will be used
while installation of Client

/srv/fai/package_config/ – Configurations related to Package installation

/srv/fai/disk_config/ – Configurations related to disk partition layout

/srv/fai/scripts – Miscellaneous scripts required for installations

/srv/fai/nfsroot – NFS Root file system which will be shared by NFS and will be
mounted as Root filesystem on client machine

/etc/dhcp/dhcpd.conf – DHCP configuration file

/etc/exports – NFS configuration file

/etc/default/tftpd-hpa – TFTP configuration file

/etc/hosts – Hosts declaration file / File DNS

Scenario:

Server Name: faiserver – 192.168.0.1

Client Name: demohost – 192.168.0.2

Steps:

Prepare FAI-Server:

1. Install Debian Wheezy with net-install ISO. Just install OpenSSH server nothing else on it.

2. Install Required Applications

apt-get -y install apache2 fai-quickstart fai-doc fai-server isc-dhcp-server
tftpd-hpa nfs-kernel-server syslinux-common

Create Local Debian Mirror:

ln -s /files/scratch/debmirror /var/www/debmirror

/usr/share/doc/fai-doc/examples/utils/mkdebmirror

/etc/init.d/apache2 restart

Configure /etc/hosts

Add below entries:

192.168.0.1 faiserver
192.168.0.2 demohost

Configure /etc/fai/fai.conf

SERVER=192.168.0.1
FAI_CONFIG_SRC=nfs://$SERVER/srv/fai/config
# Account for saving log files and calling fai-chboot.
LOGUSER=fai
FAI_LOGPROTO=ssh

Configure /etc/fai/nfsroot.conf

FAI_DEBOOTSTRAP=”wheezy http://http.debian.net/debian”

FAI_ROOTPW=’$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1′

NFSROOT=/srv/fai/nfsroot
TFTPROOT=/srv/tftp/fai
NFSROOT_HOOKS=/etc/fai/nfsroot-hooks/
FAI_DEBOOTSTRAP_OPTS=”–exclude=info”

# Configuration space
FAI_CONFIGDIR=/srv/fai/config

Configure /etc/fai/apt/sources.list

Add below entries:

http://192.168.0.1/debmirror/debian wheezy main contrib non-free
http://192.168.0.1/debmirror/debian-security wheezy/updates main contrib non-free

# PVE repository provided by proxmox.com, only for installation (this repo will stay on 3.1)
deb http://download.proxmox.com/debian wheezy pve

# security updates
deb http://security.debian.org/ wheezy/updates main contrib

Prepare faiDO droplet costs:

Run fai-setup

$ fai-setup -v

Configure /etc/dhcp/dhcpd.conf

Note down MAC address of NIC of the client machine.

deny unknown-clients;
option dhcp-max-message-size 2048;
use-host-decl-names on;

subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option domain-name “<domainName>”;
option domain-name-servers 8.8.8.8;
option time-servers 192.168.0.1;
option ntp-servers 192.168.0.1;
server-name faiserver;
next-server faiserver;
filename “pxelinux.0”;
}

host demohost {hardware ethernet <MAC Address>;fixed-address 192.168.0.2;}

Restart Dhcp server

/etc/init.d/dhcpd restart

Configure /etc/exports for NFS share

fai-setup command will add required entries in /etc/exports. Still you need to do some modifications so please make sure it should look like as below:

/srv/fai/config 192.168.0.0/24(async,ro,no_root_squash)
/srv/fai/nfsroot 192.168.0.0/24(async,ro,no_root_squash)

Restart NFS service

$ /etc/init.d/nfs-kernel-server restart

Configure TFTP Server

Config file /etc/default/tftpd-hpa should look like below.

TFTP_USERNAME=”tftp”
TFTP_DIRECTORY=”/srv/tftp/fai”
TFTP_ADDRESS=”0.0.0.0:69″
TFTP_OPTIONS=”–secure”

Restart tftpd service

/etc/init.d/tftpd-hpa restart

Copy Sample configs

cp -a /usr/share/doc/fai-doc/examples/simple/* /srv/fai/config

Change ownership of /srv/fai/config

chown -R fai /srv/fai/config

Disk Partition layout

– Remove all files from /srv/fai/config/disk_config

– Create new file name DEFAULT under /srv/fai/config/disk_config/

– Add below entries in it:

disk_config disk1 disklabel:msdos
primary / 90% ext4 rw
primary swap 10% swap sw

Package installation config

– Make sure your /srv/fai/config/package_config/DEFAULT look like below:

PACKAGES aptitude
initramfs-tools
grub-pc
pve-firmware
pve-kernel-2.6.32-26-pve
pve-headers-2.6.32-26-pve

# explicitely delete these bootloaders
# (just in case the base tgz contains them)
PACKAGES aptitude
grub-legacy-
lilo-
linux-image-amd64
linux-base

Modifying /srv/fai/config/scripts/DEBIAN/40-misc

– Add below entries in /srv/fai/config/scripts/DEBIAN/40-misc before “exit $error” line

##### Add entry to /etc/hosts of host #####

echo -e “192.168.0.2 demohost pvelocalhost” >> $target/etc/hosts

###################################################################

##### Add entries for /bin/proxmox_install.sh ######
##### This script install proxmox after first reboot #####

echo -e ‘#!/bin/bash’ > $target/bin/proxmox_install.sh

echo -e ‘echo -e “Installing Proxmox” > /root/pminstall.log’ >> $target/bin/proxmox_install.sh

echo -e ‘export DEBIAN_FRONTEND=noninteractive’ >> $target/bin/proxmox_install.sh

echo -e ‘apt-get –force-yes -y install proxmox-ve-2.6.32 ntp ssh lvm2 postfix ksm-control-daemon vzprocps open-iscsi bootlogd’ >> $target/bin/proxmox_install.sh

echo -e ‘cat /dev/null > /etc/rc.local’ >> $target/bin/proxmox_install.sh

##################################################################

chmod 777 $target/bin/proxmox_install.sh
chmod 777 $target/etc/rc.local

##### Change Default kernel for Boot #####

sed -i ‘s/set default=”0″/set default=”2″/g’ $target/boot/grub/grub.cfg
sed -i ‘s/GRUB_DEFAULT=0/GRUB_DEFAULT=2/g’ $target/etc/default/grub

################# END #################

Copy fai.conf inside nfsroot

cp /etc/fai/fai.conf /srv/fai/nfsroot/etc/fai/

Make sure /srv/fai/nfsroot/etc/fai.conf have below entry:

192.168.0.1 faiserver

Initialize Bootloader config for demohost (client)

chboot -IB demohost

Above command will create config file under /srv/tftp/fai/pxelinux.cfg/

File Name will be something like: C0A87A64

Just edit that file and make sure it should look like below:

default fai-generated
label fai-generated
kernel vmlinuz-3.2.0-4-amd64
append initrd=initrd.img-3.2.0-4-amd64 ip=dhcp root=/dev/nfs nfsroot=192.168.0.1:/srv/fai/nfsroot:vers=3 aufs FAI_FLAGS=verbose,sshd,reboot FAI_ACTION=install

Now reboot client machine from Network PXE boot. It will get automatically Proxmox installed.

Neelesh Gurjar has written 115 articles