目录(?)[+]

KickStart无人值守安装的原理:

1. DHCP服务器给需要安装的机器分发IP, 并指定ftp服务器地址和pxelinux.0

[html] view plain copy
  1. subnet 192.168.0.0  netmask 255.255.255.0 {
      range 192.168.0.200 192.168.0.220;
      option routers 192.168.0.1;
      option domain-name-servers 8.8.8.8;
      next-server   192.168.0.1;
    #指定TFTP服务器的地址
      filename      "pxelinux.0";
    #引导程序的文件

2. 客户端连接到服务器,读取启动文件 /tftpboot/pxelinux.cfg/default

3. 根据default里面指定的ks.cfg文件的位置,打开KickStart配置文件,

4. 根据ks.cfg的ftp服务器的配置, 读取/var/ftp/pub/文件, 引导安装程序

1. 查看服务状态, 启动服务

1.1 查看三种服务的状态,是否为启动状态
[html] view plain copy
  1. systemctl status vsftpd  
  2. systemctl statusxinetd 
  3. systemctl status dhcpd  
1.2 如果没有默认启动,可以设置为默认启动.
[html] view plain copy
  1. systemctl restart dhcpd  
  2. systemctl restart xinetd 
  3. systemctl restart vsftpd 
1.3 dhcp服务配置
rpm -ql dhcp | more
vim /etc/dhcp/dhcpd.conf

[[email protected] pub]# cat /etc/dhcp/dhcpd.conf
[html] view plain copy
  1. ddns-update-style interim;  
  2. ignore client-updates;  
  3. allow booting;  
  4. allow bootp;  
  5. subnet 192.168.0.0 netmask 255.255.255.0 {  
  6.         option routers                  192.168.0.1;  
  7.         option subnet-mask              255.255.255.0;  
  8.         option domain-name-servers      192.168.0.1;  
  9.         option time-offset              -18000; # Eastern Standard Time  
  10.         range dynamic-bootp 192.168.0.100 192.168.0.200;  
  11.         default-lease-time 21600;  
  12.         max-lease-time 43200;  
  13.         next-server 192.168.0.1;  
  14.         filename "pxelinux.0";  
  15. }  
1.4 tftp服务配置

yum install -y tftp
tftp服务是xinetd的子服务.

[[email protected] ftp]# cat /etc/xinetd.d/tftp 

[html] view plain copy
  1. # default: off  
  2. # description: The tftp server serves files using the trivial file transfer \  
  3. #   protocol.  The tftp protocol is often used to boot diskless \  
  4. #   workstations, download configuration files to network-aware printers, \  
  5. #   and to start the installation process for some operating systems.  
  6. service tftp  
  7. {  
  8.     socket_type     = dgram  
  9.     protocol        = udp  
  10.     wait            = yes  
  11.     user            = root  
  12.     server          = /usr/sbin/in.tftpd  
  13.     server_args     = -s /tftpboot  
  14.     disable         = no    #此处yes修改no 开户tftp服务
  15.     per_source      = 11  
  16.     cps         = 100 2  
  17.     flags           = IPv4  
  18. }  

2. 创建pxe启动所需要的文件和目录

[html] view plain copy
  1. mkdir /tftpboot  
  2. mkdir /tftpboot/pxelinux.cfg  
  3. cp /usr/share/syslinux/pxelinux.0 /tftpboot/  
挂载安装光盘的镜像,并拷贝以下文件:
[html] view plain copy
  1. cp /mnt/iso/isolinux/isolinux.cfg      /tftpboot/pxelinux.cfg/default  
  2. cp /mnt/iso/images/pxeboot/initrd.img  /tftpboot/  
  3. cp /mnt/iso/images/pxeboot/vmlinuz     /tftpboot/  

3. 修改/tftpboot/pxelinux.cfg/default文件

vim /tftpboot/pxelinux.cfg/default
[[email protected] pxelinux.cfg]# cat default 
[html] view plain copy
  1. default linux  
  2. prompt 1  
  3. timeout 60  
  4. display boot.msg  
  5. label linux  
  6.   kernel vmlinuz  
  7.   append initrd=initrd.img text ks=ftp://192.168.0.1/ks.cfg  #此处inst.stage2=XXX  可以不写
ks.cfg 是使用kickstart程序生成的文件.后面我们会使用KickStart生成它.

4. 使用kickstart程序生成ks.cfg安装配置文件

安装kickstart:
yum list *kic*
yum install system-config-kickstart.noarch
运行system-config-kickstart,进行图形化参数配置界面:

4.1.基本配置:
Centos7.2 kickstart批量装机
4.2 安装方法
Centos7.2 kickstart批量装机

4.3.创建新的分区:

Centos7.2 kickstart批量装机

4.4.网络配置:

Centos7.2 kickstart批量装机

4.5.剩下的项目是关于防火墙,selinux的,看个人需求选择.

最后保存配置文件:

Centos7.2 kickstart批量装机

5. 修改生成的ks.cfg文件

5.1 将%packages后面的全拷贝到ks.cfg中的%packages后面去
cat /root/anaconda-ks.cfg #系统的安装信息
[html] view plain copy
  1. %packages  
  2. @base  
  3. @chinese-support  
  4. @core  
  5. @debugging  
  6. @basic-desktop  
  7. @desktop-debugging  
  8. @desktop-platform  
  9. @directory-client  
  10. @fonts  
  11. @general-desktop  
  12. @graphical-admin-tools  
  13. @input-methods  
  14. @internet-applications  
  15. @internet-browser  
  16. @java-platform  
  17. @legacy-x  
  18. @network-file-system-client  
  19. @office-suite  
  20. @print-client  
  21. @remote-desktop-clients  
  22. @server-platform  
  23. @server-policy  
  24. @x11  
  25. mtools  
  26. pax  
  27. oddjob  
  28. wodim  
  29. sgpio  
  30. genisoimage  
  31. device-mapper-persistent-data  
  32. abrt-gui  
  33. samba-winbind  
  34. certmonger  
  35. pam_krb5  
  36. krb5-workstation  
  37. gnome-pilot  
  38. libXmu  
5.2 添加key --skip //跳过输入***环节
<注意是两个"-">
[[email protected] ~]# cat ks.cfg
[[email protected] tftpboot]# cat /var/ftp/ks.cfg 
[[email protected] ftp]# cat ks.cfg 
[html] view plain copy
  1. #platform=x86, AMD64, or Intel EM64T  
  2. #version=DEVEL  
  3. # Firewall configuration  
  4. firewall --disabled  
  5. # Install OS instead of upgrade  
  6. install  
  7. # Use network installation  
  8. #url --url=<a target="_blank" href="ftp://192.168.0.1/pub">ftp://192.168.0.1/pub</a>   此处例子是这样的
  9. url --url=ftp://192.168.0.1/pub   #我是这样的
  10. # Root password  
  11. rootpw --iscrypted $1$YfhInJ/9$hqyxxL34AduJm0Zzfcl/F1  
  12. # System authorization information  
  13. auth  --passalgo=sha512  
  14. # Use graphical install  
  15. graphical  
  16. firstboot --disable  
  17. # System keyboard  
  18. keyboard us  
  19. # System language  
  20. lang en_US  
  21. # SELinux configuration  
  22. selinux --disabled  
  23. # Installation logging level  
  24. logging --level=info  
  25.   
  26.   
  27. key --skip  
  28.   
  29.   
  30. # System timezone  
  31. timezone  Asia/Shanghai  
  32. # Network information  
  33. network  --bootproto=dhcp --device=eth0 --onboot=on  
  34. # System bootloader configuration  
  35. bootloader --location=mbr  
  36. # Clear the Master Boot Record  
  37. zerombr  
  38. # Partition clearing information  
  39. clearpart --all --initlabel   
  40. # Disk partitioning information  
  41. part /boot --fstype="ext4" --size=200  
  42. part swap --fstype="swap" --size=4096  
  43. part / --fstype="ext4" --grow --size=1  
  44.   
  45.   
  46. %packages  
  47. @base  
  48. @chinese-support  
  49. @core  
  50. @debugging  
  51. @basic-desktop  
  52. @desktop-debugging  
  53. @desktop-platform  
  54. @directory-client  
  55. @fonts  
  56. @general-desktop  
  57. @graphical-admin-tools  
  58. @input-methods  
  59. @internet-applications  
  60. @internet-browser  
  61. @java-platform  
  62. @legacy-x  
  63. @network-file-system-client  
  64. @office-suite  
  65. @print-client  
  66. @remote-desktop-clients  
  67. @server-platform  
  68. @server-policy  
  69. @x11  
  70. mtools  
  71. pax  
  72. oddjob  
  73. wodim  
  74. sgpio  
  75. genisoimage  
  76. device-mapper-persistent-data  
  77. abrt-gui  
  78. samba-winbind  
  79. certmonger  
  80. pam_krb5  
  81. krb5-workstation  
  82. gnome-pilot  
  83. libXmu  
  84.   
  85.   
  86. %end  
5.3 将配置文件拷贝到ftp目录下
[html] view plain copy
  1. cp ks.cfg /var/ftp/  

6. 将系统相关文件拷贝到配置ks.cfg时,指定的ftp目录下

挂载系统镜文件到/vat/ftp/pub/下
[[email protected] ~]# ls -l /var/ftp/
[html] view plain copy
  1. total 8  
  2. -rw-r--r-- 1 root root 1419 Nov 20 17:58 ks.cfg  
  3. dr-xr-xr-x 7 root root 4096 Mar  6  2013 pub  

[[email protected] ~]# ls -l /var/ftp/pub/
[html] view plain copy
  1. total 676  
  2. -r--r--r-- 2 root root     14 Mar  6  2013 CentOS_BuildTag  
  3. dr-xr-xr-x 3 root root   2048 Mar  5  2013 EFI  
  4. -r--r--r-- 2 root root    212 Mar  3  2013 EULA  
  5. -r--r--r-- 2 root root  18009 Mar  3  2013 GPL  
  6. dr-xr-xr-x 3 root root   2048 Mar  5  2013 images  
  7. dr-xr-xr-x 2 root root   2048 Mar  5  2013 isolinux  
  8. dr-xr-xr-x 2 root root 649216 Mar  6  2013 Packages  
  9. -r--r--r-- 2 root root   1354 Mar  3  2013 RELEASE-NOTES-en-US.html  
  10. dr-xr-xr-x 2 root root   4096 Mar  6  2013 repodata  
  11. -r--r--r-- 2 root root   1706 Mar  3  2013 RPM-GPG-KEY-CentOS-6  
  12. -r--r--r-- 2 root root   1730 Mar  3  2013 RPM-GPG-KEY-CentOS-Debug-6  
  13. -r--r--r-- 2 root root   1730 Mar  3  2013 RPM-GPG-KEY-CentOS-Security-6  
  14. -r--r--r-- 2 root root   1734 Mar  3  2013 RPM-GPG-KEY-CentOS-Testing-6  
  15. -r--r--r-- 1 root root   3380 Mar  6  2013 TRANS.TBL  

到此配置结束, 启动需要安装系统的机器. 修改BIOS以网卡方式启动. 

如果DHCP配置有问题,或PXE找不到安装文件的问题,
请查看/var/log/message 或仔细核对目录是否一致.

#注意如果KickStarts配置在虚拟机中,
虚拟机的网卡要设置为桥接(Bridged)模式.

转自:http://blog.csdn.net/robertkun/article/details/16851109

相关文章: