MAC based Booting PXE: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
(fmoving)
 
m (+ category)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= MAC Based booting =
== MAC Based booting ==


Installing with PXE and FAI MAC Address based.
Installing with PXE and FAI MAC Address based.


With this hooks and some small changes in dhcpd.conf (based on FAI-CD) every computer that boots fai become a MAC based config file in the pxelinux.cfg/ dir. May be in the future a GUI can use/change this information.  
With this hooks and some small changes in dhcpd.conf (based on FAI-CD) every computer that boots fai gets a MAC based config file installed in the pxelinux.cfg/ dir. May be in the future a GUI can use/change this information.  


== File dhcpd.conf ==
=== File dhcpd.conf ===
<pre>
<pre>
....
....
Line 25: Line 25:
  .....
  .....


== Hook mkboot ==
=== Hook mkboot ===
 
<pre>
<pre>
#! /bin/bash  
#! /bin/bash  
Line 63: Line 62:
</pre>
</pre>


== Hook chboot.default ==
=== Hook chboot.default ===
 
<pre>  
<pre>  
#! /bin/sh  
#! /bin/sh  
Line 96: Line 94:
</pre>
</pre>


== File: /boot/fai/pxelinux.cfg/default ==
=== File: /boot/fai/pxelinux.cfg/default ===
<pre>
<pre>
default sysinfo
default sysinfo
Line 109: Line 107:
</pre>
</pre>


== File: /boot/fai/pxelinux.cfg/local ==
=== File: /boot/fai/pxelinux.cfg/local ===
<pre>
<pre>
default local
default local
Line 121: Line 119:
</pre>
</pre>


== File: /boot/fai/pxelinux.cfg/demohost ==
=== File: /boot/fai/pxelinux.cfg/demohost ===
<pre>
<pre>
default demohost
default demohost
Line 135: Line 133:
</pre>
</pre>


== File: /boot/fai/pxelinux.cfg/sysinfo ==
=== File: /boot/fai/pxelinux.cfg/sysinfo ===
 
<pre>
<pre>
default sysinfo
default sysinfo
Line 148: Line 145:
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot
</pre>
</pre>
[[Category:Howto]]

Latest revision as of 08:20, 4 October 2010

MAC Based booting

Installing with PXE and FAI MAC Address based.

With this hooks and some small changes in dhcpd.conf (based on FAI-CD) every computer that boots fai gets a MAC based config file installed in the pxelinux.cfg/ dir. May be in the future a GUI can use/change this information.

File dhcpd.conf

....
# deny unknown-clients
....
subnet 192.168.1.0 netmask 255.255.255.0
{
  range 192.168.1.200 192.168.1.249;
  ....

If you press <shift> key during pxe booting you can get a prompt.

Possible commands are:

mkboot HOST=local  
mkboot HOST=remove 
.....
mkboot HOST=demohost
.....

Hook mkboot

#! /bin/bash 
# hook mkboot for fai.
# If you start this script on a fai client it copy, create or delete a pxe bootfile. It use the ethernet mac
# address of the fai client. 

cd /tmp 
TFTPCONFDIR="/boot/fai/pxelinux.cfg"
SSHUSER=fai
TFTPSERVER=faiserver

HOSTNAME="default"
if [ "$HOST" != "" ]; then HOSTNAME=$HOST; fi ;
BOOTMAC=`/sbin/ifconfig "$netdevices_up" |grep HWaddr|cut -d " " -f11|tr ':' '-'|tr '[:upper:]' '[:lower:]'`
BOOTMAC="01-"$BOOTMAC
echo Next Boot will boot or install: $HOSTNAME on $BOOTMAC.
echo "!!! OK - Press ctrl-c to interrupt FAI and to get a shell"

case $HOSTNAME in
    disable)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable" ;;
    local)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable ; cp $TFTPCONFDIR/local $TFTPCONFDIR/$BOOTMAC " ;;
    enable)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC\.disable $TFTPCONFDIR/$BOOTMAC" ;;
    remove)
        ssh $SSHUSER@$TFTPSERVER "rm $TFTPCONFDIR/$BOOTMAC" ;;
    *)
        ssh $SSHUSER@$TFTPSERVER "cp $TFTPCONFDIR/$HOSTNAME $TFTPCONFDIR/$BOOTMAC" ;;
esac

task_faiend

# End of mkboot

Hook chboot.default

 
#! /bin/sh 
# hook for fai. Set boot to local 
set -xv

SCRIPTNAME=`basename $0`
skiptask=`echo $SCRIPTNAME | sed "s/\..*$//"`

cd /tmp 
TFTPCONFDIR="/boot/fai/pxelinux.cfg"
SSHUSER=fai
TFTPSERVER=faiserver

HOSTNAME="local"

BOOTMAC=`/sbin/ifconfig "$netdevices_up" |grep HWaddr|cut -d " " -f11|tr ':' '-'|tr '[:upper:]' '[:lower:]'`
BOOTMAC="01-"$BOOTMAC
echo Next Boot will boot or install: $HOSTNAME on $BOOTMAC.

case $HOSTNAME in
    local)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable ; cp $TFTPCONFDIR/local $TFTPCONFDIR/$BOOTMAC " ;;
    *)
        ssh $SSHUSER@$TFTPSERVER "cp $TFTPCONFDIR/$HOSTNAME $TFTPCONFDIR/$BOOTMAC" ;;
esac

skiptask $skiptask 

# End of hook chboot.DEFAULT

File: /boot/fai/pxelinux.cfg/default

default sysinfo

label sysinfo
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=mkboot HOST=sysinfo root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot

label mkboot
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot

File: /boot/fai/pxelinux.cfg/local

default local

label local
localboot 0

label mkboot
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot

File: /boot/fai/pxelinux.cfg/demohost

default demohost

label demohost
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=install HOST=demohost root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt

label mkboot
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot

File: /boot/fai/pxelinux.cfg/sysinfo

default sysinfo

label sysinfo
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=sysinfo root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt

label mkboot
kernel vmlinuz-install
append ip=dhcp devfs=nomount FAI_ACTION=mkboot root=/dev/nfs nfsroot=/usr/lib/fai/nfsroot,v2,rsize=32768,wsize=32768  FAI_FLAGS=verbose,sshd,createvt,reboot