Wednesday, November 12, 2014

PXE Setup

PXE legacy/uefi NFS[RHEL6.4]
PXE legacy/uefi HTTP/FTP[RHEL6.4]
Set up Pxe Server with RHEL7.X/ Centos7.X HTTP

Set up Pxe Server with kicstart automation (uefi /legacy ) NFS

introduce folder and create folder: 
[root@localhost ~]# cd /
[root@localhost /]# mkdir /install/nfs_share
[root@localhost /]# mkdir /install/tftpboot

/install/nfs_share  ==>put kicstart file, and out centos images
/install/tftpboot ==>put your pxe menu page

1.Disable Firewall:
[root@localhost ~]# service iptables stop

2.Disable SELinux
[root@localhost ~]# setenforce 0

3. copy cdrom file from dvd rom into desktop
[root@localhost ~]# cp –av /media/CentOS_6.4_Final /*

4.Convert centos images folder into iso file
command: mkisofs –r –o [filename].iso /[file destination/
[root@localhost ~]# mkisofs –r –o Centos_6.4.iso / CentOS_6.4_Final

5. Set your ip address.
Eth0 set 192.168.2.1, mask: 24, gateway: 192.168.2.254
Eth1: set 192.168.1.1, mask: 24, gateway: 192.168.1.254
Reboot DUT

6.DHCP service
[root@localhost ~]#vi /etc/sysconfig/dhcpd
DHCPD_INTERFACE="et01 eth1"
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf

dhcpd.conf: 

ignore client-updates;
ddns-update-style interim;
default-lease-time 259200;
max-lease-time 518400;
option arch code 93 = unsigned integer 16;
next-server 192.168.2.1;
subnet 192.168.2.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.2.2 192.168.2.200;
if option arch = 00:07{

#for uefi
filename "BOOTX64.efi";
}else{

#for legacy
filename "pxelinux.0";
}


}

7. TFTP service
[root@localhost ~]# vim /etc/xinetd.d/tftp

tftp:
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /install/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}

8. Create tftpboot directory

[root@localhost tftpboot]# chcon --reference /var/lib/tftpboot /install/tftpboot
[root@localhost /]# cp /usr/share/syslinux/menu.c32 /usr/share/syslinux/vesamenu.c32 /usr/share/syslinux/pxelinux.0 /install/tftpboot/
[root@localhost /]# mkdir /install/tftpboot/pxelinux.cfg
[root@localhost /]# mount -o loop Centos_6.4.iso /mnt/
[root@localhost /]# mkdir -p /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/vmlinuz /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/initrd.img /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/isolinux.cfg /install/tftpboot/pxelinux.cfg/
[root@localhost /]# cp /mnt/isolinux/boot.msg /install/tftpboot/
[root@localhost /]# cp /mnt/EFI/BOOT/*.* /install/tftpboot/
[root@localhost /]# cp /efidefault /insatll/tftpboot/

9.NFS service
[root@localhost /]# mkdir -p /install/nfs_share/centos6.4
[root@localhost /]# vim /etc/fstab

fstab:
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=46cb1b57-c057-4963-9682-23d850a3fc9d /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
#add this line
/Centos_6.4.iso /install/nfs_share/centos6.4 iso9660 defaults,loop 0 0

to enable mount
[root@localhost /]# mount -a
#check to see if it is mounted
[root@localhost /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
51606140 16999308 31985392 35% /
tmpfs 987372 228 987144 1% /dev/shm
/dev/sda1 495844 39677 430567 9% /boot
/dev/mapper/VolGroup-lv_home
184350796 191852 174794464 1% /home
/Centos_6.4.iso 3681792 3681792 0 100% /install/nfs_share/centos6.4


9.Edit exports
[root@localhost /]# vim /etc/exports

[root@localhost /]# mkdir -p /home/leopard

exports:
#/install/nfs_share/ 192.168.2.*(ro)
/install/nfs_share/ 192.168.2.0/24(ro,async,nohide,crossmnt) localhost(ro,async,nohide,crossmnt)
/home/leopard *(rw,no_root_squash,sync)

10.   Set up UEFI and Legacy configure menu boot

Set up UEFI PXE configuration
[root@localhost /]# cd /install/tftpboot
[root@localhost tftpboot]# vi efidefault

#debug --graphics
default=0
#splashimage=(nd)/splash.xpm.gz
timeout 40
#hiddenmenu

title [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for com kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/com.ks text console=ttyS0,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 manual
root (nd)
kernel /EFI_kernel/centos64x64/vmlinuz ip=dhcp method=nfs:192.168.2.1:/images/centos64x64
initrd /EFI_kernel/centos64x64/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/guifullap.cfg 
initrd /kernel/centos6.4/initrd.img

 Set up  legacy BIOS PXE configuration
[root@localhost /]# cd /install/tftpboot/pxelinux.cfg
[root@localhost pxelinux.cfg]# vi default

default menu.c32
    prompt 0
    timeout 300
    
      menu title ==== Boot Menu ====

#LABEL 1)CENTOSX64 LEDGACY (NFS method)   
#MENU  [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
#kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
#initrd /kernel/centos6.4/initrd.img

LABEL 1) Boot from local drive
   menu label ^2) Boot from local drive
   localboot

LABEL 2) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS1,57600n8 ks=nfs://192.168.2.1:/install/nfs_share/sol.ks

LABEL 2) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS0,57600n8 ks=nfs://192.168.2.1:/install/nfs_share/com.ks

LABEL 4) CentOS 6.4 x64 final manual (http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img method=nfs://192.168.2.1:/Centos6.4 ip=dhcp

11. kickstart setup
[root@localhost /]# cp /sol.ks com.ks /install/nfs_share/


11.vftfp setup (put driver inside ftp)
[root@localhost /]#cp /V9_20141028.tar /var/ftp

12.chkconfig setup (enable services)
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# chkconfig tftp on
[root@localhost /]# chkconfig rpcbind on
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig rpcidmapd on
[root@localhost /]# chkconfig nfslock on
[root@localhost /]# chkconfig vsftpd on
[root@localhost /]# chkconfig dhcpd on

13.Reboot server or start service
[root@localhost ~]# /etc/init.d/dhcpd restart
[root@localhost tftpboot]# /etc/init.d/xinetd restart
[root@localhost /]# /etc/init.d/rpcbind restart
[root@localhost /]# /etc/init.d/nfs restart
[root@localhost /]# /etc/init.d/rpcidmapd restart
[root@localhost /]# /etc/init.d/nfslock restart

# make sure vsftpd services is running
[root@localhost /]# /etc/init.d/vsftpd start

14 give permission to kernel
chmod 777 /install/tftpboot/kernel
chmod 777 /install/tftpboot/kernel/centos6.4

_______________________________________________________________________

Set up Pxe Server with kicstart automation (uefi /legacy ) HTTP

introduce folder and create folder: 
[root@localhost ~]# cd /
[root@localhost /]# mkdir /tftpboot


1.Disable Firewall:
[root@localhost ~]# service iptables stop

2.Disable SELinux
[root@localhost ~]# setenforce 0

3. copy cdrom file from dvd rom into desktop, and create into iso filoe
[root@localhost ~]# mkdir /var/www/html/Centos6.4
[root@localhost ~]# cd /var/www/html
[root@localhost html]# mkisofs -r -o /centos6.4.iso Centos6.4/

4. Set your ip address.
Eth0 set 192.168.2.1, mask: 24, gateway: 192.168.2.254
Eth1: set 192.168.1.1, mask: 24, gateway: 192.168.1.254
Reboot DUT

5.DHCP service
[root@localhost ~]#vi /etc/sysconfig/dhcpd
DHCPD_INTERFACE="et01 eth1"
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf

dhcpd.conf: 

ignore client-updates;
ddns-update-style interim;
default-lease-time 259200;
max-lease-time 518400;
option arch code 93 = unsigned integer 16;
next-server 192.168.2.1;
subnet 192.168.2.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.2.2 192.168.2.200;
if option arch = 00:07{

#for uefi
filename "BOOTX64.efi";
}else{

#for legacy
filename "pxelinux.0";
}


}

6. TFTP service
[root@localhost ~]# vim /etc/xinetd.d/tftp

tftp:
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /install/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}

7. Create tftpboot directory

[root@localhost tftpboot]# chcon --reference /var/lib/tftpboot /tftpboot
[root@localhost /]# cp /usr/share/syslinux/menu.c32 /usr/share/syslinux/vesamenu.c32 /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@localhost /]# mkdir /tftpboot/pxelinux.cfg
[root@localhost /]# mkdir -p /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/vmlinuz /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/initrd.img /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/
[root@localhost /]# cp /mnt/isolinux/boot.msg /tftpboot/
[root@localhost /]# cp /mnt/EFI/BOOT/*.* /tftpboot/
[root@localhost /]# cp /efidefault /tftpboot/


8. Create file in httpd directory
[root@localhost /]#  cd /var/www/html
[root@localhost html]# mkdir Centos6.4
[root@localhost /]# mount -o loop centos6.4.iso /var/www/html/Centos6.4


fstab:
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=46cb1b57-c057-4963-9682-23d850a3fc9d /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
#add this line

/centos6.4.iso /var/www/html/Centos6.4 iso9660 defaults,loop 0 0

9.   Set up UEFI and Legacy configure menu boot

Set up UEFI PXE configuration
[root@localhost /]# cd /install/tftpboot
[root@localhost tftpboot]# vi efidefault

#debug --graphics
default=0
#splashimage=(nd)/splash.xpm.gz
timeout 40
#hiddenmenu

title [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart 111
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/sol.ks text console=ttyS1,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for com kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/com.ks text console=ttyS0,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/guifullap.ks
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap_manual
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp method=http//192.168.2.1/Centos6.4
initrd /kernel/centos6.4/initrd.img

 Set up  legacy BIOS PXE configuration
[root@localhost /]# cd /install/tftpboot/pxelinux.cfg
[root@localhost pxelinux.cfg]# vi default
 default menu.c32
    prompt 0
    timeout 300
    
      menu title ==== Boot Menu ====

#LABEL 1)CENTOSX64 LEDGACY (NFS method)   
#MENU  [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
#kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
#initrd /kernel/centos6.4/initrd.img

LABEL 1) Boot from local drive
   menu label ^2) Boot from local drive
   localboot

LABEL 2) CentOS 6.4 x64 final (http:// method)
kernel kernel/centos6.4/vmlinuz
#append initrd=kernel/centos6.4/initrd.img \ method=http://192.168.2.1/Centos6.4 ip=dhcp
append initrd=kernel/centos6.4/initrd.img ks=http://192.168.2.1/kickstart/centos6.4/guifullap.ks ip=dhcp


LABEL 3) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS1,57600n8 ks=http://192.168.2.1/kickstart/centos6.4/sol.ks

LABEL 4) CentOS 6.4 x64 final manual (http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img method=http://192.168.2.1/Centos6.4 ip=dhcp



11. kickstart setup
[root@localhost /]# cd /var/www/html
[root@localhost html]# mkdir kickstart
[root@localhost kickstart]# mkdir centos6.4
[root@localhost /]# cp /sol.ks com.ks /var/www/html/kickstart/centos6.4

12.vftfp setup (put driver inside ftp) optional
[root@localhost /]#cp /V9_20141028.tar /var/ftp

13.chkconfig setup (enable services)
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# chkconfig tftp on
[root@localhost /]# chkconfig rpcbind on
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig rpcidmapd on
[root@localhost /]# chkconfig nfslock on
[root@localhost /]# chkconfig vsftpd on
[root@localhost /]# chkconfig dhcpd on
[root@localhost /]# chkconfig httpd on

14.Reboot server or start service
[root@localhost ~]# /etc/init.d/dhcpd restart
[root@localhost tftpboot]# /etc/init.d/xinetd restart
[root@localhost /]# /etc/init.d/rpcbind restart
[root@localhost /]# /etc/init.d/nfs restart
[root@localhost /]# /etc/init.d/rpcidmapd restart
[root@localhost /]# /etc/init.d/nfslock restart
[root@localhost /]#  /etc/init.d/httpd restart
# make sure vsftpd services is running
[root@localhost /]# /etc/init.d/vsftpd start

15 give permission to kernel
chmod 777 /tftpboot/kernel
chmod 777 /tftpboot/kernel/centos6.4


_______________________________________________________________________

Set up Pxe Server with RHEL7.X/ Centos7.X HTTP
all the settingis the same, except efidefault is different.

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap_manual
root (nd)
kernel /kernel/rhel7.1/vmlinuz inst.stage2=http//192.168.2.1/rhel7.1
initrd /kernel/rhel7.1/initrd.img
-----------------------------------------------------------------------------------------------------------------

reference:
Chinese: 
http://benjr.tw/83/5
http://blog.xuite.net/geniusn/note/29065663-%E7%94%A8CentOS%E6%9E%B6%E8%A8%ADPXE+Server
http://www.dotblogs.com.tw/ghoseliang/archive/2013/05/01/102558.aspx
English:
http://djmimi-linux.blogspot.tw/2014/03/how-to-build-pxe-server-support-legacy.html

No comments:

Post a Comment