1、在生产环境中,经常要安装不同版本的 linux 操作系统,以及各种安装需求;每次安装操作系统的时候如果用传统的光盘方式安装,费时又费力!下面介绍下如何在同一个时刻,使用 kickstart push 不同的版本的 linux,主要有三个版本 centos4.8,rhel5.4,rhel6.0 和一个 linux rescue 环境!一:配置 dhcp 服务,ks 服务器地址为 192.168.50.7/241. rootrhel5 # rpm -qa |grep dhcp 2. dhcpv6-client-1.0.10-17.el5 3. dhcp-3.0.5-23.el5_5.2 4. 5.
2、 rootrhel5 # cat /etc/dhcpd.conf 6. option domain-name ““; 7. default-lease-time 6000; 8. max-lease-time 11400; 9. authourtative; 10. next-server 192.168.50.7; 11. ddns-update-style ad-hoc; 12. log-facility local7; 13. subnet 192.168.50.0 netmask 255.255.255.0 14. range 192.168.50.150 192.168.50.195
3、; 15. option domain-name-servers 192.168.50.254; 16. option domain-name ““; 17. option netbios-name-servers 192.168.50.254; 18. option routers 192.168.50.254; 19. option broadcast-address 192.168.50.255; 20. default-lease-time 6000; 21. max-lease-time 11400; 22. filename “/kickstart/ks.cfg“; 23. 24.
4、 25. option space PXE; 26. 27. class “PXE“ 28. match if substring(option vendor-class-identifier, 0, 9) = “PXEClient“; 29. option vendor-encapsulated-options 01:04:00:00:00:00:ff; 30. option boot-size 0x1; 31. filename “pxelinux.0“; 32. option tftp-server-name “192.168.50.7“; 33. option vendor-class
5、-identifier “PXEClient“; 34. vendor-option-space PXE; 35. 二:配置 tftp-server,准备 vmlinz 和 initrd.img 文件1. rootrhel5 # rpm -qa |egrep tftp|xinetd 2. tftp-0.49-2.el5.centos 3. tftp-server-0.49-2.el5.centos 4. xinetd-2.3.14-10.el5 5. 6. rootrhel5 # cat /etc/xinetd.d/tftp 7. # default: off 8. # description
6、: The tftp server serves files using the trivial file transfer 9. # protocol. The tftp protocol is often used to boot diskless 10. # workstations, download configuration files to network-aware printers, 11. # and to start the installation process for some operating systems. 12. service tftp 13. 14.
7、socket_type = dgram 15. protocol = udp 16. wait = yes 17. user = root 18. server = /usr/sbin/in.tftpd 19. server_args = -s /tftpboot 20. disable = no 21. per_source = 11 22. cps = 100 2 23. flags = IPv4 24. 25. 26. 这些文件可以在对应的系统光盘或者 ISO 文件下的 isolinux 目录下找到 27. rootrhel5 # ls /tftpboot/rhel5.4_64/ 28.
8、 initrd.img vmlinuz 29. rootrhel5 # ls /tftpboot/rhel6_64/ 30. initrd.img vmlinuz 31. rootrhel5 # ls /tftpboot/centos4.8_64/ 32. initrd.img vmlinuz 三:配置相关文件复制 pxelinux.0 文件至/tftpboot 目录下,该文件由 syslinux 软件包提供,用来 pxe 启动 linux 使用rootrhel5 # rpm -qf /usr/lib/syslinux/pxelinux.0 syslinux-3.11-4复制 rhel5 光盘
9、下的 isolinux 目录下的文件至/tftpboot 目录下,其中 vmlinuz 和 initrd.img 文件可以不用复制,在/tftpboot 目录下创建一个名为 pxelinux.cfg 的目录,并将/tftpboot 目录下的 isolinux.cfg 文件移到到该目录,重命名为 default;KS 文件可以在安装好的 linux 上使用system-config-kickstart 命令生成1. rootrhel5 # ls /tftpboot/ 2. boot.cat centos4.8_64 isolinux.bin memtest param.msg pxelinux.
10、cfg rhel5.4_64 splash.lss 3. boot.msg general.msg isolinux.cfg options.msg pxelinux.0 rescue.msg rhel6_64 TRANS.TBL 4. 5. rootrhel5 # cat /tftpboot/pxelinux.cfg/default 6. default rhel5_rescue 7. prompt 1 8. timeout 600 9. display boot.msg 10. F1 boot.msg 11. F2 options.msg 12. F3 general.msg 13. F4
11、 param.msg 14. F5 rescue.msg 15. 16. label rhel5_rescue 17. kernel rhel5.4_64/vmlinuz 18. append ksdevice=eth0 load_ramdisk=1 initrd=rhel5.4_64/initrd.img noipv6 19. 20. 21. label rhel5.4_64 22. kernel rhel5.4_64/vmlinuz 23. append ksdevice=eth0 load_ramdisk=1 initrd=rhel5.4_64/initrd.img ks=ftp:/19
12、2.168.50.7/ks/ks5_64.cfg noipv6 24. 25. label rhel6_64 26. kernel rhel6_64/vmlinuz 27. append ksdevice=eth0 load_ramdisk=1 initrd=rhel6_64/initrd.img ks=ftp:/192.168.50.7/ks/ks6_64.cfg noipv6 28. 29. 30. label centos4.8_64 31. kernel centos4.8_64/vmlinuz 32. append ksdevice=eth0 load_ramdisk=1 initr
13、d=centos4.8_64/initrd.img ks=ftp:/192.168.50.7/ks/ks4.8_64.cfg noipv6 33. 34. rootrhel5 # cat /tftpboot/boot.msg 35. #To decide install os type and enter command to continue 36. 37. linux resuce - rhel5_rescue rescue 38. 39. rhel5.4 64bit - rhel5.4_64 40. 41. rhel6.0 64bit - rhel6_64 42. 43. centos4
14、.8 64bit - centos4.8_64 四:配置 FTP 和 autofs,这里将利用 ftp 和 autofs 为安装提供光盘源镜像1. rootrhel5 # rpm -qa |egrep vsftpd|autofs 2. vsftpd-2.0.5-16.el5_5.1 3. autofs-5.0.1-0.rc2.131.el5 4. 5. rootrhel5 # tail -1 /etc/auto.master 6. /var/ftp/pub /etc/auto.ftp 7. rootrhel5 # cat /etc/auto.ftp 8. iso5 -fstype=iso966
15、0,ro,loop :/data/ISO/rhel-server-5.4-x86_64-dvd.iso 9. iso4.8 -fstype=iso9660,ro,loop :/data/ISO/CentOS-4.8-x86_64-binDVD.iso 10. iso6 -fstype=iso9660,ro,loop :/data/ISO/rhel6.iso 五:启动服务和测试 1. rootrhel5 # service dhcpd restart 2. Shutting down dhcpd: OK 3. Starting dhcpd: OK 4. 5. rootrhel5 # servic
16、e vsftpd restart 6. Shutting down vsftpd: OK 7. Starting vsftpd for vsftpd: OK 8. 9. rootrhel5 # service autofs restart 10. Stopping automount: OK 11. Starting automount: OK 12. 13. rootrhel5 # service xinetd restart 14. Stopping xinetd: OK 15. Starting xinetd: OK 16. 17. rootrhel5 # tail -f /var/lo
17、g/messages 18. Jun 13 17:40:42 rhel5 dhcpd: DHCPDISCOVER from 00:0c:29:4c:0f:d5 via br0 19. Jun 13 17:40:43 rhel5 dhcpd: DHCPOFFER on 192.168.50.184 to 00:0c:29:4c:0f:d5 via br0 20. Jun 13 17:40:44 rhel5 dhcpd: DHCPREQUEST for 192.168.50.184 (192.168.50.7) from 00:0c:29:4c:0f:d5 via br0 21. Jun 13 1
18、7:40:44 rhel5 dhcpd: DHCPACK on 192.168.50.184 to 00:0c:29:4c:0f:d5 via br0 22. Jun 13 17:40:44 rhel5 xinetd1794: START: tftp pid=2829 from=192.168.50.184 23. 24. rootrhel5 # tail -f /var/log/xferlog 25. Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES-en_US.UTF-8.html b _ o a ano
19、nymous ftp 0 * i 26. Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES.en_US.UTF-8 b _ o a anonymous ftp 0 * i 27. Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES-en_US.html b _ o a anonymous ftp 0 * i 28. Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RE
20、LEASE-NOTES.en_US b _ o a anonymous ftp 0 * i 29. Mon Jun 13 08:46:26 2011 1 192.168.50.184 80344 /pub/iso5/RELEASE-NOTES-en.html b _ o a anonymous ftp 0 * c 30. Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/images/updates.img b _ o a rhinstall ftp 0 * i 31. Mon Jun 13 08:49:48 2011 1 192.16
21、8.50.184 0 /pub/iso5/disc1/images/updates.img b _ o a rhinstall ftp 0 * i 32. Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/images/product.img b _ o a rhinstall ftp 0 * i 33. Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/disc1/images/product.img b _ o a rhinstall ftp 0 * i 34. Mon Jun 13 08:49:56 2011 8 192.168.50.184 91160576 /pub/iso5/images/stage2.img b _ o a rhinstall ftp 0 * c