1亭枷、kickstart 文件詳解
anaconda程序安裝系統(tǒng)支持交互式和配置文件方式安裝拢驾;
系統(tǒng)安裝后哼蛆,在/root下就會自動生成其安裝過程中的配置文件anaconda-ks.cfg ,即kickstart文件;
kickstart文件由三段組成:命令段(%packages前的)脆丁、程序包段(%packages開始,%end結(jié)束)动雹、腳本段(%pre槽卫,安裝前腳本 ;%post 胰蝠,安裝后腳本)歼培;具體內(nèi)容如下:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install? ? ? ? ? ? ? ? ?##安裝系統(tǒng)
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'? ##鍵盤類型
# Root password
rootpw --iscrypted $1$3Lr0AjZk$cgK7DTSfd3wiwirdTkjcI1? ? ##設(shè)置root密碼
# Use network installation
url --url="http://mirrors.aliyun.com/centos/7/os/x86_64/"? ? ?##安裝鏡像路徑,此處使用阿里云
# System language
lang en_US? ? ? ? ? ? ?##設(shè)置系統(tǒng)語言
# System authorization information
auth? --useshadow? --passalgo=sha512? ? ##用戶登錄認(rèn)證方式
# Use graphical install
graphical? ? ##設(shè)置使用圖形安裝方式
firstboot --disable? ?##設(shè)置當(dāng)系統(tǒng)啟動時Setup Agent 是否安裝茸塞;默認(rèn)disable
# SELinux configuration
selinux --disabled? ? ? ##設(shè)置默認(rèn)關(guān)閉selinux
# System services
services --disabled="chronyd"? ? ? ##不啟用chronyd服務(wù)躲庄,chronyd是centos7代替ntp服務(wù)的
ignoredisk --only-use=sda? ? ?##當(dāng)有多塊磁盤時,指定安裝使用的磁盤钾虐,其他都忽略?
# Firewall configuration
firewall --disabled? ? ##不起用防火墻
# Network information
network? --bootproto=dhcp --device=ens33? ? ?##配置網(wǎng)卡及獲取IP地址的協(xié)議
# Halt after installation
halt
# System timezone
timezone Asia/Shanghai --nontp? ? ? ??
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda? ? ##設(shè)置bootloader選項
# Clear the Master Boot Record
zerombr? ? ##If zerombr is specified any invalid partition tables found on disks are initialized. This destroys all of the contents of disks with invalid partition tables.
# Partition clearing information
clearpart --all --initlabel? ? ?##Removes partitions from the system, prior to creation of new partitions. By default, no partitions are removed
# Disk partitioning information
part / --fstype="xfs" --size=10240
part /boot --fstype="xfs" --size=500
%packages? ? ? ?##設(shè)置需要安裝的程序包
@^minimal
@core
kexec-tools
net-tools
vim
%end
參考:https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-options.html
2噪窘、圖形界面配置并生成kickstart文件
windows物理機安裝:
xshell
xmanager
linux虛擬機安裝:
>>>yum group install "X Window System" -y
>>>yum install "system-config-kickstart" -y
(vm workstation中的)linux虛擬機運行:
>>>system-config-kickstart? &
會彈出以下界面:
打開anaconda文件進行編輯,
設(shè)置安裝鏡像地址:https://mirrors.aliyun.com/centos/7/os/x86_64/
安裝新boot loader :
創(chuàng)建分區(qū):
設(shè)置網(wǎng)卡名稱及IP地址獲取方式:
用戶登錄認(rèn)證方式:
關(guān)閉防火墻和selinux
安裝圖形界面及是否安裝Setup Agent:
設(shè)置完畢后,另存為/root/ks.cfg?
cat??/root/ks.cfg?
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
# Root password
rootpw --iscrypted $1$3Lr0AjZk$cgK7DTSfd3wiwirdTkjcI1
# Use network installation
url --url="http://mirrors.aliyun.com/centos/7/os/x86_64/"
# System language
lang en_US
# System authorization information
auth? --useshadow? --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# System services
services --disabled="chronyd"
ignoredisk --only-use=sda
# Firewall configuration
firewall --disabled
# Network information
network? --bootproto=dhcp --device=ens33
# Halt after installation
halt
# System timezone
timezone Asia/Shanghai --nontp
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="xfs" --size=10240
part /boot --fstype="xfs" --size=500
%packages
@^minimal
@core
kexec-tools
net-tools
vim
%end
將以上ks.cfg 放入httpd 服務(wù)器的/var/www/html 下效扫,則訪問地址為:http://192.168.0.140/ks.cfg 倔监;
新建虛擬機,插入光盤菌仁,開啟電源浩习,Tab 鍵進入安裝設(shè)置界面,并輸入:
ip=192.168.0.150 netmask=255.255.255.0 gateway=192.168.0.1 ks=http://192.168.0.140/ks.cfg?
然后繼續(xù)啟動機器济丘,就可以自動安裝系統(tǒng)了谱秽。。摹迷。疟赊。。?