How to set up PXE/kickstart server for automated OS installations under RedHat/CentOS/Oracle Linux 6.x.
This turned out to be a quite long and scary manual... but believe me, it only sounds harder than the actual deal is. Should take about an hour for experienced admins, and may longer for other people, depending on their skills.
You need 3 service components - DHCP/bootpc server (dynamic IP allocations), TFTP server (PXE boot environment), HTTP server (OS repository). In addition, you will need installation Kickstart scripts.
1) DHCP/bootpc server
To install dhcpd on Linux via YUM use the following command:
# yum install -y dhcp
DHCP configuration should point to your TFTP server, containing PXE boot environment, which can be on the same server as DHCP or the other server. Here is my example of /etc/dhcpd.conf:
allow booting;
allow bootp;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.1.2; # IP address of your TFTP server, described in #2 below
filename "pxelinux.0";
}
default-lease-time 600;
max-lease-time 7200;
ddns-update-style ad-hoc;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
option domain-name "mynetwork.com";
option subnet-mask 255.255.255.0;
range 192.168.1.200 192.168.1.254;
}
After you save the config, start dhcpd daemon:
# service dhcpd start
References:
2) TFTP server (handled by xinetd TCP wrapper)
To install it via YUM use the following command:
# yum install -y tftp-server xinetd
In "/etc/xinetd.d/tftp" file change "disable = yes" with "disable = no", then (re)start xinetd server:
# service xinetd restart
PXE OS boot files to be installed to /tftpboot folder. For the initial boot you need 3 PXELinux loader files. They can be obtained from "syslinux" package, a latest version of which you can find at http://www.kernel.org/
/tftpboot/pxelinux.0
/tftpboot/menu.c32
/tftpboot/pxelinux.cfg/default
This is the example of my /tftpboot/pxelinux.cfg/default file, where I have few OS systems to choose my installation from:
DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
ONTIMEOUT local
MENU TITLE PXE Installation Menu
LABEL local
MENU LABEL Boot local hard drive
LOCALBOOT 0
MENU DEFAULT
LABEL CentOS 6.5
MENU LABEL CentOS 6.5
KERNEL menu.c32
APPEND pxelinux.cfg/CentOS6.5.cfg
LABEL CentOS 6.4
MENU LABEL CentOS 6.4
KERNEL menu.c32
APPEND pxelinux.cfg/CentOS6.4.cfg
LABEL CentOS 6.3
MENU LABEL CentOS 6.3
KERNEL menu.c32
APPEND pxelinux.cfg/CentOS6.3.cfg
Each of the configuration files mentioned above contains OS-specific installation instructions. For instance, this is a part of my "/tftpboot/pxelinux.cfg/CentOS6.5.cfg" file:
MENU TITLE PXE Installation for CentOS 6.5
LABEL Main Menu
MENU LABEL Main Menu
KERNEL menu.c32
APPEND pxelinux.cfg/default
LABEL CentOS 6.5 x64 (eth0, no kickstart)
MENU LABEL CentOS 6.5 x64 (eth0, no KS)
KERNEL CentOS-6.5/vmlinuz
APPEND initrd=CentOS-6.5/initrd.img ramdisk_size=100000 ip=dhcp url --url=http://repository_server/CentOS/6.5/os/x86_64
LABEL CentOS 6.5 x64 (eth0, RAID, KS)
MENU LABEL CentOS 6.5 x64 (eth0, KS)
KERNEL CentOS-6.5/vmlinuz
APPEND initrd=CentOS-6.5/initrd.img ramdisk_size=100000 ip=dhcp url --url=http://repository_server/CentOS/6.5/os/x86_64 ksdevice=bootif ks=http://repository_server/CentOS-6.5.cfg mpath
[...]
* Note "url" and "ks" parameters above - they point to our local repository server, described in #3.
Under /tftpboot/CentOS*/ folders, referred in the config above, I have OS-specific boot files, obtained from "isolinux" folder of OS-specific installation media (they can also be downloaded from one of the OS repository websites).
# ls -1 /tftpboot/CentOS-6.5/
boot.cat
boot.msg
general.msg
initrd.img
isolinux.bin
isolinux.cfg
memtest
options.msg
param.msg
rescue.msg
splash.lss
TRANS.TBL
vmlinuz
#
References:
- http://www.mythtv.org/wiki/Minimyth_Howto
3) HTTP OS repository server.
You need to install Apache httpd server, start it and copy the OS repository to its DocumentRoot folder. Depending on default settings, you may need to modify httpd.conf and set "Options +Indexes" to allow file listings.
# yum install httpd
# vi /etc/httpd/conf/httpd.conf
# service httpd start
# mount /dev/cdrom /mnt
# mkdir -p /var/www/html/CentOS/6.5/os/x86_64
# rsync -av /mnt/os /var/www/html/CentOS/6.5/
You repository server should be accessible via http://repository_server/CentOS/6.5/os link from your browser, and you should see the list of files.
References:
- http://www.how2centos.com/creating-a-local-yum-repository-on-centos-5x/
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_Yum_and_Yum_Repositories.html
- http://mirror.centos.org/
- http://public-yum.oracle.com/
4) Kickstart environment.
A very first installation you will have to perform manually, in non-automated manner (re: "no KS" line above). During this installaton, the installation program will create a script /root/anakonda-ks.cfg, which you can use later for automated installations.
All you need to do is to rename it, modify as necessary, save it to your HTTP repository server and make sure it's accessible (Re: "http://repository_server/CentOS-6.5.cfg" in the example above).
5) Your overall installation procedure will look like:
- You boot your new server from the network via PXE (choosing corresponding option from the BIOS).
- Your server obtains DHCP address and boot parameters (TFTP server address and PXELinux filename) from your DHCP server
- Your server loads pxelinux.0 file from your TFTP server, runs it, reads menu.c32 and default configuration file, containing the menu
- You choose an installation option from the menu
- Server loads the kernel (vmlinuz/initrd/etc. files) from TFTP server, passes specified kernel parameters and then performs installation, according to your specific kickstart script, and using your HTTP OS repository server to load necessary packages
References:
- http://fedoraproject.org/wiki/Anaconda/Kickstart
- http://www.oracle-base.com/articles/linux/kickstart.php
All of these certainly gives you an advantage, when you have to install a number of similar servers in your network (I'd say, makes sense for more than 3).
Comments: none (click here to reply) Tags: How-to | Linux | Работа
|