Monday, 20 August 2012

Installing and Configuring PXE Boot for CentOS

Installing and Configuring PXE Boot for CentOS


Assuming that you have followed all the steps mentioned in the earlier tutorials, we now have a fully working PXE Server

To test this PXE Server, we will create a new VM in VMware Workstation with NAT Network (as our PXE Server is also placed on the NAT Network) and boot CentOS from it.

From VMware Workstation, Select "Create New Virtual Machine"

Select "Typical" and click "Next"

Select "I will install the OS later" and click "Next"

Select "Linux" as the OS and "Other Linux 64 Bit" as the version

Provide a name to this VM. In this case, its TestVM

Specify "Disk Size". We just want this VM for testing, so provide a minimum disk size (8 GB)

Click "Finish" to complete the VM customization.
NOTE: Make sure the Network card of the Test VM is that of NAT.

When all is done, Power ON the VM

When the VM powers ON, you will see that it contacts the DHCP server and tries to obtain an IP address. This DHCP Server is the one that we have configured in our earlier post with PXE Boot.

After few seconds, you be prompted with the following Boot Screen. 

NOTE: This Boot Screen is displayed according to the text and info provided in the "DEFAULT" file present in /tftpboot/pxelinux.cfg directory

Select the CentOS 5 (DVD - 64-BIT) Option and hit Enter Key.

You will see some text run by followed by a message "Greetings"

You will now be prompted to "Select the Language" for the Installation process

NOTE: This is the beginning of your CentOS installation process using PXE Boot

Select the type of "Keyboard"

This new VM will now query back to the PXE Server to determine its "Hostname" and "Domain".

Once done, it will retrieve few necessary files for the installation process

And shortly after that, you will get the CentOS Installation screen launching its anaconda KickStart script

You can now install CentOS manually as you do on normal basis. 

NOTE: This installation is a manual process. You can automate the entire installation by using a KickStart File. To know more about this, check out the post on Automating Linux Installations using KickStart

That's it !! you can now install CentOS using your PXE Server. 

To add more OS to your PXE Server, just follow these simple steps:

Create a new directory in /var/www/html folder by the name of your new OS (e.g. RHEL)
# cd /var/www/html
# mkdir RHEL

Mount the RHEL ISO to your PXE Server

Copy the contents of your entire RHEL ISO to this newly created folder (/var/www/html/RHEL)

Create an associate folder for housing your OS's vmlinux and initrd.img file at /tftpboot/images directory 
# mkdir -P /tftpboot/images/rhel

Copy the vmlinux and initrd.img files from either the mounted ISO or from the copied ISO contents at /var/www/html/RHEL, whichever you want

Place both these files in /tftpboot/images/rhel folder as shown below:

Next, in the default file, present in the /tftpboot/pxelinux.cfg directory, add the details for your new OS (RHEL) as shown:

KERNEL images/rhel/5/x86_64/vmlinuz
APPEND vga-=normal initrd=images/rhel/5/x86_64/initrd.img
method=http://<YOUR PXE SERVER IP>/RHEL ip=dhcp
url --url http://<YOUR PXE SERVER IP>/RHEL

NOTE: There is no "enter" in the APPEND line.. its a continuous statement

Save the file and exit.

Restart the DHCP, the Apache and the PXE Service

# service httpd restart
# service dhcpd restart
# service xinetd restart

Now when you boot a new VM again using the same steps as we followed at the beginning of this Post, then you will now see two menus in your PXE Boot Menu.

Select the RHEL Menu and hit Enter Key

Again after some loading and selecting the keyboard and stuff, you will be shown the RHEL 6 installation screen as shown below.

That's it !! You now have installed, configured and tested a PXE Boot Server on a CentOS VM !!

In my NEXT POST, I will be demonstrating how to Automate a Linux Installation using KickStart File, so stay tuned !!

No comments :

Post a Comment

Note: only a member of this blog may post a comment.