Red Hat Enterprise Linux 6.x – small tutorial - part 3

37 downloads 2640 Views 461KB Size Report
a.pdf), I've described how to configure and install RHEL 6.4 using Kickstart ... Te fIrst of them (rhel641.example.com) is my RHEL Kickstart repository like as it.
Red Hat Enterprise Linux 6.x – small tutorial - part 3

Red Hat Enterprise Linux 6.x - small tutorial - part 3 author: Alexandre Borges revision: A website: http://alexandreborges.org

Installing RHEL 6.x from beginning to end using PXE and Kickstart Introduction In the first part of this series (http://alexandreborgesbrazil.files.wordpress.com/2013/07/alexandre_blog_first_post_rhel_1 a.pdf), I've described how to configure and install RHEL 6.4 using Kickstart method (taking packages from a local repository) and, as the reader can remember, that procedure explained how to install Red Hat Enterprise Linux 6 without enter any information during the installation process. However, some people have asked for a way to install RHEL 6.4 through the network (like in the first article), but without the obligation of using an RHEL 6.4 dvd to start the task. In an other words, it would be very cool turn a machine on without any operating system and DVD attached, and just waiting for its complete installation. For demonstrating the whole procedure, I'll be using a virtual machine running RHEL 6.4 in VMware Workstation 10 and I'm going to create a second one accomplish some tests taking the PXE boot. Te fIrst of them (rhel641.example.com) is my RHEL Kickstart repository like as it was configured in our first article about RHEL and it will be used to execute all commands of this document.

Step-by-Step PXE procedure 1) Confirm that your Kickstart configuration is correct as we have set in the first article of this series. A example of working repository: [root@redhat641 ~]# more /etc/yum.repos.d/newrepository.repo [blog] name=Local Repository baseurl=http://192.168.1.150/software enabled=1 gpgcheck=0

http://alexandreborges.org

Página 1

Red Hat Enterprise Linux 6.x – small tutorial - part 3

[root@redhat641 www]# yum search nmap Loaded plugins: product-id, refresh-packagekit, security, subscription-manager ===================================================================== N/S Matched: nmap ===================================================================== nmap.x86_64 : Network exploration tool and security scanner Name and summary matches only, use "search all" for everything.

As the reader can prove, everything is OK.

2) Install the following packages: httpd, dhcp, tftp-server, syslinux and xinetd. Probably some packages have already installed in your system (for example, in my case, I have needed to install syslinux, dhcp and tfftp-server packages: [root@redhat641 ~]# yum install -y dhcp syslinux xinetd httpd

tftp-server

3) This step is a bit strange, but it should be done exactly this way. You must create a specific directory for PXE configuration and copy a template to this directory:

[root@redhat641 ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [root@redhat641 ~]# cp /usr/share/syslinux/pxelinux.0

/var/lib/tftpboot/

4) Edit the tftpd service configuration file (contained in the xinetd framework), enable the service and, afterwards, restart the xinetd and configure it to a permanent “on” status:

[root@redhat641 ~]# vi /etc/xinetd.d/tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 http://alexandreborges.org

Página 2

Red Hat Enterprise Linux 6.x – small tutorial - part 3

cps flags

= 100 2 = IPv4

}

[root@redhat641 ~]# service xinetd restart Stopping xinetd: Starting xinetd:

[ OK ] [ OK ]

[root@redhat641 ~]# chkconfig xinetd on [root@redhat641 ~]# chkconfig --list xinetd xinetd 0:off 1:off 2:on 3:on

4:on

5:on

6:off

5) Configure the DHCP for providing an IP address to a new machine which we will install the RHEL6. To complete this task, we should edit the DHCP configuration file and change it according your network. I suggest you pay attention to highlighted parts: [root@redhat641 Desktop]# vi /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # see 'man 5 dhcpd.conf' # # Global Options Allow booting; Allow bootp; authoritative; log-facility local7; # Subnet definition subnet 192.168.1.0 netmask 255.255.255.0 { # Parameters for the local subnet option routers 192.168.1.1; option subnet-mask 255.255.255.0; option domain-name "example.com"; option domain-name-servers 8.8.8.8; default-lease-time 21600; max-lease-time 43200; # Client IP range range dynamic-bootp 192.168.1.150 192.168.1.170; filename "pxelinux.0"; next-server 192.168.1.150; } Some very important things about this file:

http://alexandreborges.org

Página 3

Red Hat Enterprise Linux 6.x – small tutorial - part 3



Allow bootp / Allow booting → it's needed to be able to boot a new machine from network.



subnet → which the network address served by DHCP server



range-dynamic bootip → what's the IP addresses range offered by DHCP + bootp.



filename "pxelinux.0" → indicates the pxe file needed to boot using PXE.



next server → the Kickstart server

6) Restart your dhcp service and you only must continue if everything seems ok: [root@redhat641 ~]# service dhcpd restart Shutting down dhcpd: Starting dhcpd:

[ OK ] [ OK ]

7) Execute the following commands: [root @redhat641 ~]# mkdir /var/lib/tftpboot/rhel64

8) You must copy necessaries files (vmlinuz and initrd.img) for a boot from any RHEL machine through PXE: root @redhat641 ~]# cp /var/www/html/software/images/pxeboot/vmlinuz /var/lib/tftpboot/rhel64 root @redhat641 ~]# cp /var/www/html/software/images/pxeboot/initrd.img /var/lib/tftpboot/rhel64

This example assumes the needed files are in /var/www/html/software/images/pxeboot/ because previous Kickstart configuration task from another article (tutorial RHEL – first part). If you want you can copy the same files from RHEL64 DVD.

9) Additionaly, we need to copy another file from another place: root @redhat641 ~] cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot

10) Create the file /var/lib/tftpboot/pxelinux.cfg/default (it has the bootloader menu) and insert the following lines into it: root @redhat641 ~] vi /var/lib/tftpboot/pxelinux.cfg/default timeout 50 default menu.c32 menu title ******** PXE Boot Menu ******** http://alexandreborges.org

Página 4

Red Hat Enterprise Linux 6.x – small tutorial - part 3

label 1 menu label ^ 1) RHEL6 kernel rhel64/vmlinuz append initrd=rhel64/initrd.img ks=http://192.168.1.150/software/kick.cfg ksdevice=eth0 11) Edit the httpd configuration file. insert the following lines at end of file and restart the httpd service:

[root@redhat641 ~]# vi /etc/httpd/conf/httpd.conf …................(end of file) Alias /software "/var/www/html/software" Options Indexes FollowSymLinks Order Deny,Allow Deny from all Allow from 127.0.0.1 192.168.1.0/24 [root@redhat641 ~]# service httpd restart Stopping httpd: Starting httpd:

[ OK ] [ OK ]

[root@redhat641 ~]# chkconfig httpd on [root@redhat641 ~]# chkconfig --list httpd httpd

0:off

1:off

2:on

3:on

4:on

5:on

6:off

12) Finally, you can configure iptables to allow TFTP protocol access (port 69) and HTTP protocol access (port 80): [root@redhat641 ~]# iptables -I INPUT -m state --state NEW -p udp --dport 69 -j ACCEPT [root@redhat641 ~]# iptables -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT [root@redhat641 ~]# /etc/init.d/iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

http://alexandreborges.org

Página 5

Red Hat Enterprise Linux 6.x – small tutorial - part 3

Wow !!! We've done !!! It would be nice if you could create a new virtual marchine (guest operating system being Red Hat Enterprise Linux 6 – 64 bits) on VMware (you may use VIrtualBox or a physical machine, whatever) and try to boot it using PXE. If you've done everything correctly, the RHEL 6.4 should go from beginning to end without any prompted question. For example, your first screen when you power the virtual machine on should be that:

I hope you have enjoyed. Have a nice day. :)

Alexandre Borges.

http://alexandreborges.org

Página 6