[关闭]
@mrz1 2018-01-13T19:03:50.000000Z 字数 3408 阅读 730

PXE自动化安装CentOS 6实验

自动化


安装前准备:关闭防火墙和SELINUX,DHCP服务器静态IP

  1. 安装相应软件包
  2. 1.yum install dhcp httpd tftp-server syslinux
  3. 2.chkconfig httpd on
  4. chkconfig dhcpd on
  5. chkconfig tftp on (因为tftpxinetd管理所以xinetd也许启动)
  6. chkconfig xinetd on 或者修改/etc/xinetd.d/tftp文件中disable=no
  7. 3.[root@centos7 ~]#vim /etc/dhcp/dhcpd.conf //编写这个文件
  8. option domain-name "zhangqifei.com";
  9. option domain-name-servers 114.114.114.114,8.8.8.8; //DNS解析
  10. option routers 192.168.109.1;//全局默认网关
  11. default-lease-time 84600; //有效期
  12. max-lease-time 84600; //特殊要求最大有效期
  13. log-facility local7;
  14. subnet 192.168.109.0 netmask 255.255.255.0 { //网段
  15. range 192.168.109.100 192.168.109.200; //分配ip范围 如果这里写网关,就是这些范围ip,外面的网关是全局的这里不设置网关会是全局网关
  16. filename "pxelinux.0";/文件名网络中启动程序的文件名
  17. next-server "192.168.109.143";(tftp)//程序的文件名地址
  18. }
  19. 例也可以这样:
  20. host fantasia { //绑定mac地址,分配默认ip
  21. hardware ethernet 08:00:07:26:c0:a5;
  22. fixed-address 192.168.109.101;
  23. 这里网关和DNS都可以单独设置
  24. }
  25. 4.service dhcpd restart (启动dhcp服务)
  26. 5.service httpd restart (启动httpd服务)
  27. 6.mkdir -p centos/6;mkdir ksdir
  28. 7.cp /root/anaconda-ks.cfg /var/www/html/ksdir/ks6-pxe.cfg
  29. 8.[root@centos7 ksdir]#cat ks6-pxe.cfg (编辑这个脚本)
  30. # Kickstart file automatically generated by anaconda.
  31. #version=DEVEL
  32. install
  33. reboot
  34. text
  35. url --url=http://192.168.109.143/centos/6(url这里我们用光盘看9)
  36. lang en_US.UTF-8
  37. keyboard us
  38. network --onboot yes --device eth0 --bootproto dhcp --noipv6
  39. rootpw --iscrypted $6$6YyIa0te.We2OG1r$W8zGexnUlYhMlStMTMYVJ7QAQIuFpqJp655PUU6xGnpC7FhFXUoZ2pB77H7wQSdT5ci3yiJ0vxilWzcxGst00.
  40. firewall --disabled
  41. authconfig --enableshadow --passalgo=sha512
  42. selinux --disabled
  43. timezone Asia/Shanghai
  44. bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
  45. # The following is the partition information you requested
  46. # Note that any partitions you deleted are not expressed
  47. # here so unless you clear all partitions first, this is
  48. # not guaranteed to work
  49. clearpart --all
  50. zerombr
  51. part /boot --fstype=ext4 --size=1024
  52. part / --fstype=ext4 --size=50000
  53. part /app --fstype=ext4 --size=20000
  54. part swap --size=2048
  55. %packages
  56. @base
  57. @core
  58. @debugging
  59. @basic-desktop
  60. @desktop-debugging
  61. @desktop-platform
  62. @directory-client
  63. @fonts
  64. @general-desktop
  65. @graphical-admin-tools
  66. @input-methods
  67. @internet-applications
  68. @internet-browser
  69. @legacy-x
  70. @network-file-system-client
  71. @x11
  72. %end
  73. 9.[root@centos7 ksdir]#cat /etc/fstab (把下面添加进去并且挂载maunt -a
  74. /dev/sr0 /var/www/html/centos/6 iso9660 defaults 0 0
  75. 10.注意ks6-pxe.cfg权限644
  76. /var/lib/tftpboot/(tftp客户端连接的目录默认是这个目录下)
  77. 1.yum install syslinux(安装这个包)
  78. 2.cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
  79. cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
  80. mkdir /var/lib/tftpboot/pxelinux.cfg/
  81. cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  82. cp /misc/cd/isolinux/{vesamenu.c32,boot.msg,splash.jpg} /var/lib/tftpboot/
  83. 3.[root@centos7 ~]#Vim /var/lib/tftpboot/pxelinux.cfg/default(默认菜单)
  84. default vesamenu.c32
  85. timeout 60
  86. display boot.msg
  87. menu background splash.jpg
  88. menu title Welcome to CentOS 6!
  89. menu color border 0 #ffffffff #00000000
  90. menu color sel 7 #ffffffff #ff000000
  91. menu color title 0 #ffffffff #00000000
  92. menu color tabmsg 0 #ffffffff #00000000
  93. menu color unsel 0 #ffffffff #00000000
  94. menu color hotsel 0 #ff000000 #ffffffff
  95. menu color hotkey 7 #ffffffff #ff000000
  96. menu color scrollbar 0 #ffffffff #00000000
  97. menu title PXE INSTALL CentOS 6
  98. label desktop
  99. menu label ^Install desktop CentOS 7
  100. kernel vmlinuz
  101. append initrd=initrd.img ks=http://192.168.109.143/ksdir/ks6-pxe.cfg
  102. label mini
  103. menu label install ^Mini CentOS 6
  104. kernel vmlinuz
  105. append initrd=initrd.img ks=http://192.168.109.143/ksdir/ks6-mini.cfg
  106. label local
  107. menu default
  108. menu label Boot from ^local drive
  109. localboot 0xffff
  110. menu end
  111. [root@centos7 tftpboot]#tree
  112. .
  113. ├── boot.msg
  114. ├── splash.jpg
  115. ├── initrd.img
  116. ├── pxelinux.0
  117. ├── vesamenu.c32
  118. ├── pxelinux.cfg
  119. └── default
  120. └── vmlinuz
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注