Setting up Pxe boot server using Centos5.8


This is a long tutorial which will show you how to set up a pxe_boot server, which will allow any machine on your network to boot from their ethernet port, rather than using a CD drive or the hard drive. You should be fairly familiar with linux before trying to do this.

    Install a base CentOS system.
    We need to add a repository to install cobbler so add a repo with the following command:
    vi /etc/yum.repos.d/extras.repo
    Make it look like the following:
    Now run:
    yum install cobbler httpd xinetd tftp-server -y
    When completed, your screen should look like this:
    For the purposes of this tutorial, you probably want your cobbler server to also be your dhcp server. TO do this run:
    yum -y install dhcp
    Now to set up your computer as a DHCP server (may or may not be the same machine). Enter the command shown below:
    vi /etc/dhcpd.conf
    Cobbler can manage the dhcp server if they are both on the same machine. To do this run the command below:
    vi /etc/cobbler/settings
    manage_dhcp: 0
    manage_dhcp: 1
    Please note that if you do this, later if you want to change your dhcp settings you need to run
    vi /etc/cobbler/dhcp.template
    and then perform a
    cobbler sync
    instead of directly editing the dhcp file with:
    vi /etc/dhcpd.conf
    Make it look like the following, except make sure the 'next-server' ise set to the ip of what you want the pxe boot server's ip to be (the same computer you are changing now).
    Now to change tftp to not be disabled on boot. run the command below:
    Change the disable value from yes to no
    Restart the xinetd service:
    Good idea to check that your change took effect:
    Make a directory for storing your linux distributions that you are going to allow pxe_booting:
    Make a directory for each distribution you are going to support.
    Mount your downloaded iso file (if you havent gotten one yet, download it!). If you haven't got/made a folder in your /mnt/ location make one now otherwise this will fail.
    mount -o loop /root/Fedora-14-x86_64-DVD.iso /mnt/iso

    if you 'ls' the directory you will now see the contents of the iso.
    Copy the files to your distribution directory that you just created.
    cp -R . /distros/my-distro-name/.
    If you want, use the following commands to ensure everything copied correctly.
    Unmount the iso.
    create a file called distros.conf in /etc/httpd and open it in vi.
    vi /etc/httpd/conf.d/distros.conf
    Make it look like the following:
    start the httpd service and make sure it will start at boot:
    Edit your iptables...
    Compare the following two print screens to see what lines to add (you may want it to be eth0 instead of eth1 though:

    restart the iptables service
    service iptables restart
    start the cobbler daemon:
    Update: If at this point you get a message:
    No module named ctypes
    Then you need to run:
    yum install python-ctypes
    This is because cobbler does not require python-ctypes package when it should.
    Run the cobbler check to see if everything is set up right:
    As you can see, its not set up correctly yet. Change your cobbler settings by entering the command below:
    vi /etc/cobbler/settings
    Your screen should look like this (dont make changes yet)
    change next_server: from to whatever the servers actual ip should be.

    The same should be done for the 'server'
    Save the changes and edit the ethernet details.
    vi /etc/sysconfig/network-scripts/ifcfg-eth1
    Make sure it looks similar to below (obviously dont copy the HWADDR) and you may need to be setting eth0 instead of eth1
    Update: If you are using Centos 5.8 (like I am in this tutorial) for your cobbler server, then you need to fix a potential problem with your cobbler/httpd settings.
    vi /etc/httpd/conf.d/wsgi.conf
    You need to uncomment (remove the #) the single line setting in the file as it is shown below:
    Further update. Even after running that, I still had problems getting cobbler daemon to run. I had to run the following two commands In order to iron out an issue with SELinux (from this blog about fixing cobbler settings)
    grep httpd /var/log/audit/audit.log | audit2allow -M httpdcobbler
    semodule -i httpdcobbler.pp
    Add the distro to cobbler with the following command(substituting parts that say fedora with whatever you specified):
    cobbler distro add --name=Fedora_14_x86_64 --kernel=/distros/fedora-14-x86_64/images/pxeboot/vmlinuz --initrd=/distros/fedora-14-x86_64/images/pxeboot/initrd.img
    (When I was doing this for ubuntu 12 it looked like this)
    cobbler distro add --name=Ubuntu_desktop_32bit --kernel=/distros/ubuntu12.04-desktop-32/casper/vmlinuz --initrd=/distros/ubuntu12.04-desktop-32/casper/initrd.lz
    Add to the cobblers profile. You dont have to provide the kickstart option if you want to manually set up. Also, make sure the distro option is named exactly the same as you used when specifying distro for cobbler earlier.
    Sync cobbler:
    cobbler sync
    Your screen should now look like so:
    Edit the file in /tftpboot/pxelinux.cfg/default:
    The file should look something like this: (A label for each profile you added)
    By the way, dont forget to ensure that you have a url option specified under the install line in your kickstart file similar to the following.


Picture gallery:

1 comment:

  1. Great post, im going to try this! (p.s. putpic images work again)