Benutzer-Werkzeuge

Webseiten-Werkzeuge


linux:pxe_server

Debian 5 PXE-Server

In this tutorial I’m going to explain how to prepare Debian 5 to deliver Live Operating Systems (in this case Clonezilla)
via PXE-Boot with the Live OS Images stored on a network share.
This tutorial requires rudimentary Linux knowledge, as it will not cover basics like nano.

Pre-Requirements

The first step requires a default Debian installation. For this installation only Debian 5 CD1 is necessary.
Download it from the official Debian website at http://www.debian.org/.
For the installation process, please refer to the software users manual.
Next download Clonezilla Live from http://www.clonezilla.org or any other Linux based Distribution.
The steps to integrate a Linux based Distribution are mostly the same.
For this tutorial the Clonezilla image file will be stored on a Windows network share (\\172.26.209.2\Bootimages).

Network Configuration

Before proceeding with the next step, make sure your network is configured.
In this Tutorial the following settings are used:

nano /etc/network/interfaces
auto eth0
iface eth0 inet static
  address 172.26.209.7
  gateway 172.26.209.1
  netmask 255.255.255.0
  network 172.26.209.0
  broadcast 172.26.209.255

And restart your networking service:

/etc/init.d/networking restart

In addition a properly configured DHCP-Server is required.
If you already have a Linux based DHCP server in your network, you must modify its configuration.
Add the following lines to your configuration:

filename “pxelinux.0″;
next-server 172.26.209.7;

Where 172.26.209.7 is the IP Address of our Debian PXE server.
On a Windows based DHCP server add the following entries:

066 Boot Server Host Name and the IP address of my PXEserver as the string
067 Bootfile Name and a String Value of pxelinux.0

If your network privacy is protected by a proxy server please follow these instructions:

export http_proxy=’http://username:password@proxy.thing.com:8080/’; 

To make the proxy permanent for all users add the line to your /etc/environment file.

nano /etc/environment

Now check your installation sources to make sure that you get all packages.

nano /etc/apt/sources.list

My repository list looks like this:

# deb cdrom:[Debian GNU/Linux 5.0.6 _Lenny_ - Official i386 CD Binary-1 20100904-18:58]/ lenny main
# deb cdrom:[Debian GNU/Linux 5.0.6 _Lenny_ - Official i386 CD Binary-1 20100904-18:58]/ lenny main

deb http://security.debian.org lenny/updates main contrib
deb-src http://security.debian.org/ lenny/updates main contrib

deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main contrib

deb http://ftp.tu-chemnitz.de/pub/linux/debian/debian lenny main contrib
deb-src http://ftp.tu-chemnitz.de/pub/linux/debian/debian lenny main contrib

Then update the package list and install the following packages:

apt-get update
apt-get -y install lighttpd syslinux tftp-hpa smbfs

TFTP-Configuration

At first you need to configure the TFTPBoot directory and set the folder which tftpd should use as root directory.

mkdir /tftpboot
nano /etc/default/tftpd-hpa
RUN_DAEMON=”yes”
OPTIONS=”-l -s /tftpboot -m /etc/tftp_remap.conf”

Create a tftp remap file. This is used to translate back slashes to forward slashes.
It’s useful particulary if you want to boot a Windows PE via network.

nano /etc/tftp_remap.conf
rg \\ /
/etc/init.d/tftpd-hpa start

Lighttpd Configuration

We will configure syslinux to deliver our clonezilla files via http.
So we need a proper configured http Server. I decided to use lighttpd because it’s small and has the functionality we need.
There are only a few settings that are going to be configured.

mkdir /mnt/http
nano /etc/lighttpd/lighttpd.conf
server.modules = (
“mod_access”,
“mod_alias”,
“mod_accesslog”,
“mod_compress”
)

server.document-root = “/mnt/http”
/etc/init.d/lighttpd restart

Getting the Images

Now you will need the Clonezilla image which is stored on a network share:

mkdir /media/Bootimages\\ 
smbmount // 172.26.209.2/Bootimages /media/Bootimages -o user=‹USER›,pass=‹PASSWORD›,dom=‹DOMAIN›

If you want to mount the share automatically, type the above line in your fstab file.

nano /etc/fstab

Now we need to mount the iso image in the http directory.

mkdir -p /mnt/http/Clonezilla
mount -o loop /media/Bootimages/clonezilla-live-1.2.6-24-i486.iso /mnt/http/Clonezilla

Also include this mount command in your /etc/fstab file to get the image automatically mounted after you reboot your Server.

Syslinux Configuration

From the mounted Clonezilla CD Transfer initrd1.img, vmlinuz1 and memtest to /tftpboot:

cp /mnt/http/Clonezilla/live/vmlinuz1 /tftpboot/clonezilla.vmlinuz1
cp /mnt/http/Clonezilla/live/initrd1.img /tftpboot/clonezilla.initrd1.img
cp /mnt/http/Clonezilla/live/memtest /tftpboot/memtest86

The following files are necessary to display our PXE-Boot menu:

cp /usr/lib/syslinux/pxelinux.0 /tftpboot/pxelinux.0
cp /usr/lib/syslinux/menu.c32 /tftpboot/menu.c32

Next you will have to configure the PXE-Boot menu:

mkdir /tftpboot/pxelinux.cfg
nano /tftpboot/pxelinux.cfg/default
prompt 1
default menu.c32
prompt 0
noescape 1
allowoptions 0
timeout 120
ontimeout localboot
menu title PXE-Boot Options
menu width 80
menu margin 22
menu passwordmargin 26
menu rows 6
menu tabmsgrow 15
menu cmdlinerow 15
menu endrow 24
menu passwordrow 12
menu timeoutrow 13
menu vshift 6

label localboot
menu label Boot from first local harddrive
localboot 0

label Clonezilla
kernel clonezilla.vmlinuz1
append initrd=clonezilla.initrd1.img boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run=”ocs-live-general” ocs_live_batch=”no” vga=788 nosplash fetch=http://172.26.209.7/Clonezilla/live/filesystem.squashfs

label memtest
menu label Memtes86+
kernel memtest86

At last you’ll apply a recursively chmod 777 to make all files in /tftpboot usable for everyone.

chmod -R 777 /tftpboot

Steps to integrate another Linux Distribution

Copy the Image on the network share.

mkdir -p /mnt/http/‹LINUXDISTRO›
mount -o loop /media/Bootimages/‹LINUXDISTRO›.iso /mnt/http/‹LINUXDISTRO›

From the mounted Linuxdistro CD Transfer initrd1.img and vmlinuz1 to /tftpboot.
The files can also be called initrd.img or vmlinuz.

cp /mnt/http/‹LINUXDISTRO›/live/vmlinuz1 /tftpboot/‹LINUXDISTRO›.vmlinuz1
cp /mnt/http/‹LINUXDISTRO›/live/initrd1.img /tftpboot/‹LINUXDISTRO›.initrd1.img

Add the following lines to your PXE-Boot Menu:

nano /tftpboot/pxelinux.cfg/default
label ‹LINUXDISTRO›
kernel ‹LINUXDISTRO›.initrd1.img
append initrd=‹LINUXDISTRO›.initrd1.img boot=live union=aufs noswap noprompt vga=788 fetch=http://172.26.209.7/‹LINUXDISTRO›/live/filesystem.squashfs

Important! These steps may vary from Distribution to Distribution!
Please take a look in the documentation of your Distribution.

Steps to integrate a Windows PE 3.0

In this article I described how to prepare all necessary files for a Windows PE 3.0 PXE-Boot.
And in another article from me is covered how to create a more advanced Windows PE 3.0.
To integrate this WinPE, extract the SOURCES\BOOT.WIM file from the WinPE3.0 image and upload it to /tftpboot/Boot/winpex86.wim, or whatever your /Boot/winpex86.wim structure is.
After you uploaded the folder to /tftpboot/execute the following command:

ln -s /tftpboot/Boot/bootmgr.exe /tftpboot/.
linux/pxe_server.txt · Zuletzt geändert: 2014/03/10 22:24 von Madic