KickStart安装系统Rhel7

1.系统环境:
服务端:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
客户端:
另外新建一个虚拟机,操作系统为linux,内存至少为1G,借助服务端配置为其安装rhel7系统

  • 用到的几个软件
    tftp => udp寻址、传输小文件(ks.cfg等)
    http => 发送文件
    dhcp => 分配ip地址

2.先关闭防火墙、selinux,安装相关软件

[root@localhost /]# systemctl stop firewalld
[root@localhost /]# setenforce 0
[root@localhost /]# yum install dhcp tftp-server httpd syslinux 
                                system-config-kickstart
  • dhcp
[root@localhost /]# vim /etc/dhcp/dhcpd.conf
\# cat /usr/share/doc/dhcp*/dhcpd.conf.example
subnet 192.168.137.0 netmask 255.255.255.0 {
  range 192.168.137.30 192.168.137.60;
  option domain-name-servers 192.168.137.1;
  option domain-name "912616.com";
  option routers 192.168.137.1;
  option broadcast-address 192.168.137.255;
  default-lease-time 3600;
  max-lease-time 7200;
  next-server 192.168.137.6; 
  filename "/pxelinux.0";
}
[root@localhost /]# systemctl restart dhcpd
[root@localhost ~]# touch /var/lib/dhcpd/dhcpd.leases #如果有相关报错,再执行这一步
[root@localhost dhcpd]# netstat -antulp | grep dhcpd
udp        0      0 0.0.0.0:67              0.0.0.0:*           3432/dhcpd          
udp        0      0 0.0.0.0:36194           0.0.0.0:*         3432/dhcpd          
udp6       0      0 :::7055                 :::*                   3432/dhcpd     
  • tftp
[root@localhost ~]# yum -y install xinetd
[root@localhost ~]# vim /etc/xinetd.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot #默认共享目录
        disable                 = no #默认yes
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
[root@localhost ~]# systemctl start xinetd
[root@localhost ~]# netstat -antulp | grep :69
udp        0      0 0.0.0.0:69              0.0.0.0:*      18427/xinetd 
[root@localhost ~]# mkdir  /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
把iso镜像文件挂载到本机/mnt目录
[root@localhost ~]# cp -r /mnt/isolinux/* /var/lib/tftpboot/
[root@localhost ~]# cp -r /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]# ll /var/lib/tftpboot/ -h
total 72M
-r--r--r--. 1 root root 2.0K Mar  5 18:32 boot.cat
-r--r--r--. 1 root root   84 Mar  5 18:32 boot.msg
-r--r--r--. 1 root root  321 Mar  5 18:32 grub.conf
-r--r--r--. 1 root root  34M Mar  5 18:32 initrd.img
-r--r--r--. 1 root root  24K Mar  5 18:32 isolinux.bin
-r--r--r--. 1 root root 3.1K Mar  5 18:32 isolinux.cfg
-r--r--r--. 1 root root 173K Mar  5 18:32 memtest
-rw-r--r--. 1 root root  27K Mar  5 18:24 pxelinux.0
drwxr-xr-x. 2 root root   21 Mar  5 18:36 pxelinux.cfg
-r--r--r--. 1 root root  186 Mar  5 18:32 splash.png
-r--r--r--. 1 root root 2.4K Mar  5 18:32 TRANS.TBL
-r--r--r--. 1 root root  33M Mar  5 18:32 upgrade.img
-r--r--r--. 1 root root 153K Mar  5 18:32 vesamenu.c32
-r-xr-xr-x. 1 root root 4.7M Mar  5 18:32 vmlinuz
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default 
default linux # 将vesamenu.c32改为linux
timeout 600
..................
label linux
  menu label ^Install Red Hat Enterprise Linux 7.0
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.137.8/ks.cfg 
                inst.repo=http://192.168.137.8/cdrom quiet
.........................

3.ks.cfg 文件

1).可以参考/root/anaconda-ks.cfg
2).也可以手动配置

[root@localhost ~]# system-config-kickstart #打开图形界面

KickStart安装系统Rhel7_第1张图片
kick1.jpg
KickStart安装系统Rhel7_第2张图片
kick2.jpg
KickStart安装系统Rhel7_第3张图片
kick3.jpg
KickStart安装系统Rhel7_第4张图片
kick4.jpg
KickStart安装系统Rhel7_第5张图片
kick4-1boot.jpg
KickStart安装系统Rhel7_第6张图片
kick4-2root.jpg
KickStart安装系统Rhel7_第7张图片
kick4-3.jpg
KickStart安装系统Rhel7_第8张图片
kick5.jpg
KickStart安装系统Rhel7_第9张图片
kick6.jpg
KickStart安装系统Rhel7_第10张图片
kick7.jpg
KickStart安装系统Rhel7_第11张图片
kick8.jpg
KickStart安装系统Rhel7_第12张图片
kick9.jpg
KickStart安装系统Rhel7_第13张图片
kick10.jpg
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim /root/anaconda-ks.cfg
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
kexec-tools
%end
[root@localhost html]# vim ks.cfg
# 将上文packages安装包部分 加到%post之前
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
kexec-tools
%end

%post
useradd mycmss
echo mycms5 | passwd --stdin mycms5
%end
[root@localhost html]# mkdir cdrom
[root@localhost html]# mount /dev/cdrom /var/www/html/cdrom
mount: /dev/sr0 is write-protected, mounting read-only

开启客户端虚拟机电源,等候系统安装完成。

你可能感兴趣的:(KickStart安装系统Rhel7)