Difference between revisions of "TFTP server manage netboot kernels"

Line 1: Line 1:
 
[[Category:Linux]]
 
[[Category:Linux]]
 +
 +
 +
  
  
Line 36: Line 39:
  
  
=TFTP folder tree=
 
  
This is how we'll setup our files and folders:
+
 
 +
 
 +
---------------------------------------
 +
 
 +
 
 +
 
 +
=Create Boot menu and Kernel setup=
 +
 
 +
The first thing to do is to setup a booting kernel. To do so we'll use the "syslinux" files.
 +
 
 +
 
 +
'''Reminder'''
 +
If your client(s) will use some smart-cards driver then you MUST install these drivers on the on the NFS server + reboot the server ; before going through the following steps. See [[Drivers#Smart-card_drivers]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
==Create NetBoot menu | defaults==
 +
 
 +
Now, we have to specify which kernel to use and which distributions are available for NetBoot.
 +
 
 +
 
 +
Create the default configuration file:
 +
 
 +
<syntaxhighlight lang="bash">
 +
vim /tftpboot/pxelinux.cfg/default
 +
</syntaxhighlight>
 +
 
 +
 
 +
Put the following:
 +
 
 +
<syntaxhighlight lang="bash">
 +
# Debian 7.x
 +
LABEL wheezy
 +
    kernel images/wheezy/vmlinuz
 +
    initrd images/wheezy/initrd.img
 +
 
 +
# Ubuntu 14.04
 +
LABEL trusty
 +
    kernel images/trusty/vmlinuz
 +
    initrd images/trusty/initrd.img
 +
 
 +
 
 +
# Prompt user for selection
 +
PROMPT 1
 +
# No timeout
 +
TIMEOUT 0
 +
</syntaxhighlight>
 +
 
 +
* Each LABEL is a specific configuration that will displayed on the NetBoot menu.
 +
* PROMPT 0 = enable user prompt so you can choose the configuration
 +
* TIMEOUT 0 = timeout (in seconds) before the default option is chosen. 0 == no timeout
 +
 
 +
 
 +
 
 +
Note that I used a reference to "trusty/", that's a folder I need to create later on.
 +
 
 +
 
 +
 
 +
==Init Kernel files==
 +
 
 +
 
 +
===Create directories===
 +
 
 +
Create the target kernel folders. You should create 1 folder for each distribution you'd like to provide in NetBoot.
 +
 
 +
<syntaxhighlight lang="bash">
 +
# Debian 7.x
 +
mkdir -p /tftpboot/images/wheezy
 +
 
 +
# Ubuntu 14.04
 +
mkdir -p /tftpboot/images/trusty
 +
</syntaxhighlight>
 +
 
 +
 
 +
===Prepare ''initramfs'' to boot over NFS===
 +
 
 +
'''This step must to be run on the machine that has the kernel you are going to serve to your clients'''.
 +
 
 +
 
 +
>>> In our case it has to be run on the TFTP server
 +
 
 +
 
 +
 
 +
Copy initramfs settings for PXE boot
 +
 
 +
<syntaxhighlight lang="bash">
 +
cp -r /etc/initramfs-tools /etc/initramfs-pxe
 +
</syntaxhighlight>
 +
 
 +
 
 +
Adjust PXE boot configuration
 +
 
 +
<syntaxhighlight lang="bash">
 +
cd /etc/initramfs-pxe/
 +
vim /etc/initramfs-pxe/initramfs.conf
 +
</syntaxhighlight>
 +
 
 +
 
 +
 
 +
Add / adjust the following options:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
##### TFTP root
+
BOOT=nfs
/tftpboot/                                 
+
MODULE=netboot
 +
</syntaxhighlight>
 +
 
 +
 
  
 +
===Copy and prepare kernel===
  
#### PXE application
 
/tftpboot/pxelinux.0
 
  
 +
You have to copy your current kernel files to the boot folder:
 +
 +
<syntaxhighlight lang="bash">
 +
# Debian 7.x
 +
cp /boot/vmlinuz-`uname -r` /tftpboot/images/wheezy/vmlinuz
 +
cp /boot/initrd.img-`uname -r` /tftpboot/images/wheezy/initrd.img
 +
 +
# Ubuntu 14.04
 +
cp /boot/vmlinuz-`uname -r` /tftpboot/images/trusty/vmlinuz
 +
cp /boot/initrd.img-`uname -r` /tftpboot/images/trusty/initrd.img
 +
</syntaxhighlight>
  
#### Boot configuration
 
  
/tftpboot/pxelinux.cfg/                # PXE configuration(s)
 
/tftpboot/pxelinux.cfg/menu.c32        # PXE interactive menu (text)
 
/tftpboot/pxelinux.cfg/vesamenu.c32    # PXE interactive menu (graphical)
 
  
/tftpboot/pxelinux.cfg/default                  # default NetBoot configuration
+
Enable NFS boot on target kernel:
  
/tftpboot/pxelinux.cfg/01-ec-a8-6b-fd-da-44    # specific configuration for host with MAC @ "EC-A8-6B-FD-DA-44"
+
<syntaxhighlight lang="bash">
 +
mkinitramfs -d /etc/initramfs-pxe -o /tftpboot/images/trusty/initrd.img
 +
</syntaxhighlight>
  
  
#### Netboot Kernels
+
Adjust rights:
  
/tftpboot/images/    
+
<syntaxhighlight lang="bash">
 +
chmod -R 755 /tftpboot/images/
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
 +
Notes:
 +
 +
* Do NOT use some symlink for "vmlinuz" and "initrd.img" !! It won't work.
 +
 +
* If you don't want to use `uname -r` [current kernel version and architecture] then adjust the values to target kernel number + architecture
 +
 +
* You have to run ''mkinitramfs'' for each kernel you'll provide
 +
 +
* Don't forget to adjust the rights to 755 for every distribution

Revision as of 09:43, 21 August 2014




TFTP configuration

TFTP can manage different configurations, up to 1 per host!

This is how a ThinClient (= netBoot client) will retrieve its configuration:


TFTP getConfiguration()


As you can see you have 3 possibilities:


1. MAC @ filter. Configuration file name must be:

  • Start with ARP type '01-'
  • all in lower case hexadecimal
  • dash '-' separators instead of ';'

for example a MAC @ 88:99:AA:BB:CC:DD would search for the filename 01-88-99-aa-bb-cc-dd.


2. IP @ filter. Configuration file name must be:

  • host IP / network address in hexadecimal
  • all in upper case

e.g. 192.0.2.91 -> C000025B


3. Default configuration


To learn more about all the available option, check out http://www.syslinux.org/wiki/index.php/PXELINUX.






Create Boot menu and Kernel setup

The first thing to do is to setup a booting kernel. To do so we'll use the "syslinux" files.


Reminder If your client(s) will use some smart-cards driver then you MUST install these drivers on the on the NFS server + reboot the server ; before going through the following steps. See Drivers#Smart-card_drivers



Create NetBoot menu | defaults

Now, we have to specify which kernel to use and which distributions are available for NetBoot.


Create the default configuration file:

vim /tftpboot/pxelinux.cfg/default


Put the following:

# Debian 7.x
LABEL wheezy
    kernel images/wheezy/vmlinuz
    initrd images/wheezy/initrd.img

# Ubuntu 14.04
LABEL trusty
    kernel images/trusty/vmlinuz
    initrd images/trusty/initrd.img


# Prompt user for selection
PROMPT 1
# No timeout
TIMEOUT 0
  • Each LABEL is a specific configuration that will displayed on the NetBoot menu.
  • PROMPT 0 = enable user prompt so you can choose the configuration
  • TIMEOUT 0 = timeout (in seconds) before the default option is chosen. 0 == no timeout


Note that I used a reference to "trusty/", that's a folder I need to create later on.


Init Kernel files

Create directories

Create the target kernel folders. You should create 1 folder for each distribution you'd like to provide in NetBoot.

# Debian 7.x
mkdir -p /tftpboot/images/wheezy

# Ubuntu 14.04
mkdir -p /tftpboot/images/trusty


Prepare initramfs to boot over NFS

This step must to be run on the machine that has the kernel you are going to serve to your clients.


>>> In our case it has to be run on the TFTP server


Copy initramfs settings for PXE boot

cp -r /etc/initramfs-tools /etc/initramfs-pxe


Adjust PXE boot configuration

cd /etc/initramfs-pxe/
vim /etc/initramfs-pxe/initramfs.conf


Add / adjust the following options:

BOOT=nfs
MODULE=netboot


Copy and prepare kernel

You have to copy your current kernel files to the boot folder:

# Debian 7.x
cp /boot/vmlinuz-`uname -r` /tftpboot/images/wheezy/vmlinuz
cp /boot/initrd.img-`uname -r` /tftpboot/images/wheezy/initrd.img

# Ubuntu 14.04
cp /boot/vmlinuz-`uname -r` /tftpboot/images/trusty/vmlinuz
cp /boot/initrd.img-`uname -r` /tftpboot/images/trusty/initrd.img


Enable NFS boot on target kernel:

mkinitramfs -d /etc/initramfs-pxe -o /tftpboot/images/trusty/initrd.img


Adjust rights:

chmod -R 755 /tftpboot/images/


Notes:

  • Do NOT use some symlink for "vmlinuz" and "initrd.img" !! It won't work.
  • If you don't want to use `uname -r` [current kernel version and architecture] then adjust the values to target kernel number + architecture
  • You have to run mkinitramfs for each kernel you'll provide
  • Don't forget to adjust the rights to 755 for every distribution