CentOS8手动编辑定制生成应答文件anaconda-ks.cfg

Posted 白-胖-子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS8手动编辑定制生成应答文件anaconda-ks.cfg相关的知识,希望对你有一定的参考价值。

CentOS8应答文件

记录了安装系统时的操作
可以用此为基础创建自定义应答文件

kickstart文件主要包括三个部分:

命令段,程序包段,脚本段

手动编辑定制生成应答文件

  • CentOS6和7中的图形化工具在CentOS8中没有了
  • 只能通过手动编辑并定制生成应答文件

拷贝系统中原生anaconda-ks.cfg

cp anaconda-ks.cfg ks8.cfg

编辑ks8.cfg应答文件

#version=RHEL8
ignoredisk --only-use=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
# Use graphical install
graphical
# Use CDROM installation media
cdrom
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network  --hostname=localhost.localdomain
repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Root password
rootpw --iscrypted $6$0oNcn58oJTkyswqj$ZSA1obbRFFvijoTaiY.GJsBz1CBhIOWt7eEIC7jdZTUZbifpJnR1f8ekUJwc4RTVi/XY5xX/YmkcfFEllTWCZ.
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd"
# System timezone
timezone America/New_York --isUtc

%packages
@^server-product-environment
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

修改需要的项

#version=RHEL8
#ignoredisk --only-use=sda ## 分区信息改喽
ignoredisk --only-use=sda
zerombr
#autopart --type=lvm 
#autopart --type=lvm
#part / --fstype xfs --size 1 --grow --ondisk sda 可以实现根自动使用所有剩余空间
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024
# Partition clearing information
clearpart --none --initlabel
# Use graphical install
## graphical ## 图形化安装改喽
# Use text mode install
text
# Setup Firewall
selinux --disabled
firewall --disabled

# Use CDROM installation media ## 安装介质改喽
## cdrom
# Use network installation
url --url="http://10.0.0.88/centos/8/os/x86_64/"
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information ## 网卡名改喽
network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network  --hostname=localhost.localdomain
## repo位置改喽
# repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
repo --name="AppStream" --baseurl=http://10.0.0.88/centos/8/os/x86_64/AppStream/
# Root password ## 密码改喽
## rootpw --iscrypted ## $6$0oNcn58oJTkyswqj$ZSA1obbRFFvijoTaiY.GJsBz1CBhIOWt7eEIC7jdZTUZbifpJnR1f8ekUJwc4RTVi/XY5xX/YmkcfFEllTWCZ.
rootpw --iscrypted $1$Zmb3GPCH$gNU/fyVaRKbqZeFATib3k/
# Run the Setup Agent on first boot
firstboot --enable
# Setup Booterloader
bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda
# Do not configure the X Window System
skipx
# System services ## 系统服务改喽
## services --enabled="chronyd"
services --disabled="chronyd"
# System timezone
timezone America/New_York --isUtc

%packages
## @^server-product-environment ## 安装包先择,改喽
## kexec-tools
@^minimal-environment
kexec-tools
%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
yum -y install curl
curl 10.0.0.88/shell/newSet.sh | bash
curl 10.0.0.88/shell/sshpass.sh | bash
%end

汇总归一

ignoredisk --only-use=sda
zerombr
text
reboot
clearpart --all --initlabel
selinux --disabled
firewall --disabled
url --url=http://10.0.0.88/centos/8/os/x86_64/
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network --hostname=server8.timonium.co
bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda

rootpw --iscrypted $1$Zmb3GPCH$gNU/fyVaRKbqZeFATib3k/
firstboot --enable
skipx
services --disabled="chronyd"
timezone Asia/Shanghai --isUtc --nontp
#autopart --type=lvm
#part / --fstype xfs --size 1 --grow --ondisk sda 可以实现根自动使用所有剩余空间
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024
%packages
@^minimal-environment
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
%post
yum -y install curl
curl 10.0.0.88/shell/newSet.sh | bash
curl 10.0.0.88/shell/sshpass.sh | bash
%end

创建ks8.cfg在HTTP服务器目录下

cat > /var/www/html/ks/ks8.cfg <<EOF
> ignoredisk --only-use=sda
> zerombr
> text
> reboot
> clearpart --all --initlabel
> selinux --disabled
> firewall --disabled
> url --url=http://10.0.0.88/centos/8/os/x86_64/
> keyboard --vckeymap=us --xlayouts='us'
> lang en_US.UTF-8
> network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
> network --hostname=server8.timonium.co
> bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda
> 
> rootpw --iscrypted $1$Zmb3GPCH$gNU/fyVaRKbqZeFATib3k/
> firstboot --enable
> skipx
> services --disabled="chronyd"
> timezone Asia/Shanghai --isUtc --nontp
> #autopart --type=lvm
> #part / --fstype xfs --size 1 --grow --ondisk sda 可以实现根自动使用所有剩余空间
> part / --fstype="xfs" --ondisk=sda --size=102400
> part /data --fstype="xfs" --ondisk=sda --size=51200
> part swap --fstype="swap" --ondisk=sda --size=2048
> part /boot --fstype="ext4" --ondisk=sda --size=1024
> %packages
> @^minimal-environment
> kexec-tools
> %end
> %addon com_redhat_kdump --enable --reserve-mb='auto'
> %end
> %anaconda
> pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
> pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
> pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
> %end
> %post --nochroot
yum -y install curl
curl 10.0.0.88/shell/newSet.sh | bash
curl 10.0.0.88/shell/sshpass.sh | bash
%end
> EOF

以上是关于CentOS8手动编辑定制生成应答文件anaconda-ks.cfg的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7使用图形工具定制生成应答文件anaconda-ks.cfg

CentOS8原始应答文件anaconda-ks.cfg内容

手动配置yum源文件(CentOS8)

笔记 10月29,30

如何搭建一个本地centos8源(以minimal镜像为例)

MySQL在CentOS8纯手动安装 8.0.20版本