Boot Linux using PXE over LAN

There are a few circumstances where PXE booting is desirable, such as mass booting or booting a foreign OS on a legacy computer (that does not have USB booting or disc drive). The question is how to boot an OS over LAN? PXE is a way, but the setup is not as straightforward as you might think, and this post will show you how.

Things you should have.
APXE boot capable Linux distro
A PXE capable computer
pxelinux.0 file
A network switch (If you’re using a router disable the built-in DHCP)

Firstly place the pxelinux.0 file and the extracted Linux distro image folder into a main directory, for example I dump everything in the C:\Users\AhHeng\Desktop\PXE directory. Download tftpd to setup a DHCP server on your computer. DHCP works by telling the PXE booting computer where the OS is located and how to access it.


 
Open up tftpd and click on Settings. At the global tab make sure you have TFTP Server and DHCP Server enabled. 
 Click on the TFTP tab and at the advanced TFTP Options, tick ‘PXE Compabiliity’ and ‘Bind TFTP to this address’ (the LAN address of computer running tftpd). For the ‘Base Directory’ enter the full link to the main directory, for example mine is C:\Users\AhHeng\Desktop\PXE. 



At the DHCP tab, you can setup the DHCP anyway you like. My IP pool starting address (the first IP address to be assigned) is 192.168.28.2, size of pool (number of IP that can be assigned) is 20, Mask (the subnet of the network) is 255.255.255.255, the others you can leave blank however the Boot file, must be pxelinux.0. Also at the DHCP Options, make sure you untick ‘Ping address before assignation’ and tick ‘Bind DHCP to this address’ (the address of computer running tftpd). Click OK. Then, set the server interface to the address of computer running tftpd.



Next download FreeNFS and place the FreeNFS.exe at same directory of tftpd, and run it. The FreeNFS will serve the actual OS file system after tftpd told the PXE booting computer where to look for it. Enter the folder location where you extracted your Linux distro. For example, my Backtrack 5 is located at C:\Users\AhHeng\Desktop\PXE\BT5.

Before you can start booting, create a folder called pxelinux.cfg (yes a folder with a file extension) at the main directory and in the pxelinux.cfg folder create a new text file. In the text file copy paste this whole thing

TIMEOUT 100
DEFAULT bt5
PROMPT 1
DISPLAY /isolinux.msg
LABEL bt5
        KERNEL BT5/casper/vmlinuz
        APPEND initrd=BT5/casper/initrd.gz BOOT=casper boot=casper netboot=nfs nfsroot=192.168.1.2:/BT5

In my case, this is correct, and should work on other Linux distro. The KERNEL option you see points to the kernel of the Linux distro to be booted, so for example my Backtrack 5 is placed at C:\Users\AhHeng\Desktop\PXE\BT5, the KERNEL option is BT5/casper/vmlinuz (mind the slash and backslash). The LABEL option you can put anything you like, but remember it because you have to enter this LABEL when booting .The APPEND option is the extra commands that are passed to the KERNEL

 initrd=BT5/casper/initrd.gz BOOT=casper boot=casper netboot=nfs nfsroot=192.168.1.2:/BT5

Replace the’ BT5/’ with the name of your folder and the ‘192.168.1.2:/BT5’ with the address of the computer running tftpd, also replace the DEFAULT option to what you entered for LABEL. Then, save the text file with the name ‘default’ (without any file extensions).



Go back to the main directory and create a text file called ‘isolinux.msg’, open it up and enter anything you like, such as ‘Type BT5 to load backtrack 5’ and save it. The message will be shown when booting.

All said and done, connect your PXE booting computer to the network and set it to boot from network, and you should see something like this.

 
And then this


At the prompt, type in the LABEL option that you entered previously or wait for it to boot automatically.
After all the scrolling the PXE booting computer will start to look for the NFS hosted file system, and start the live OS.


0 comments:

Post a Comment

techteendaily One Line Description Avatar Logo a one place stopshop for some of your tech needs. Though this blog is not updated frequently, but it's information are still meant to be usable and feasible. As the blogger is a lazy person, and also there are no audience at the moment, so maintainence is kept to the lowest priority. If you want this blog to come alive, PLEASE TELL ME and POST COMMENTS to let me know that you care.