Difference between revisions of "Unattended installation of Proxmox"

From Proxmox VE
Jump to navigation Jump to search
(Created page with "'''What is Remote unattended installation?'''<br /> Remote unattended installation means installation of remote server without any human interference. This process is very use...")
 
m (Typo fixes, PVE 6 runs on buster)
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''What is Remote unattended installation?'''<br />
+
 
 +
{{Note|Article refers to Proxmox VE 3.x which is based on Debian wheezy; Proxmox VE 6.x is based on Debian buster, the article has to be updated and verified}}
 +
== Introduction ==
 
Remote unattended installation means installation of remote server without any human interference.
 
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.  
+
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.  
'''What is Proxmox?'''<br />
 
Proxmox is debian based OS, which provides Virtualization Platform like VMware.
 
https://www.proxmox.com/en/
 
 
 
'''What is FAI?'''<br />
 
 
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 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/
 
"FAI-Fully Automatic Installation" is used to automate headless installation of Proxmox or Debian. http://fai-project.org/
  
In this example Bare Metal Provisioning of Proxmox OS is shwon. We can do with any other Linux as well.
+
== Basic Architecture ==
 
 
 
'''Components:'''<br />
 
'''Components:'''<br />
 +
This setup has following components required.<br />
 
:fai-server
 
:fai-server
 
:DHCP server
 
:DHCP server
Line 29: Line 25:
  
 
'''Important Configurations files and folders of FAI:'''<br />
 
'''Important Configurations files and folders of FAI:'''<br />
 +
{| class="wikitable"
 +
|-
 +
! 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: ==
  
/etc/fai/-    FAI configuration folder
+
'''Scenario:'''<br />
/etc/fai/fai.conf            -    FAI configuration file
+
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.
/etc/fai/nfsroot.conf    -    NFSroot configuration file
+
  Server Name: faiserver 
/etc/fai/apt/                  -    FAI repositories which will be used while installation
+
  Server IPAddress: 192.168.0.1/24
 +
  Client Name: demohost
 +
  Client IPAddress: 192.168.0.2/24
  
/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   
+
'''Steps:'''<br />
                                                  mounted as Root filesystem on client machine
+
'''Prepare FAI-Server:'''<br />
 +
1. Install Debian Wheezy with net-install ISO. Just install OpenSSH server nothing else on it.<br />
 +
2. Install Required Applications<br />
  
/etc/dhcp/dhcpd.conf    -    DHCP configuration file
+
  apt-get -y install apache2 fai-quickstart fai-doc fai-server isc-dhcp-server tftpd-hpa nfs-kernel-server syslinux-common debmirror
/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:
 
Create Local Debian Mirror:
ln -s /files/scratch/debmirror /var/www/debmirror
+
  ln -s /files/scratch/debmirror /var/www/debmirror
/usr/share/doc/fai-doc/examples/utils/mkdebmirror
+
  /usr/share/doc/fai-doc/examples/utils/mkdebmirror
/etc/init.d/apache2 restart
+
  /etc/init.d/apache2 restart
  
Configure /etc/hosts
+
Configure /etc/hosts:
 
Add below entries:
 
Add below entries:
192.168.0.1    faiserver
+
  192.168.0.1    faiserver
192.168.0.2    demohost
+
  192.168.0.2    demohost
  
Configure /etc/fai/fai.conf
+
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
  
SERVER=192.168.0.1
+
Configure /etc/fai/nfsroot.conf":
FAI_CONFIG_SRC=nfs://$SERVER/srv/fai/config
+
Make sure nfsroot.conf looks like:
# Account for saving log files and calling fai-chboot.
+
  FAI_DEBOOTSTRAP="wheezy http://http.debian.net/debian"
LOGUSER=fai
+
  FAI_ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
FAI_LOGPROTO=ssh
+
  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/nfsroot.conf
+
Configure /etc/fai/apt/sources.list:
FAI_DEBOOTSTRAP="wheezy http://http.debian.net/debian"
+
sources.list should look like below:
FAI_ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
 
  
NFSROOT=/srv/fai/nfsroot
+
  deb http://192.168.0.1/debmirror/debian wheezy main contrib non-free
TFTPROOT=/srv/tftp/fai
+
  deb http://192.168.0.1/debmirror/debian-security wheezy/updates main contrib non-free
NFSROOT_HOOKS=/etc/fai/nfsroot-hooks/
+
 
FAI_DEBOOTSTRAP_OPTS="--exclude=info"
+
  # 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
  
# Configuration space
+
Prepare fai:
FAI_CONFIGDIR=/srv/fai/config
+
Run fai-setup command to prepare fai
 +
  $ fai-setup -v
  
  
Configure /etc/fai/apt/sources.list
+
Configure /etc/dhcp/dhcpd.conf:
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.
 
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;}
  
    deny unknown-clients;
+
Restart Dhcp server:
    option dhcp-max-message-size 2048;
+
Run below command to restart dhcp server. Note that I am using init script here.
    use-host-decl-names on;
+
  /etc/init.d/isc-dhcp-server restart
   
 
    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;}
+
Configure /etc/exports for NFS share:
 
 
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:
 
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)
  
    /srv/fai/config 192.168.0.0/24(async,ro,no_root_squash)
+
Restart NFS service:
  /srv/fai/nfsroot 192.168.0.0/24(async,ro,no_root_squash)
+
  /etc/init.d/nfs-kernel-server restart
  
    Restart NFS service
+
Configure TFTP Server:
    $ /etc/init.d/nfs-kernel-server restart
 
 
 
Configure TFTP Server
 
 
Config file /etc/default/tftpd-hpa should look like below.
 
Config file /etc/default/tftpd-hpa should look like below.
TFTP_USERNAME="tftp"
+
  TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp/fai"
+
  TFTP_DIRECTORY="/srv/tftp/fai"
TFTP_ADDRESS="0.0.0.0:69"
+
  TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
+
  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
  
Restart tftpd service
+
Copy Sample configuration files to fai/config directories
/etc/init.d/tftpd-hpa restart
+
  cp -a /usr/share/doc/fai-doc/examples/simple/* /srv/fai/config
  
Copy Sample configs
+
Change ownership of /srv/fai/config:
 +
  chown -R fai /srv/fai/config
  
cp -a /usr/share/doc/fai-doc/examples/simple/* /srv/fai/config
+
Disk Partition layout:
 
 
Change ownership of /srv/fai/config
 
 
 
chown -R fai /srv/fai/config
 
 
 
Disk Partition layout
 
 
- Remove all files from /srv/fai/config/disk_config
 
- Remove all files from /srv/fai/config/disk_config
- Create new file name DEFAULT under /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:
 
- Add below entries in it:
        disk_config disk1 disklabel:msdos
+
  disk_config disk1 disklabel:msdos
    primary / 90% ext4 rw
+
  primary / 90% ext4 rw
    primary swap 10% swap sw
+
  primary swap 10% swap sw
  
Package installation config
+
Package installation config:
 
- Make sure your /srv/fai/config/package_config/DEFAULT look like below:
 
- Make sure your /srv/fai/config/package_config/DEFAULT look like below:
    PACKAGES aptitude
+
  PACKAGES aptitude
    initramfs-tools
+
  initramfs-tools
    grub-pc
+
  grub-pc
    pve-firmware
+
  pve-firmware
    pve-kernel-2.6.32-26-pve
+
  pve-kernel-2.6.32-26-pve
    pve-headers-2.6.32-26-pve
+
  pve-headers-2.6.32-26-pve
 
+
 
    # explicitely delete these bootloaders
+
  # explicitly delete these bootloaders
    # (just in case the base tgz contains them)
+
  # (just in case the base tgz contains them)
    PACKAGES aptitude
+
  PACKAGES aptitude
    grub-legacy-
+
  grub-legacy-
    lilo-
+
  lilo-
    linux-image-amd64
+
  linux-image-amd64
    linux-base
+
  linux-base
  
  
Modifying /srv/fai/config/scripts/DEBIAN/40-misc
+
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 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
  
##### Add entry to /etc/hosts of host #####
+
  sed -i '/default/a\
 
+
  /bin/proxmox_install.sh' $target/etc/rc.local
echo -e "192.168.0.2 demohost pvelocalhost" >> $target/etc/hosts
+
 
 
+
  ##################################################################
###################################################################
+
 
 
+
  chmod 777 $target/bin/proxmox_install.sh
##### Add entries for /bin/proxmox_install.sh ######
+
  chmod 777 $target/etc/rc.local
##### This script install proxmox after first reboot #####
+
 
 
+
  ##### Change Default kernel for Boot #####
echo -e '#!/bin/bash' > $target/bin/proxmox_install.sh
+
  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
echo -e 'echo -e "Installing Proxmox" > /root/pminstall.log' >> $target/bin/proxmox_install.sh
+
 
 
+
  ################# END  #################
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
 
Copy fai.conf inside nfsroot
cp /etc/fai/fai.conf /srv/fai/nfsroot/etc/fai/
+
  cp /etc/fai/fai.conf /srv/fai/nfsroot/etc/fai/
 
+
Add to /srv/fai/nfsroot/etc/ssh/ssh_config
Make sure /srv/fai/nfsroot/etc/fai.conf have below entry:
+
  StrictHostKeyChecking no
192.168.0.1 faiserver
 
  
 +
Make sure /srv/fai/nfsroot/etc/hosts have below entry:
 +
  192.168.0.1 faiserver
  
 
Initialize Bootloader config for demohost (client)
 
Initialize Bootloader config for demohost (client)
chboot -IB demohost
+
  fai-chboot -IB demohost
  
 
Above command will create config file under /srv/tftp/fai/pxelinux.cfg/
 
Above command will create config file under /srv/tftp/fai/pxelinux.cfg/
 
File Name will be something like: C0A87A64
 
File Name will be something like: C0A87A64
 
Just edit that file and make sure it should look like below:
 
Just edit that file and make sure it should look like below:
 
+
  default fai-generated
default fai-generated
+
  label fai-generated
label fai-generated
+
  kernel vmlinuz-3.2.0-4-amd64
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
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.
+
'''Now reboot client machine from Network PXE boot. It will get automatically Proxmox installed.'''
 +
[[Category:Archive]] [[Category:Installation]] [[Category: Proxmox VE 3.x]]

Latest revision as of 18:35, 19 August 2019

Yellowpin.svg Note: Article refers to Proxmox VE 3.x which is based on Debian wheezy; Proxmox VE 6.x is based on Debian buster, the article has to be updated and verified

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
 
 # explicitly 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.