Linux kickstart自動安裝腳本

  • rhel7中:
  1. yum install system-config-kickstart(rhel8中目前還沒有)
  • 每個系統的家目錄裏面都有一個文件anaconda-ks.cfg用於自動安裝。可以在rhel7中利用圖形工具自動生成這些腳本。

在這裏插入圖片描述

  1. system-config-kickstart 圖形制作ks文件的工具
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述
  • 其他選項默認即可
  • 設置完之後一定要左上角save,自己任意選個路徑保存,會生成一個ks.cfg文件
    在這裏插入圖片描述
  1. vim ks.cfg
%packages
@base ##軟件組
lftp ##軟件包
%end
  • 輸入的時候漏掉了%end,可以通過 ksvalidator ks.cfg檢測文件語法
    在這裏插入圖片描述
    在這裏插入圖片描述
  1. ksvalidator /mnt/ks.cfg (檢測文件語法)
  2. 發佈ks文件
yum install vsftpd -y
systemctl start vsftpd 
systemctl stop firewalld 
mkdir /var/ftp/ksfile
mv ks.cfg /var/ftp/ksfile 
##將ks文件移動到ksfile目錄下
  1. 檢測發佈
  • firefox ftp://192.168.0.10/ksfile/ks.cfg
    在這裏插入圖片描述
  1. 使用
  • 在安裝界面按

  • 輸入:ks=ftp://192.168.0.10/ksfile/ks.cfg

  • 回車

  • 進入到自動安裝過程

  • 在這裏插入圖片描述

  • 注意:使用kickstart安裝系統時環境中必須有dhcp服務器否則網絡資源訪問不到

  • 如何配置dhcp

  • 安裝服務 yum install dhcp.x86_64 -y

  • cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf複製模版

  • vim /etc/dhcp/dhcpd.conf開始編輯配置文件

  1 # dhcpd.conf
  2 #
  3 # Sample configuration file for ISC dhcpd
  4 #
  5 
  6 # option definitions common to all supported networks...
  7 option domain-name "example.com";
  8 option domain-name-servers 114.114.114.114;
  9 
 10 default-lease-time 600;
 11 max-lease-time 7200;
 12 
 13 # Use this to enble / disable dynamic dns updates globally.
 14 #ddns-update-style none;
 15 
 16 # If this DHCP server is the official DHCP server for the local
 17 # network, the authoritative directive should be uncommented.
 18 #authoritative;
 19 
 20 # Use this to send dhcp log messages to a different log file (you also
 21 # have to hack syslog.conf to complete the redirection).
 22 log-facility local7;
 23 
 24 # No service will be given on this subnet, but declaring it helps the 
 25 # DHCP server to understand the network topology.
 26 
 27 
 28 
 29 # This is a very basic subnet declaration.
 30 
 31 subnet 192.168.1.0 netmask 255.255.255.0 {
 32   range 192.168.1.40 192.168.1.88;
 33   option routers 192.168.1.1;
 34 }

在這裏插入圖片描述

  • systemctl restart dhcpd重啓服務
  • systemctl status dhcpd查看服務狀態

在這裏插入圖片描述

  1. 使用網絡資源安裝系統
  • 通過ftp服務發佈景象資源到網絡
  • 訪問網絡鏡像資源ftp://192.168.1.16/rhel8.0
  • 更改ks.cfg
  • vim ks.cfg
  • #cdrom ##註釋使用光盤資源
  • url --url=“ftp://192.168.1.10/rhel8.0” ##使用網絡資源
    在這裏插入圖片描述
  • 在rhel8主機中:
dnf install vsftpd -y
systemctl start vsftpd 
systemctl stop firewalld 
  • vim /etc/vsftpd/vsftpd.conf 更改配置文件,因爲rhel8中默認拒絕匿名用戶訪問,將NO改爲YES
    在這裏插入圖片描述
  • mkdir /var/ftp/rhel8.0
  • mount /dev/cdrom /var/ftp/rhel8.0將鏡像掛載到此目錄中
  • 注意:如果實驗的時候ftp://192.168.1.10無法訪問的話,看一下本機的firewalld和selinux是否開啓,把他們關掉
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章