DHCP+TFTP+PXE自动网络引导安装Linux操作系统


DHCP+TFTP+PXE自动网络引导Linux+NFS/FTP/HTTP Push多个Linux操作系统

原理:

1)客户端PXE网卡启动

2)从DHCP服务器获得IP

3)从TFTP服务器上下载pxelinux.0、default

4)根据配置文件default指定的vmlinuz、initrd.img启动系统内核,并下载指定的ks.cfg文件

5)跟据ks.cfg去(HTTP/FTP/NFS)服务器下载RPM包并安装系统

6)完成安装

·    DHCP:

  1. [root@rhel6 ~]# cat /etc/dhcp/dhcpd.conf
  2. ddns-update-style none;
  3. option routers 192.168.1.119;
  4. option subnet-mask 255.255.255.0;
  5. option domain-name "xfcy.org";
  6. option domain-name-servers 192.168.1.119;
  7. default-lease-time 21600;
  8. max-lease-time 43200;
  9. subnet 192.168.1.0 netmask 255.255.255.0 {
  10. range 192.168.1.101 192.168.1.200;
  11. # TFTP Server
  12. filename "pxelinux.0";
  13. next-server rhel6.xfcy.org;
  14. host vm.xfcy.org {
  15. hardware ethernet 00:0c:29:c0:a7:99;
  16. fixed-address 192.168.1.19;
  17. }
  18. }
  19. [root@rhel6 tftpboot]# /etc/init.d/dhcpd restart
  20. Shutting down dhcpd: [ OK ]
  21. Starting dhcpd: [ OK ]
  ·TFPT:
  1. [root@rhel6 ~]# rpm -qa | egrep 'tftp|xinetd'
  2. tftp-0.49-7.el6.x86_64
  3. xinetd-2.3.14-33.el6.x86_64
  4. tftp-server-0.49-7.el6.x86_64
  5. [root@rhel6 ~]# cat /etc/xinetd.d/tftp
  6. # default: off
  7. service tftp
  8. {
  9. socket_type = dgram
  10. protocol = udp
  11. wait = yes
  12. user = root
  13. server = /usr/sbin/in.tftpd
  14. server_args = -s /var/lib/tftpboot
  15. disable = no
  16. per_source = 11
  17. cps = 100 2
  18. flags = IPv4
  19. }
  20. [root@rhel6 ~]# chkconfig xinetd on
  21. [root@rhel6 ~]# /etc/init.d/xinetd restart
  22. Stopping xinetd: [ OK ]
  23. Starting xinetd: [ OK ]
  24. [root@rhel6 ~]# netstat -lnup | grep :69
  25. udp 0 0 0.0.0.0:69 0.0.0.0:* 2751/xinetd
  26. [root@rhel6 ~]# yum -y install syslinux
  27. [root@rhel6 ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg/
  28. [root@rhel6 ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
  29. [root@rhel6 ~]# cp /media/isolinux/initrd.img /var/lib/tftpboot/
  30. [root@rhel6 ~]# cp /media/isolinux/vmlinuz /var/lib/tftpboot/
  31. [root@rhel6 ~]# cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  32. [root@rhel6 ~]# ls -R /var/lib/tftpboot/
  33. /var/lib/tftpboot/:
  34. boot.msg initrd.img pxelinux.0 pxelinux.cfg vmlinuz
  35. /var/lib/tftpboot/pxelinux.cfg:
  36. default
  37. [root@rhel6 ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
  38. default rhel6_nfs
  39. prompt 1 #显示"boot: " 提示进行选择以下lable
  40. timeout 100 #10s 的超时后进入default所定义的lable
  41. display boot.msg #以boot.msg进行文本提示(与以下的*.msg文件结合,非必选项)
  42. F1 boot.msg
  43. F2 options.msg
  44. F3 general.msg
  45. F4 param.msg
  46. F5 rescue.msg
  47. #可通过以下3种方式下载ks.cfg文件,通过default定义lable或在timeout时间之内选择lable即可
  48. label rhel6_nfs #通过NFS方式
  49. kernel vmlinuz
  50. append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=nfs:192.168.1.119:/var/ftp/pub/ks.cfg
  51. label rhel6_ftp #通过FTP方式
  52. kernel vmlinuz
  53. append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=ftp://192.168.1.119/pub/ks.cfg
  54. label rhel6_http #通过HTTP方式
  55. kernel vmlinuz
  56. append ksdevice=eth0 load_ramdisk=1 initrd=initrd.img network ks=http://192.168.1.119/pub/ks.cfg
  57. label rescue #用于rescue模式
  58. kernel vmlinuz
  59. append load_ramdisk=1 initrd=initrd.img rescue

  • 1
  • 2
  • 下一页

相关内容