自动安装的应答文件

制作引导光盘和U盘

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

kickstart文件创建

创建kickstart文件的方式

  • 可使用创建工具:system-config-kickstart ,注意:此方法 CentOS 8 不再支持
  • 依据某模板修改并生成新配置,CentOS安装完后,会自动参考当前系统的安装过程,生成一个kickstart文件 /root/anaconda-ks.cfg

检查ks文件的语法错误

使用 ksvalidator 工具可以检查kickstart的文件格式是否有语法错误,来自于 pykickstart 包

格式:

ksvalidator /PATH/TO/KICKSTART_FILE

范例:使用system-config-kickstart一边来看看生成的kickstart配置文件,我们一页一页观察

1. Basic Configuration

在这里插入图片描述

配置文件如下

┌────────────────────────────────────────────────────────┐
│#Basic Configuration                         
│========================================================
│#platform=x86, AMD64, or Intel EM64T                    
│#Default Language默认语言                                 
│lang en_US                                               
│# Keyboard 键盘
│keyboard 'us'
│# timezone 时区(勾选了"Use UTC clock" 会追加[--isUtc])
│timezone Asia/Shanghai 
│# Root password
│rootpw --iscrypted $1$DBk7xfJp$Agxd303XUAfRKIf7gB8DG/
└──────────────────────────────────────────────────────────┘

┌────────────────────────────────────────────────────────┐
│#Advanced Configuration       
│勾选就有,不勾没有
│========================================================
│# Reboot after installation
│reboot
│# Use text mode install
│text
└────────────────────────────────────────────────────────┘

2. Installation Method

在这里插入图片描述

配置文件如下

┌────────────────────────────────────────────────────────┐
│#Installation Method                   
│========================================================
│# Install OS instead of upgrade
│install
│# Upgrade existing installation
│upgrade
└────────────────────────────────────────────────────────┘

┌────────────────────────────────────────────────────────┐
│#Installation source     
│选了哪项就写哪项
│========================================================
│# Use CDROM installation media
│cdrom
│# Use NFS installation media
│nfs --server=服务器 --dir=目录
│# Use network installation
│url --url="ftp://用户名:密码@服务器/目录"
│# Use network installation
│url --url="http://服务器/目录"
│# Use hard drive installation media
│harddrive --dir=目录 --partition=分区
└────────────────────────────────────────────────────────┘

3. Boot Loader Options

在这里插入图片描述

配置文件如下

┌────────────────────────────────────────────────────────────────┐
│#Installation Method&GRUB options&Install Options
│=================================================================
│ ┌────────────────────────────────────┐
│ │ 选择了Do not install a boot loader  │
│ └────────────────────────────────────┘
│ # System bootloader configuration
│ bootloader --location=none
│
│ ┌────────────────────────────────────┐
│ │   选择了install new boot loader     │
│ └────────────────────────────────────┘
│ bootloader --append="ker" --location=mbr --password="123"
│#append是内核参数,location是bootloader安装位置,password是GRUB密码
└────────────────────────────────────────────────────────────────┘

4. Partition Information

在这里插入图片描述

配置文件如下

┌─────────────────────────────────────────────────────┐
│# Master Boot Record  
│#Master Boot Record选择了clear... 否则就没有               
│======================================================
│# Clear the Master Boot Record
│zerombr
└─────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────┐
│# Partitions&Disk Label            
│======================================================
│# Partition clearing information
│clearpart --linux --initlabel
└─────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────┐
│# Layout  分区
│part  挂载点   --fstype=文件系统  --size=大小(单位M)         
│======================================================
│# Disk partitioning information
│part / --fstype="xfs" --size=10240
│part /boot --fstype="ext4" --size=1024
│part swap --fstype="swap" --size=2048
└─────────────────────────────────────────────────────┘

5. Network Configuration

在这里插入图片描述

配置文件如下

┌─────────────────────────────────────────────────────┐
│# Network Configuration
│Centos7如果要写eth0,要加内核参数net.ifnames=0
│======================================================
│# Network information
│network  --bootproto=dhcp --device=eth0
└─────────────────────────────────────────────────────┘

6. Authentication

在这里插入图片描述

配置文件如下

┌───────────────────────────────────────────────────────────────┐
│# Authentication
│如果勾选Enable Fingerprint reader则追加参数 --enablefingerprint
│===============================================================
│# System authorization information
│auth  --useshadow  --passalgo=md5
└───────────────────────────────────────────────────────────────┘

7. Firewall Configuration

在这里插入图片描述

配置文件如下

┌───────────────────────────────────────────────────────────────┐
│# Firewall Configuration
│===============================================================
│# SELinux configuration
│selinux  --disabled或permissive或enforcing
│
│# Firewall configuration
│firewall  --disabled或enabled
│#如果是enable,可以在追加:--http --ftp --telnet --smtp --ssh
│#还可以追加端口:--port=555:tcp,444:udp
└───────────────────────────────────────────────────────────────┘

8. Display Configuration

在这里插入图片描述

配置文件如下

┌───────────────────────────────────────────────────────────────┐
│# Display Configuration
│===============================================================
│如果选了安装图形界面,就没有下面这句话
│# Do not configure the X Window System
│skipx  
│# Run the Setup Agent on first boot
│firstboot --enable或disable
└───────────────────────────────────────────────────────────────┘

9. Package Selection

在这里插入图片描述

如果你的界面是什么都没有,那么需要把你现使用的yum仓库配置文件改一下

[root]#vim /etc/yum.repos.d/***.repo
[development]
#把原来"[]"内的内容改成development就可以了,其它不变

配置文件如下

%packages
@development
-byacc
-cscope
-ctags
-diffstat
-doxygen
-elfutils
-gcc-gfortran
-git
-indent
-intltool
-patchutils
-rcs
-subversion
-swig
-systemtap
%end

10. Pre-Installation Script

在这里插入图片描述

配置文件如下

%pre
i am pre 
%end

11. Post-Installation Script

在这里插入图片描述

配置文件如下

%post --nochroot
i am post
%end

12 以上system-config-kickstart 执行后最终生成的kickstart文件如下

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$2TeoFGRN$EeykyMirEiMIya57QmbG71
# Use network installation
url --url="http://192.168.100.7/Centos/7/os/x86_64"
# System language
lang zh_CN
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx

# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=2048
part / --fstype="xfs" --size=10240
part swap --fstype="swap" --size=2048

%pre
i am pre
%end

%post --nochroot
i am post
%end

%packages
@development
-byacc
-cscope
-ctags
-diffstat
-doxygen
-elfutils
-gcc-gfortran
-git
-indent
-intltool
-patchutils
-rcs
-subversion
-swig
-systemtap
%end

本文链接:https://www.yunweipai.com/36130.html

自动安装的应答文件

制作引导光盘和U盘

网友评论comments

发表回复

您的电子邮箱地址不会被公开。

暂无评论

Copyright © 2012-2022 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部