Difference between revisions of "TFTP server manage netboot kernels"

 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
  
 +
=Prepare NetBoot kernel=
  
 +
All these steps must be done on the server who has the kernel you want to extract.
  
=TFTP configuration=
+
Best practice: ''<big>you should perform the kernel extraction on the TFTP server!</big>''
  
TFTP can manage different configurations, up to 1 per host!
 
  
This is how a ThinClient (= netBoot client) will retrieve its configuration:
 
  
 +
==IMPORTANT NOTES==
  
[[File:TFTP getConfiguration().png|none|TFTP getConfiguration()]]
+
You're about to extract a server kernel and make it available for NetBooting. Make sure that:
  
 +
* The '''kernel has all the drivers installed and configured'''
 +
* The '''kernel doesn't need a reboot'''
  
As you can see you have 3 possibilities:
+
If your client(s) will use some specifics drivers then you MUST install these drivers before going through the following steps.
  
 +
You need to be very careful, especially if you plan to use some smart-card reader!
  
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:
+
==Create TFTP Kernel directory==
* host IP / network address in hexadecimal
 
* all in upper case
 
e.g. 192.0.2.91 -> C000025B
 
  
 +
Create the TFTP kernel's folder. You should create '''1 folder for each kernel''' you'd like to provide in NetBoot.
  
3. '''Default configuration'''
+
<syntaxhighlight lang="bash">
 +
# Ubuntu 14.04 - Kernel version 3.13.0.32 (August 2014)
 +
mkdir -p /tftpboot/images/trusty
 +
</syntaxhighlight>
  
  
To learn more about all the available option, check out http://www.syslinux.org/wiki/index.php/PXELINUX.
 
  
 +
==Enable NFS support==
  
 +
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">
 +
BOOT=nfs
 +
MODULE=netboot
 +
</syntaxhighlight>
  
=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.
 
  
 +
==Copy and prepare kernel==
  
'''Reminder'''
+
Copy kernel's files
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]]
 
  
 +
<syntaxhighlight lang="bash">
 +
cp /boot/vmlinuz-`uname -r` /tftpboot/images/trusty/vmlinuz
 +
cp /boot/initrd.img-`uname -r` /tftpboot/images/trusty/initrd.img
 +
</syntaxhighlight>
  
  
 +
Enable NFS boot option
  
 +
<syntaxhighlight lang="bash">
 +
mkinitramfs -d /etc/initramfs-pxe -o /tftpboot/images/trusty/initrd.img
 +
</syntaxhighlight>
  
==Create NetBoot menu | defaults==
 
 
Now, we have to specify which kernel to use and which distributions are available for NetBoot.
 
  
 
+
Adjust rights
Create the default configuration file:
 
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
vim /tftpboot/pxelinux.cfg/default
+
chmod -R 755 /tftpboot/images/
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Put the following:
 
  
<syntaxhighlight lang="bash">
+
Notes:
# Debian 7.x
 
LABEL wheezy
 
    kernel images/wheezy/vmlinuz
 
    initrd images/wheezy/initrd.img
 
  
# Ubuntu 14.04
+
* Do NOT use some symlink for "vmlinuz" and "initrd.img" !! It won't work.
LABEL trusty
 
    kernel images/trusty/vmlinuz
 
    initrd images/trusty/initrd.img
 
  
 +
* If you don't want to use `uname -r` [current kernel version and architecture] then adjust the values to target kernel number + architecture. You can use the `uname -r`command's result.
  
# Prompt user for selection
+
* You have to run ''mkinitramfs'' for each kernel you'll provide
PROMPT 1
 
# No timeout
 
TIMEOUT 0
 
</syntaxhighlight>
 
  
* Each LABEL is a specific configuration that will displayed on the NetBoot menu.
+
* Don't forget to adjust the rights to 755 for every distribution
* 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.
 
  
 +
==Kernel modules and source==
  
 +
Your NFS image must have the kernel's libraries and modules, and that must match the kernel's version of the TFTP server!!
  
==Init Kernel files==
+
Since Linux kernel is evolving every month or so, you need to backup your kernel's libraries and modules for future use.
  
  
===Create directories===
+
Create kernel source directory
 
 
Create the target kernel folders. You should create 1 folder for each distribution you'd like to provide in NetBoot.
 
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# Debian 7.x
+
# Ubuntu 14.04 - Kernel version 3.13.0.32 (August 2014)
mkdir -p /tftpboot/images/wheezy
+
mkdir -p /tftpboot/sources-images/trusty/lib/modules
 +
mkdir -p /tftpboot/sources-images/trusty/usr/src
 +
</syntaxhighlight>
  
# Ubuntu 14.04
 
mkdir -p /tftpboot/images/trusty
 
</syntaxhighlight>
 
  
 +
Copy libraries and modules
  
===Prepare ''initramfs'' to boot over NFS===
+
<syntaxhighlight lang="bash">
 +
# Copy kernel modules
 +
cp -r /lib/modules/`uname -r` /tftpboot/sources-images/trusty/lib/modules
  
'''This step must to be run on the machine that has the kernel you are going to serve to your clients'''.
+
# Copy kernel sources
 +
cp -r /usr/src/linux-headers-`uname -r` /tftpboot/sources-images/trusty/usr/src/
 +
</syntaxhighlight>
  
  
>>> In our case it has to be run on the TFTP server
 
  
  
 +
=Update TFTP configuration=
  
Copy initramfs settings for PXE boot
+
If you haven't configure TFTP boot yet, check-out [[TFTP_server_PXE_configuration]]
  
<syntaxhighlight lang="bash">
 
cp -r /etc/initramfs-tools /etc/initramfs-pxe
 
</syntaxhighlight>
 
  
  
Adjust PXE boot configuration
+
To use your new kernel you just need to update TFTP configuration file.
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd /etc/initramfs-pxe/
+
vim /tftpboot/pxelinux.cfg/default
vim /etc/initramfs-pxe/initramfs.conf
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
  
Add / adjust the following options:
+
Put the following instead of the previous kernel:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
BOOT=nfs
+
# Ubuntu 14.04
MODULE=netboot
+
    kernel images/trusty/vmlinuz
 +
    initrd images/trusty/initrd.img
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
  
===Copy and prepare kernel===
+
=Debug kernel=
  
 +
During NetBoot client startup you might encounter some '''modprobe errors'''.
  
You have to copy your current kernel files to the boot folder:
+
That means the thin client failed to access your kernel's libraries and / or modules.
  
<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
+
==NFS image update==
cp /boot/vmlinuz-`uname -r` /tftpboot/images/trusty/vmlinuz
+
 
cp /boot/initrd.img-`uname -r` /tftpboot/images/trusty/initrd.img
+
Access your NFS image by CHROOT /nfs/... + login
</syntaxhighlight>
 
  
  
  
Enable NFS boot on target kernel:
+
1. Be sure to '''install the kernel's header''' on the NFS image:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
mkinitramfs -d /etc/initramfs-pxe -o /tftpboot/images/trusty/initrd.img
+
apt-get install linux-headers-3.13.0-32
 +
apt-get install linux-headers-3.13.0-32-generic
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
<small>''Replace "3.13.0-32" by your version''</small>
  
  
Adjust rights:
 
  
<syntaxhighlight lang="bash">
+
2. Check the symlinks
chmod -R 755 /tftpboot/images/
 
</syntaxhighlight>
 
  
 +
Sometimes when there is just 1 kernel the OS will check for libraries in ''/lib/modules'' instead of ''/lib/modules/kernel-version''
  
  
Notes:
+
You can try to copy all the modules files to /lib/modules and adjust the symlink.
  
* Do NOT use some symlink for "vmlinuz" and "initrd.img" !! It won't work.
+
<syntaxhighlight lang="bash">
 +
cd /lib/modules
 +
mv 3.13.0-32-generic/* .
 +
rm -rf 3.13.0-32-generic
 +
ln -s /lib/modules/ /lib/modules/3.13.0-32-generic
 +
</syntaxhighlight>
  
* If you don't want to use `uname -r` [current kernel version and architecture] then adjust the values to target kernel number + architecture
+
<small>''Replace "3.13.0-27" by your version''</small>
  
* You have to run ''mkinitramfs'' for each kernel you'll provide
 
  
* Don't forget to adjust the rights to 755 for every distribution
+
That should do !

Latest revision as of 11:31, 21 August 2014



Prepare NetBoot kernel

All these steps must be done on the server who has the kernel you want to extract.

Best practice: you should perform the kernel extraction on the TFTP server!


IMPORTANT NOTES

You're about to extract a server kernel and make it available for NetBooting. Make sure that:

  • The kernel has all the drivers installed and configured
  • The kernel doesn't need a reboot
If your client(s) will use some specifics drivers then you MUST install these drivers before going through the following steps. 

You need to be very careful, especially if you plan to use some smart-card reader!


Create TFTP Kernel directory

Create the TFTP kernel's folder. You should create 1 folder for each kernel you'd like to provide in NetBoot.

# Ubuntu 14.04 - Kernel version 3.13.0.32 (August 2014)
mkdir -p /tftpboot/images/trusty


Enable NFS support

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

Copy kernel's files

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


Enable NFS boot option

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 can use the `uname -r`command's result.
  • You have to run mkinitramfs for each kernel you'll provide
  • Don't forget to adjust the rights to 755 for every distribution



Kernel modules and source

Your NFS image must have the kernel's libraries and modules, and that must match the kernel's version of the TFTP server!!

Since Linux kernel is evolving every month or so, you need to backup your kernel's libraries and modules for future use.


Create kernel source directory

# Ubuntu 14.04 - Kernel version 3.13.0.32 (August 2014)
mkdir -p /tftpboot/sources-images/trusty/lib/modules
mkdir -p /tftpboot/sources-images/trusty/usr/src


Copy libraries and modules

# Copy kernel modules
cp -r /lib/modules/`uname -r` /tftpboot/sources-images/trusty/lib/modules

# Copy kernel sources
cp -r /usr/src/linux-headers-`uname -r` /tftpboot/sources-images/trusty/usr/src/



Update TFTP configuration

If you haven't configure TFTP boot yet, check-out TFTP_server_PXE_configuration


To use your new kernel you just need to update TFTP configuration file.

vim /tftpboot/pxelinux.cfg/default


Put the following instead of the previous kernel:

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


Debug kernel

During NetBoot client startup you might encounter some modprobe errors.

That means the thin client failed to access your kernel's libraries and / or modules.


NFS image update

Access your NFS image by CHROOT /nfs/... + login


1. Be sure to install the kernel's header on the NFS image:

apt-get install linux-headers-3.13.0-32
apt-get install linux-headers-3.13.0-32-generic

Replace "3.13.0-32" by your version


2. Check the symlinks

Sometimes when there is just 1 kernel the OS will check for libraries in /lib/modules instead of /lib/modules/kernel-version


You can try to copy all the modules files to /lib/modules and adjust the symlink.

cd /lib/modules
mv 3.13.0-32-generic/* . 
rm -rf 3.13.0-32-generic 
ln -s /lib/modules/ /lib/modules/3.13.0-32-generic

Replace "3.13.0-27" by your version


That should do !