Unattended installation of Proxmox
Introduction
Remote unattended installation means installation of remote server without any human interference. This process is very useful for bare metal provisioning or automated installation on multiple servers. I have used FAI (Fully Automatic Installation) to automate remote installation of ProxmoxVE. I have used steps from "ProxmoxVE installation over Debian wheezy". So this does not install ProxmoxVE from ProxmoxVE ISO. It installs Debian wheezy first and then ProxmoxVE. 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. "FAI-Fully Automatic Installation" is used to automate headless installation of Proxmox or Debian. http://fai-project.org/
Basic Architecture
Components:
This setup has following components required.
- 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:
Configuration File/Directory | Details |
---|---|
/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 |
Implementation:
Scenario:
To follow these steps require 2 machines Server & Client. Server is the one which has FAI Server configured on Debian Wheezy. Client is the one on which ProxmoxVE is going to be installed.
Server Name: faiserver Server IPAddress: 192.168.0.1/24 Client Name: demohost Client IPAddress: 192.168.0.2/24
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 debmirror
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: Make sure you have these entries in 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": Make sure nfsroot.conf looks like:
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: sources.list should look like below:
deb http://192.168.0.1/debmirror/debian wheezy main contrib non-free deb 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 fai: Run fai-setup command to prepare fai
$ 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: Run below command to restart dhcp server. Note that I am using init script here.
/etc/init.d/isc-dhcp-server 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"
Create directory for tftp:
mkdir -p /srv/tftp/fai/pxelinux.cfg
Copy pxelinux.0, kernel and initrd to tftp root:
cp /boot/vmlinuz-3.2.0-4-amd64 /srv/tftp/fai/ cp /usr/lib/syslinux/pxelinux.0 /srv/tftp/fai/ cp /boot/initrd.img-3.2.0-4-amd64 /srv/tftp/fai/
Restart tftpd service:
/etc/init.d/tftpd-hpa restart
Copy Sample configuration files to fai/config directories
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/ and remove all other examples - 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 below 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 'sed -i '/proxmox_install/d' /etc/rc.local' >> $target/bin/proxmox_install.sh echo -e 'reboot' >> $target/bin/proxmox_install.sh
sed -i '/default/a\ /bin/proxmox_install.sh' $target/etc/rc.local ################################################################## 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/
Add to /srv/fai/nfsroot/etc/ssh/ssh_config
StrictHostKeyChecking no
Make sure /srv/fai/nfsroot/etc/hosts have below entry:
192.168.0.1 faiserver
Initialize Bootloader config for demohost (client)
fai-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.