Wednesday, December 19, 2012

Remote Installation Service in LINUX


Required Softwares:

DHCP server
NFS server
TFTP-HDA server

Command to install

1.) sudo apt-get install tftpd-hpa dhcp3-server nfs-kernel-server syslinux

sudo mkdir /srv
sudo mkdir /srv/tftpboot
then edit the tftp-hpa file

2.) sudo vi /etc/default/tftpd-hpa


and add the following lines in that

TFTP_USERNAME="tftp"

TFTP_DIRECTORY="/srv/tftpboot"

TFTP_ADDRESS="<IP.OF.YOUR.SERVER>:69"

TFTP_OPTIONS="--secure -l"


3.) Configure the /etc/dhcp3/dhcpd.conf file like so:

sudo vi /etc/dhcp3/dhcpd.conf

allow booting;
allow bootp;
group
{
    next-server IP.OF.YOUR.SERVER;
    filename     "/pxelinux.0";
    host laptop
    {
            hardware ethernet    mac:address:of:device;
            option host-name     "laptop";
    }
}


4.) Create the Ubuntu PXE Environment(s):

sudo mkdir -p /srv/tftpboot/pxelinux.cfg

sudo mkdir /srv/tftpboot/OS1

sudo mkdir /srv/tftpboot/OS2



5.) Loop mount the ISOs into place:

sudo mount -o loop /path/to/OS1.iso /srv/tftpboot/OS1

sudo mount -o loop /path/to/OS2.iso /srv/tftpboot/OS2


6.) Create a nice message screen that will be displayed upon PXE boot:

sudo vi /srv/tftpboot/message

:: Ubuntu PXE Environment ::
============================
OPTIONS:           DESCRIPTIONS:
OS1 (Default) == OS1  
OS2       == OS2  
----------------------------------------------------
Type the option, and hit enter:





7.) Create the default pxelinux config file:

sudo vi /srv/tftpboot/pxelinux.cfg/default

DISPLAY message
DEFAULT OS1
PROMPT 1
TIMEOUT 0
LABEL OS1
    kernel 11.04x86desktop/casper/vmlinuz
    append root=/dev/nfs boot=casper netboot=nfs nfsroot=IP.OF.YOUR.SERVER:/srv/tftpboot/11.04x86desktop initrd=11.04x86desktop/casper/initrd.lz --
LABEL OS2
    kernel 11.04x64desktop/casper/vmlinuz
    append root=/dev/nfs boot=casper netboot=nfs nfsroot=IP.OF.YOUR.SERVER:/srv/tftpboot/11.04x64desktop initrd=11.04x64desktop/casper/initrd.lz --

8.) Copy the pxelinux.0 file into place:

sudo cp /usr/lib/syslinux/pxelinux.0 /srv/tftpboot/


9.) Configure the NFS server like so:

sudo vi /etc/exports

/srv/tftpboot/OS1  *(ro,sync,no_root_squash,no_subtree_check)
/srv/tftpboot/OS2  *(ro,sync,no_root_squash,no_subtree_check)

10.) Start all the appropriate services:

sudo exportfs -va
sudo service tftpd-hpa start
sudo service dhcp3-server start
sudo service nfs-kernel-server start



11.) Go boot the laptop, and you should be presented with the "

:: Ubuntu PXE Environment ::" menu.
Enjoy!