LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Blogs > morningboy
User Name
Password

Notices

Rate this Entry

Boot From Network via PXE

Posted 05-06-2010 at 10:54 PM by morningboy
Updated 05-06-2010 at 11:10 PM by morningboy
Tags linux, pxe, rootfs

Boot from Network via PXE (Eng. Version)

--THE IDEA--


1. using root_fs for i386 we have made before to be able booted from network.
2. root_fs can be booted from Network with Boot From Network facility in BIOS.
3. We will use PXE Technology.

--UNDERSTANDING PXE--

PXE is ... you can read it at http://en.wikipedia.org/wiki/Preboot...on_Environment.

There are several BIOS that have been supported by PXE, but there are not. If you don't have any BIOS that is supported by PXE, you need some standard boot device such as USB FD, CF, HARDDISK etc) and it have to be configured first with gPXE, so it can handle PXE process.
Some application we need to boot with PXE :

1. DHCP
2. TFTP
3. SYSLINUX
4. gPXE (Optional)

--How Does it work ?--


1. If you set your system to boot from Network, system will send broadcast message with DHCP protocol. DHCP Server will give it an IP Address dan PXE configuration to it.
2. The system will start to download the configuration files for preparing booting process via tftp.
3. The system is ready to boot and ready to use.

Setting BIOS to boot from network

Set BIOS
Set BIOS

later the system which is booted from network will be called PXEClient

--CONFIGURE gPXE--

as we mentioned above, if you don't have any BIOS that is supported by PXE, you need some standard boot device that is configured with gPXE.
Below we will discuss about how to use gPXE.

1. Install gPXE, you can get the source from http://etherboot.org/wiki/index.php
2. We will use USB FD as standard boot device, so we need to copy the gpxe.usb to our device (ex: /dev/sda1). You can find gpxe.usb file in "./bin" directory at gpxe folder.
* Copy:
* dd if=bin/gpxe.usb of=/dev/sda1
3. Your USB FD is ready to use.

--CONFIGURE DHCP--

We need DHCP Server to assign IP Address and send early configuration file to our PXEClient. We can adjust our dhcp configuration in /etc/dhcpd.conf.
DHCP Configuration:
Assume:

1. IP Address PXEClient : 192.168.0.254/24
2. MACAddress : 00:0D:48:36:0C:E4
3. DHCP Server : 192.168.0.1/24
4. TFTP Server : 192.168.0.1/24
5. Konfigurasi file : pxelinux.0

File dhcpd.conf:

allow booting;
allow bootp;

# Standard configuration directives...
subnet 192.168.0.0 netmask 255.255.255.0 {
option domain-name "mydomain";
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option domain-name-servers 192.168.0.1;
option routers 192.168.0.1;

# Group the PXE bootable hosts together
group {
# PXE-specific configuration directives...
option dhcp-class-identifier "PXEClient";
next-server 192.168.0.1;
filename "/pxelinux.0";

# You need an entry like this for every host
# unless you're using dynamic addresses
host hostname {
hardware ethernet 00:0D:48:36:0C:E4;
fixed-address 192.168.0.254;
}
}


--CONFIGURE TFTP--

We use TFTP as transfer file protocol to download neede files.

1. install tftp,
2. you should check the default directory of downloadable file via tftp (/var/lib/tftpboot)
3. Activate tftp via inetd

--CONFIGURE SYSLINUX--

Syslinux is a Linux Operating System boot loader which operates off an MS-DOS/Windows FAT Filesystem. You can check with "man syslinux".
Intended to boot with PXE we need PXELINUX as a derivatif of syslinux.
Files needed to boot with pxe:

* pxelinux.0

we can get it from directory:

* /usr/lib/syslinux/pxelinux.0

-STEP BY STEP-
---Preparing The Files---
Please prepare the files we needed in default directory of tftp (/var/lib/tftpboot)
All of the files would be :

1. /var/lib/tftpboot/pxelinux.0
2. /var/lib/tftpboot/bzImage
3. /var/lib/tftpboot/root_fs_i386.gz
4. /var/lib/tftpboot/pxelinux.cfg/01-00-0d-48-36-0c-e4

5. /var/lib/tftpboot/pxelinux.cfg/C0A800FE
6. /var/lib/tftpboot/pxelinux.cfg/C0A800
7. /var/lib/tftpboot/pxelinux.cfg/C0A800
8. /var/lib/tftpboot/pxelinux.cfg/C0A80
9. /var/lib/tftpboot/pxelinux.cfg/C0A8
10. /var/lib/tftpboot/pxelinux.cfg/C0A
11. /var/lib/tftpboot/pxelinux.cfg/C0
12. /var/lib/tftpboot/pxelinux.cfg/C
13. /var/lib/tftpboot/pxelinux.cfg/default

You can see at point 4 to 13 are how syslinux read the configuration file. I have taken the article below from http://syslinux.zytor.com/wiki/index.php/PXELINUX:

1. First, it will search for the config file using the hardware type (using its ARP type code) and address, all in lower case hexadecimal with dash separators; for example, for an Ethernet (ARP type 1) with address 00:0d:48:36:0c:e4 it would search for the filename 01-00-0d-48-36-0c-e4.
2. Next, it will search for the config file using its own IP address in upper case hexadecimal, e.g. 192.168.0.254 -> C0A800FE (you can use the included progam gethostip to compute the hexadecimal IP address for any host). If that file is not found, it will remove one hex digit and try again. Ultimately, it will try looking for a file named default (in lower case). As an example, if the boot file name is /mybootdir/pxelinux.0, the Ethernet MAC address is `00:0d:48:36:0c:e4` and the IP address 192.168.0.254, it will try the files above (point 4 to 13).

The Example of Configuration for boot loader at 01-00-0d-48-36-0c-e4 file name:

* prompt 1
* default linux
* timeout 1
* label linux
* kernel bzImage
* append initrd=root_fs_i386.gz root=/dev/ram0 ramdisk_size=30000 noapic acpi=off

I often use the following configuration:
Files :

1. /var/lib/tftpboot/pxelinux.0
2. /var/lib/tftpboot/bzImage
3. /var/lib/tftpboot/root_fs_i386.gz
4. /var/lib/tftpboot/pxelinux.cfg/01-00-0d-48-36-0c-e4

--Execute DHCP Server--
Start dhcp server with the following command:

* dhcpd

Or you can execute it in foreground use :

* dhcpd -d

--Execute tftp server--

Start tftp server with the following command :

* inetd

PXEClient ready to boot from Network.

Google Tech Talk

[youtube=http://www.youtube.com/watch?v=GofOqhO6VVM]

Hope this help.
Posted in linux
Views 1145 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 10:06 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration