DHCP+TFTP+PXE自動網路引導安裝Linux作業系統

來源:互聯網
上載者:User

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
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.