Contents
This document is based on the requirement from me. I have
gathered all the details from different websites and prepared this document.
At the end of this
document you will be able to setup a RHEL/Fedora/Centos Pxeboot server through
which we can install OS for Windows XP, 2003, Win7, 2008, 2008 R2, Win8, 2012 ,
Linux RHEl, Fedora, Centos, Solaris, Ubuntu and Esxi 4.1,5.0 through network.
1.
RHEL Server:
a.
DHCP service
b.
TFTP service
c.
Samba service
d.
VSFTPD service
e.
NFS service
2.
Binaries:
a.
Windows AIK
b.
Windows XP,2003,Win7,2008,2008 R2,Win8,2012
c.
Linux RHEl,Fedora,Centos,Solaris,Ubuntu
d.
Esxi4.1,5.0
You can setup all of the above mentioned services in a
single server or multiple servers with different OS.
Install a
RHEl server. Minimum requirements are 3GB RAM and Dual core processor 2.7 GHz
or more. For details about installation of RHEL server step by step
click
here. For installing service create a YUM repository, for details about
creating YUM repository
click
here. Here we use different services for installing different OS, e.g.
Samba for installing Windows OS, FTP for Linux RHEL/Fedora/Centos, NFS for
Solaris.
Install DHCP in RHEL machine.
#Yum install –y dhcpd*
After installing dhcp service go to
#Vim /etc/dhcpd.conf
It will ask you to go to /usr/share/doc/dhcp*/dhcpd.conf.sample.
Copy the file to /etc/ as dhcpd.conf and replace the old
file.
#cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
Now open the dhcpd.conf
#Vim /etc/dhcpd.conf
#####################################################################################ddns-update-style interim;
ignore client-updates;
subnet 192.168.XX.XX netmask 255.255.255.XX {
allow booting;
allow bootp;
next-server 192.168.XX.XX;
filename "pxelinux.0";
option
routers 192.168.XX.XX;
option
subnet-mask 255.255.255.XX;
option
nis-domain "domain.org";
option
domain-name "domain.org";
option
domain-name-servers 192.168.XX.XX;
option
time-offset -18000; # Eastern Standard Time
option
ntp-servers 192.168.XX.XX;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid).
Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range
dynamic-bootp 192.168.XX.XX 192.168.XX.XX;
default-lease-time
3600;
max-lease-time
3601;
host xxxxx {
option host-name xxxxx.domain.org";
hardware ethernet 00:A0:78:8E:9E:AA;
fixed-address 192.168.XX.XX;
}
}
#####################################################################################
Subnet:
you can specify your own subnet e.g.: 10.xx.xx.xx and 255.xx.xx.xx.
Allow booting: this will allow the DHCP server to give IP to any
adapter which is pxe enabled.
Allow bootp:
Next server: this is the ip of your tftp server. You can keep same
server or server ip in which you installed tftp server.
Filename: when your client machine asks for ip DHCP server gives the
information about both next server and boot file name it should look for.
Then give the remaining options like gateway router, DNS server, NTP
server if you want.
Adjust the default lease time and max lease time in my case I kept it
as one hour. (Note here time is calculated in seconds).
If you are running multiple servers for this setup you need to have a
static IP for all of the servers so you
can bind it using client MAC address.
Now save the file and restart the service.
#Service dhcpd
restart
#Chkconfig dhcpd on
Install TFTP in RHEL machine.
#Yum install –y tftp*
Now restart the service.
#Service xinetd
restart
#Chkconfig tftp on
The folder
for keeping all the boot files is /tftpboot/.
Install Samba in RHEL machine.
#Yum install –y samba*
Create a folder
named share under /.
Open the
configuration file and add a sample share at the end of the file.
######################################################################
[example]
comment = example
path = /share
public = yes
writable = yes
printable = no
write list = user
browseable = yes
######################################################################
Add a user
named “user” and give a password.
#Useradd user –p
<password>
#Smbpasswd –a user
It will ask
for password give same password.
Now restart the service.
#Service smb restart
#Chkconfig smb on
Then try to
access the share from a Windows machine using samba server IP address. You will
be seeing a share named example.
Note:
1.
In case if you are using a windows machine for
pxe-booting like windows 7 you can get dhcp service and tftp service installed
using “serva” or “solarwinds tftp server” applications and samba share by
sharing any folder.
2.
But only drawback you should work hard to make
linux machines to boot from windows pxeboot server.
Install TFTP in RHEL machine.
#Yum install –y ftp*
Now restart the service.
#Service vsftpd
restart
#Chkconfig vsftpd
on
Open browser
and type url as ftp://<IPaddress> it will show pub which
is a default folder in ftp. We can
access the pub folder from /var/ftp/pub.
Install TFTP in RHEL machine.
#Yum install –y nfs*
Now restart the service.
#Service nfs
restart
#Chkconfig nfs on
Open file
/etc/exports and add an entry for nfs server.
e.g.
#vim /etc/exports
#####################################################################################
/var/ftp/pub/solaris
192.168.11.0/24(rw,sync)
#####################################################################################
Copy the below files to /tftp boot by making respective
folders.
# cp /usr/share/syslinux/pxelinux.0 /tftpboot
# cp /usr/share/syslinux/menu.c32 /tftpboot
# mkdir /tftpboot/pxelinux.cfg
# touch /tftpboot/pxelinux.cfg/default
First
install Windows Automated installation kit in any of windows 7 machine and copy
the below script to a text file and save it as .bat file (e.g. copy the below
script and save it as winpe.bat on your desktop). Run the "Deployment
Tools Command Prompt" as administrator (should be located in your start
menu).
For
installing 32-bit or 64-bit operating system you should run the below script by
changing set ARCH in below script to “x86” for 32bit and “amd64” for 64-bit. I
recommend “x86”.
#####################################################################################
@echo off
:: This script prepares a Windows 7 image for PXE
:: This assumes you have the WAIK installed
:: Author: Louis A
:: Date: 3/31/2013
:: Modified: 6/26/2013
:: Any modification of this file is strictly on you and is not
recommended.
:: Modify only if you know what you're doing.
:: Variables below.
:: The next few reference file and directory paths that are essential
:: Change BASEDIR if you would like a different directory to deploy the
PE environment
:: Change ARCH to x86 if you need a 32 Bit PE instead
set WAIKPATH=%ProgramFiles%\Windows AIK
set ARCH=amd64
set BASEDIR=C:\winpe
set PEPATH=%BASEDIR%\winpe_%ARCH%
set TFTPPATH=%BASEDIR%\tftp\Boot
set BCDSTORE=%TFTPPATH%\BCD
:: These were created because of errors that came up (due to missing
variable references)
:: Do not remove these, otherwise you'll see errors that may confuse
you, even though they're harmless.
set WAIKMISSING=0
set ARCHMISSING=0
set NOTSANE=0
set ERROR=0
:: Checking if we're elevated
net session >nul 2>&1
if %errorLevel%==0 ( echo Admin Success ) else ( set ERROR=2 &&
goto :exit )
:: Making sure our environment is sane.
:: We need to make sure our working directory is empty. If it's not,
we'll empty it and start over.
if not exist "%WAIKPATH%" ( set WAIKMISSING=1 && goto
:end )
if not exist "%WAIKPATH%\Tools\PETools\%ARCH%" ( set
ARCHMISSING=1 && goto :end )
if not exist "%BASEDIR%" ( md C:\winpe )
if exist "%PEPATH%" ( echo Temporary working directory is not
empty! && rd %PEPATH% /S )
if exist "%PEPATH%" ( echo Temporary working directory is
still not empty! Are you serious? Trying to delete... again. && cd
"%WAIKPATH%\Tools\%ARCH%" && imagex /unmount
%PEPATH%\mount && rd %PEPATH% /S /Q )
if exist "%PEPATH%" ( set NOTSANE=1 && goto :end )
if exist "%TFTPPATH%" ( echo TFTP boot directory is not empty!
&& rd %TFTPPATH% /S )
if exist "%TFTPPATH%" ( set NOTSANE=1 && goto :end )
if exist "%BCDSTORE%" ( echo BCD store already exists!
&& del /P %BCDSTORE% )
if exist "%BCDSTORE%" ( set NOTSANE=1 && goto :end )
:: Environment appears to be sane... beginning work.
:: This is the grunt work. Do not change anything below unless you know
what you're doing.
cd "%WAIKPATH%\Tools\PETools"
echo "Copying the PE Files"
call copype %ARCH% %PEPATH%
echo "Mounting the PE image with imagex"
:: This was added because I forgot the concept of mounting in Linux :)
The folder must exist.
if not exist "%PEPATH%\mount" ( md %PEPATH%\mount )
imagex /mountrw %PEPATH%\winpe.wim 1 %PEPATH%\mount
md %TFTPPATH% > NUL
copy %PEPATH%\mount\Windows\Boot\PXE\*.* %TFTPPATH% > NUL
copy "%WAIKPATH%\Tools\PETools\%ARCH%\boot\boot.sdi"
%TFTPPATH% > NUL
copy %PEPATH%\winpe.wim %TFTPPATH% > NUL
bcdedit /createstore %BCDSTORE%
bcdedit /store %BCDSTORE% /create {ramdiskoptions} /d "Ramdisk
Options"
bcdedit /store %BCDSTORE% /set {ramdiskoptions} ramdisksdidevice Boot
bcdedit /store %BCDSTORE% /set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
for /f "Tokens=3" %%x in ('bcdedit /store %BCDSTORE% /create
/d "Windows 7 Installation" /application osloader') do set GUID=%%x
bcdedit /store %BCDSTORE% /set %GUID% systemroot \Windows
bcdedit /store %BCDSTORE% /set %GUID% detecthal Yes
bcdedit /store %BCDSTORE% /set %GUID% winpe Yes
bcdedit /store %BCDSTORE% /set %GUID% osdevice
ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}
bcdedit /store %BCDSTORE% /set %GUID% device
ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}
bcdedit /store %BCDSTORE% /create {bootmgr} /d "Windows 7 Boot
Manager"
bcdedit /store %BCDSTORE% /set {bootmgr} timeout 30
bcdedit /store %BCDSTORE% /set {bootmgr} displayorder %GUID%
bcdedit /store %BCDSTORE%
:: This was added because at BCD loading, it will freeze and then
complain of missing fonts
md %TFTPPATH%\fonts
copy %PEPATH%\ISO\boot\fonts\*.* %TFTPPATH%\fonts
pause
:: If the command below fails, make sure to use imagex to unmount
C:\winpe\winpe_amd64\mount
imagex /unmount mount
goto :exit
:end
:: Environment was not sane.
if %WAIKMISSING%==1 ( echo Your WAIK directory was not found. Execution
aborted. && set ERROR=1 && goto :exit )
if %ARCHMISSING%==1 ( echo Architecture is either missing or is not
recognized. && set ERROR=1
&& goto :exit )
if %NOTSANE%==1 ( echo Your environment was not clean. Execution
aborted. && set ERROR=1 && goto :exit )
:exit
if %ERROR%==1 ( echo There was an error and execution was aborted. )
if %ERROR%==2 ( echo You were not elevated. Please launch an elevated
command prompt. )
#####################################################################################
Then go to
desktop, in my case.
>Cd “c:\users\administrator\Desktop”
Then run
winpxe.bat
>winpxe.bat
Then a
folder named winpe will be created in your “C dive” inside there will be boot
folder, copy the whole content to /tftpboot/Boot/ of TFTP server.
Now keep both
WIN 7 (32 bit, 64 bit) dvd or an iso images and extract the sources folder in
/share/WIN7/
It should be
like:
#/tftpboot/
-Boot
#/share/WIN7/
-sourcesx86
-sourcesx64
Note: you
can create booting files for both 32bit or 64 bit, I recommend to keep 32-bit
files because if you are keeping 64bit booting files and if you processor is
not a 64 bit processor then it will fail at the starting itself. So keep 32 bit
boot files and when installing you can change to 64 bit setup.
Next, open
the following file and add content.
#Vim /etc/tftpd.map
#####################################################################################
re ^pxeboot\.n12 Boot/pxeboot.n12
re ^pxeboot\.com Boot/pxeboot.com
re ^pxeboot\.0 Boot/pxeboot.n12
re ^bootmgr\.exe Boot/bootmgr.exe
rg \\ /
#####################################################################################
The purpose
of this file is that when it is booting it will asks for following files in
/tftpboot/ folder but we will tell to search files in /tftpboot/Boot/ and the
last statement is to convert all the backward slashes of windows to forward
slashes which are compactible for linux.
Then Edit
/etc/xinetd.d/tftp and add an entry
It will be
as
server_args =
-s /tftpboot
Change it to
server_args =
-m /etc/tftpd.map -s /tftpboot
Finally go to /tftpboot/Boot/ and create two soft links.
#Cd /tftpvoot/Boot
#ln -s pxeboot.n12
startrom.0
#ln -s winpe.wim
boot.wim
Then open /tftpboot/pxelinux.cfg/default
and add entry as:
######################################################################
default menu.c32
prompt 0
MENU TITLE PXE Menu
TIMEOUT 200
TOTALTIMEOUT 6000
LABEL Windown7x32x64
MENU LABEL Windown7x32x64
KERNEL Boot/startrom.0
LABEL Boot from HDD
MENU LABEL ^Boot from local disk
LOCALBOOT 0x80
MENU end
######################################################################
Now start the installation in your
client machine. Restart the system and keep lan/network boot in the first
priority or start boot from network. Then wait for DHCP server to assign IP and
then select Windows 7 from PXEMENU.
Then it goes to command prompt.
Then type:
>Net use z: \\<IPaddresss-of-samba-server->\win7
>z:
Here you will find two folders if you
type dir. If you want to install 32 bit win7 go to sourceX86 and run setup.exe
Example:
Z:>\sourcesx86\setup.exe
That’s it continue with your
installation……..
Preparing Fedora for Network boot
Create the directories to store Fedora 10.
# mkdir -p /var/lib/tftpboot/fedora/12/i386
# mkdir -p /var/lib/tftpboot/fedora/12/amd64
# mkdir -p /srv/install/fedora/12/i386
# mkdir -p /srv/install/fedora/12/amd64
Mount the Fedora 12 64-bit DVD ISO and copy the kernel and
initrd to the previously created location.
# mkdir /mnt/loop
# mount -o loop -t iso9660 /location/of/ISO/Fedora-12-x86_64-DVD.iso /mnt/loop
# cp /mnt/loop/images/pxeboot/vmlinuz /var/lib/tftpboot/fedora/12/amd64
# cp /mnt/loop/images/pxeboot/initrd.img /var/lib/tftpboot/fedora/12/amd64
# cp -R /mnt/loop/* /srv/install/fedora/12/amd64
# umount /mnt/loop
Mount the Fedora 12 32-bit DVD ISO and copy the kernel and
initrd to the previously created location.
# mkdir /mnt/loop
# mount -o loop -t iso9660 /location/of/ISO/Fedora-12-i386-DVD.iso /mnt/loop
# cp /mnt/loop/images/pxeboot/vmlinuz /var/lib/tftpboot/fedora/12/i386
# cp /mnt/loop/images/pxeboot/initrd.img /var/lib/tftpboot/fedora/12/i386
# cp -R /mnt/loop/* /srv/install/fedora/12/i386
# umount /mnt/loop
Then add Entry in /tftpboot/pxelinux.cfg/default
LABEL
Fedora 12 (64-bit)
MENU
LABEL Fedora 12 (64-bit)
KERNEL fedora/12/amd64/vmlinuz
APPEND
method=nfs:10.10.1.10:/srv/install/fedora/12/amd64/ lang=us keymap=us ip=dhcp
ksdevice=eth0 noipv6 initrd=fedora/12/amd64/initrd.img
Preparing Solaris for Network boot
At your NFS server
Mount the iso file:
# mount -o loop /sol-10-u9-ga-x86-dvd.iso /mnt
Created and shared
file in directory /share/solaris
Create a NFS entry
for /share/solaris.
Check required file
in your shared directory, place the below mentioned files to in its respective
directories by making directories.
Under /tftpboot/
folder should look like this
solarisx86/`-- boot
`--
multiboot
`-- x86.minirootboot/
boot/`-- grub
`--
menu.lst
`--
menu1.lst
`--
pxegrub.0
label SolarisX86
menu label Install
Solaris 10 X86
kernel
/boot/grub/pxegrub.0
7. Configure file /tftpboot/boot/grub/menu.lst
######################################################################
default=0
timeout=60
min_mem64 1024
title Oracle Solaris
kernel$
/solarisx86/boot/multiboot kernel/unix v -m verbose install
nfs://192.168.11.66/var/ftp/pub/solaris/jumpstart/config.tar -B
install_media=192.168.11.66:/var/ftp/pub/solaris/
module$
/solarisx86/boot/x86.miniroot
title Oracle Solaris Serial Console ttya
kernel$
/solarisx86/boot/multiboot kernel/unix -B
install_media=192.168.11.66:/var/ftp/pub/solaris/,console=ttya
module$
/solarisx86/boot/x86.miniroot
title Oracle Solaris Serial Console ttyb (for lx50, v60x and
v65x)
kernel$
/solarisx86/boot/multiboot kernel/unix -B
install_media=192.168.11.66:/var/ftp/pub/solaris/,console=ttyb
module$ /solarisx86/boot/x86.miniroot
################################################################
Get back to NFS
server,We still missed config.tar that contain 4 files in /share/solaris
/jumpstart (create new dir)
1.
rules file
#cat rules
any - - any_machine -
2.
rules.ok file
]# cat rules.ok
any - - any_machine -
version=2
checksum=num
3.
sysidcfg file
# cat sysidcfg
system_locale=en_US
install_locale=en_US
terminal=vt100
name_service=NONE
network_interface=PRIMARY
{protocol_ipv6=no}
security_policy=NONE
timeserver=localhost
4.
any_machine file
# cat any_machine
install_type
initial_install
cluster SUNWCXall
package SUNWaccr add
fdisk all solaris all
partitioning explicit
filesys any free /
filesys any 4096 swap
system_type server
5.
Then tar all file
# tar -c rules rules.ok
any_machine sysidcfg > /share/solaris/jumpstart/config.tar