Tuesday, March 22, 2016

Automated OS Installation PXE server using iPXE - Part 1

Hello There,

In this series of posts, I will be explaining PXE server setup using iPXE and some other tools. By end of this tutorial, you will be having a PXE server which can accomplish the tasks for you.

1. a PXE server capable of installing all OSes like Windows, Linux and VMware.
2. Every OS will be installed with a single touch and no human intervention is required.
3. You can install OS on iSCSI or FCoE LUN and driver update to discover LUN is automated as well
4. The PXE sersver is capable of working on Legacy and UEFI modes.

As this setup needs some amount of configuration which we will do it in Parts, so that it will be easy to us to understand. I am dividing the configuration into below steps.

1. We will be configuring a DHCP server which will work for Legacy and UEFI boots.
2. We will install iPXE in DHCP server and configure iPXE boot loaders for Legacy and UEFI.
3. We setup a Cobbler server and configure the Kickstart files for Automated OS installation
4. We setup a Windows WDS server configure OSes for Automated OS installation
5. We will create scripts in iPXE to install the different OSes from different locations.

I hope it will fulfill you requirement. If I miss anything you can leave a comment so that I can try to explain that. 

Friday, February 12, 2016

IET - iSCSI Enterprise target

Hi,

This post is a simple tutorial on how to use IET software target. IET stands for iSCSI Enterprise Target. There are few Software targets available for Linux operating system and IET is one of the best and easy to configure software target.


You can download the IET target from the Sourceforge.net. The installation is pretty easy. In this tutorial I am not covering installation process.


Checking iSCSI Target service:

Once you install the IET target software in your Linux System, you need to check the IET service status using the below command to confirm that target service is running.

service iscsi-target status


If the service is not running you can start the service using the below command.


service iscsi-target start


We can create and delete targets and LUNs through command line or by editing the configuration file /etc/iet/ietd.conf. I will cover the command line configuration in this tutorial. IETADM is the tool to configure IET target.


Creating a New Target: 

We can create a new target using the below command.

ietadm --op new --tid=1 --params --name= iqn.2009-10.com.iet:target


In the above command, --op is the operation. We can mention different operations like new, delete and show.


--tid is the target ID. You can create multiple targets by providing different Target IDs with Unique Target IQN names for each target ID.


--params is the Parameters required to complete the command.


Once you create the target, you can check view the target details by the below command


cat /proc/net/iet/session


Deleting the existing Target:

To delete the existing target you can use the below command

ietadm --op delete --tid=1


You don't need to provide any parameters except Target ID to delete a target.


Creating a new LUN:

You can create a new LUN using the below command. I use dd command to create a LUN file in Linux. Make sure that you have enough space to create a Virtual LUN file in your Linux system. In this example I want to create the LUN file in /home directory.

dd if=/dev/zero of=/home/IET/target1/LUN0 bs=1G count=60


In the above example, bs stands for Block size and count is the multiplication of Block size to create the LUN with required size. So I will be creating 60 X 1G = 60G LUN. You can try Block size as 1k, 1m etc. It will take sometime based on the LUN size you have mentioned.


Now we have a LUN and Target created and we will see how to map the LUN to the target.


Mapping the LUN to Target:

You can map a LUN to the target using the below command.

ietadm --op new --tid=1 --lun=0 --params=path=/home/IET/target1/LUN0,Type=fileio


As per the above command, we are creating mapping a LUN as LUN id 0 with the LUN placed in /home/IET/target1 folder. Type is fileio as it needs to perform Input and Output operations. 


To check LUNs mapped to targets, use the below command.


cat /proc/net/iet/volume


It will list the available targets and LUNs mapped to the particular targets. 


Configuring CHAP:

CHAP provides security for the targets to be accessible by Initiators. CHAP is two types.

1. One way CHAP 

2. mutual CHAP

Use the below command to configure One way CHAP


ietadm --op new --tid=1 --user --params=IncomingUser=incuser,password=xxxxxxxxxxxx


Use the below command to configure mutual CHAP


ietadm --op new --tid=1 --user --params=OutgoingUser=ouruser,password=xxxxxxxxxxxx


Once you configure the One way and mutual CHAP, use the below command to check


ietadm --op show --tid=1 --user


This is the tutorial on IET software target usage. Please leave a comment if you have any query on this post. 


Thank you...




Wednesday, February 10, 2016

PXE Continuous Reboot using iPXE


Hi,

In this post, I will be explaining how to put a machine on PXE continuous reboot using iPXE. I am assuming that you are having the basic knowledge PXE functionality.


PXE continuous reboot works with the simple steps which I mentioned below.


1. First we will include a reboot script in PXE boot image.

2. Server boots from a pxe device and download the PXE boot image.
3. PXE boot image got executed and server will be rebooted
4. Server will reboot continuously as it follows the steps 1 to 3.

I will be using iPXE image for this task. iPXE is an extension to the PXE and it has more advantages like scripting which helps us in accomplish our task easily.


You need the below stuff to configure a iPXE server.


1. One Linux system which is having DHCP and TFTP configured.

2. IPXE ROM image and script files.

1. Configure DHCP server: 

Configuring DHCP server in linux is simple. Assign a static IP for one of the Linux system's port on which you want to configure DHCP server. 

Static IP: 172.20.10.20

Netmast: 255.255.255.0

Copy the below content to your dhcpd.conf in /etc/dhcp folder.


ddns-update-style interim;
option space ipxe;
option ipxe-encap-opts code 175 = encapsulate ipxe;
option ipxe.bus-id code 177 = string;

subnet 172.20.10.0 netmask 255.255.255.0 {

        default-lease-time 3600;
        max-lease-time 4800;
        option routers 172.20.10.20;
        option subnet-mask 255.255.255.0;
        range dynamic-bootp 172.20.10.21 172.20.10.254;
        option time-offset -8;
if not exists ipxe.bus-id {
next-server 172.20.10.20;
filename "undionly.kpxe";
}
else {
next-server 172.20.10.20;
filename "ipxe/menu.ipxe";      #Provide configuration file path
}
server-name "pxe_reboot_server";
server-identifier 172.20.10.20;
}

After editing the dhcpd.conf file, restart the dhcpd server and check for errors.

Configure IPXE:

Configure the tftp folder in the same linux server. You can get many online tutorials to configure a tftp folder so I am assuming that you have configured tftp server and make sure that tftp service is running.

I have my tftpserver share is pointing to /var/lib/tftpboot folder. Now I will place "undionly.kpxe" file directly in tftpboot folder. Now create a folder named "ipxe" in tftpboot folder and create a menu.ipxe file in "ipxe" folder.


We are having the file hierarchy as below. 

/tftpboot/undionly.kpxe
/tftpboot/ipxe/menu.ipxe

Now add the below code to menu.ipxe file.


#!ipxe

echo Server will reboot in 60 seconds
sleep 60
reboot

Now reboot the DHCP and TFTP services and check for errors. If you find any errors please leave comment explaining the error so that I can help.

Now enable PXE for the adapter and make sure to bring the PXE device up in the Boot order list to make sure that server will boot PXE first. Disable harddisk or any other boot-able device if required.  Reboot the server and you can see that server is going for continuous reboot after pxe boot.