一、dhcp 的安装及其部署 1、检查是否安装dhcp服务软件,如果没有安装则进行安装。 [root@localhost ~]# rpm -qa |grep dhcp dhcp-4.1.1-38.P1.el6.centos.i686 dhcp-common-4.1.1-38.P1.el6.centos.i686 如果检查不到可以yum安装 [root@localhost ~]# yum install dhcp 2、使用dhcp服务获取TFTP IP 位置和boot loader 文件名称所在位置(关于dhcp服务器的配置没有详述) [root@localhost ~]# vim /etc/dhcp/dhcpd.conf ddns-update-style none; default-lease-time 259200; max-lease-time 518400; option routers 172.16.0.103; option broadcast-address 172.16.0.255; option domain-name-servers 202.96.64.68; subnet 172.16.0.0 netmask 255.255.255.0 { range 172.16.0.104 172.16.0.120; option subnet-mask 255.255.255.0; option domain-name "localhost.domain.com"; next-server 172.16.0.103; // 这里指定TFTP服务器所在的位置 filename "pxelinux.0"; //告知从TFTP根目录下载的boot loader 的文件名 } [root@localhost ~]# service dhcpd restart Shutting down dhcpd: [ OK ] Starting dhcpd: [ OK ] 3、查看服务是否启动 [root@localhost ~]# netstat -antulp |grep dhcp udp 0 0 0.0.0.0:67 0.0.0.0:* 2807/dhcpd 二、TFTP服务的安装及其部署 1、使用yum方式安装TFTP服务器 [root@localhost ~]# yum install tftp-server tftp 2、配置TFTP服务的配置文件 (TFTP使用的xinetd服务) [root@localhost ~]# vim /etc/xinetd.d/tftp service tftp { disable = no \\开启tftp服务 socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /install/tftpboot \\tftp的访问目录 per_source = 11 cps = 100 2 flags = IPv4 } 2、建立TFTP的访问目录和开启TFTP服务 [root@localhost ~]#mkdir -p /install/tftpboot [root@localhost ~]#/etc/init.d/xinetd restart [root@localhost ~]#chkconfig xinetd on [root@localhost ~]#chkconfig tftp on [root@localhost ~]#netstat -tulnp | grep xinetd udp 0 0 0.0.0.0:69 0.0.0.0:* 1682/xinetd 三、使用syslinux提供的boot loader与选择菜单相关的内容 [root@localhost ~]# yum install syslinux [root@localhost ~]# cp /usr/share/syslinux/menu.c32 /usr/share/syslinux/vesamenu.c32 \ > /usr/share/syslinux/pxelinux.0 /install/tftpboot/ [root@localhost ~]#mkdir /install/tftpboot/pxelinux.cfg 四、利用原版安装光盘取得linux安装软件的核心文件 [root@localhost ~]# mount -o loop /install/iso/CentOS-6.4-x86_64-bin-DVD1.iso /mnt [root@localhost ~]# mkdir -p /install/tftpboot/kernel/centos6.4 [root@localhost ~]# cp /mnt/isolinux/vmlinuz /install/tftpboot/kernel/centos6.4 [root@localhost ~]# cp /mnt/isolinux/initrd.img /install/tftpboot/kernel/centos6.4 [root@localhost ~]# cp /mnt/isolinux/isolinux.cfg /install/tftpboot/pxelinux.cfg/demo [root@localhost ~]# umount /mnt vmlinuz:就是安裝软件的核心档案(kernel file); initrd.img:就是开机过程所需要的核心模块参数; isolinux.cfg --> demo:作为未来PXE所需要的开关机选项参考。 设置开机选项: [root@localhost ~]#vim /install/tftpboot/pxelinux.cfg/default UI vesamenu.c32 TIMEOUT 300 DISPLAY ./boot.msg MENU TITLE Welcome to CHEN PXE Server System LABEL local MENU LABEL Boot from local drive MENU DEFAULT localboot 0 LABEL network1 MENU LABEL Boot from PXE Server for Install CentOS 6.4 kernel ../kernel/centos6.4/vmlinuz append initrd=../kernel/centos6.4/initrd.img [root@localhost ~]#vim /install/tftpboot/boot.msg Welcome to CHEN PXE Server System. The 1st menu can let you system goto hard disk menu. The 2nd menu can goto interactive installation step. 以上设置完毕后,配置要做系统的机器,设置其BIOS让其从网络中获取地址,然后会有如图的界面出现
已装机系统下的anaconda-ks.cfg文件自己修改成自己需要系统配置 [root@localhost ~]# vim anaconda-ks.cfg # Kickstart file automatically generated by anaconda. #version=DEVEL install cdrom lang en_US.UTF-8 keyboard us network --onboot no --device eth0 --bootproto static --ip 172.16.0.102 --netmask 255.255.255.0 --gateway 172.16.0.1 --noipv6 --nameserver 202.96.64.68 rootpw --iscrypted $6$UBwvO2.VsdtptQNx$bmRID5ChZqpVBFbUZVEEFkm3GbdXsVza1BDEHsSGuBm5PVqQ6B7sLvFaisnJRJkCrdJzn2PE/xCnDCfyN/DCg/ \\在这里修改网络访问方式 firewall --service=ssh authconfig --enableshadow --passalgo=sha512 selinux --enforcing timezone --utc Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work #clearpart --none \\在这里修改适合自己的磁盘分区(将#去掉) #part /boot --fstype=ext4 --size=1000 #part swap --size=2000 #part / --fstype=ext4 --grow --size=200 repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 %packages @base @core @debugging @basic-desktop @desktop-debugging @desktop-platform @directory-client @fonts @input-methods @internet-browser @java-platform @legacy-x @network-file-system-client @print-client @remote-desktop-clients @server-platform @server-policy @x11 pax oddjob sgpio mtools abrt-gui certmonger pam_krb5 krb5-workstation libXmu %end 修改完配置文件建立一个共享目录(可以使用FTP、NFS、HTTP等);本案例中使用NFS作为共享系统服务。 [root@localhost ~]# vim /etc/exports /var/nfs/kickstart/ *(rw,no_root_squash) \\存放有kickstart生成的ks.cfg配置文件 /var/nfs/linux/ *(rw,no_root_squash) \\原版的linux操作系统 [root@localhost ~]# /etc/init.d/rpcbind restart [root@localhost ~]# /etc/init.d/nfs restart
六、修改boot loader 选项菜单 [root@localhost ~]# vim /install/tftpboot/pxelinux.cfg/default UI vesamenu.c32 TIMEOUT 300 DISPLAY ../boot.msg MENU TITLE Welcome to CHEN PXE Server System LABEL local MENU LABEL Boot from local drive MENU DEFAULT localboot 0 LABEL network1 MENU LABEL Boot from Server for Install CentOS 6.4 kernel ../kernel/centos6.4/vmlinuz append initrd=../kernel/centos6.4/initrd.img //以下内容为新添加的内容 LABEL kickstart1 MENU LABEL Boot from PEX Server for AUTO Install CentOS 6.4 kernel ../kernel/centos6.4/vmlinuz append initrd=../kernel/centos6.4/initrd.img ks=nfs:172.16.0.103:/tmp/ks/ks.cfg
修改完成,在看一下引导菜单选如图:
先择红色的部分就会自动安装自己的系统了(如下图:)