CentOS7 /root下系统自生成的anaconda-ks.cfg文件(Kickstart file)

本文提供了一份详细的CentOS 7.4自动安装Kickstart配置文件,包括系统授权信息、安装类型、网络配置、分区设置、服务及时间配置等关键步骤。

一、Centos7.4自动生成的完整Kickstart file文件

[root@localhost ~]# vim anaconda-ks.cfg 
#version=DEVEL
# System authorization information
auth --useshadow --enablemd5
# Install OS instead of upgrade
install
# Use network installation
url --url="http://172.16.70.110/cblr/links/CentOS-7.4-x86_64"
# Use text mode install
text
# Firewall configuration
firewall --enabled
firstboot --disable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network  --bootproto=dhcp --device=eth0 --activate
network  --hostname=localhost.localdomain
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$cobbler$sqDDOBeLKJVmxTCZr52/11
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# X Window System configuration information
xconfig  --startxonboot
# 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 /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --size=282495

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1
# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &
curl "http://172.16.70.110/cblr/svc/op/trig/mode/pre/profile/CentOS-7.4-x86_64" -o /dev/null
# Enable installation monitoring
%end
%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1
%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
curl "http://172.16.70.110/cblr/svc/op/yum/profile/CentOS-7.4-x86_64" --output /etc/yum.repos.d/cobbler-config.repo
# End yum configuration
# Start post_install_network_config generated code
# End post_install_network_config generated code

# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)
# Start koan environment setup
echo "export COBBLER_SERVER=172.16.70.110" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 172.16.70.110" > /etc/profile.d/cobbler.csh
# End koan environment setup
# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration
# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings
# End cobbler registration
# Enable post-install boot notification
# Start final steps
curl "http://172.16.70.110/cblr/svc/op/ks/profile/CentOS-7.4-x86_64" -o /root/cobbler.ks
curl "http://172.16.70.110/cblr/svc/op/trig/mode/post/profile/CentOS-7.4-x86_64" -o /dev/null
# End final steps
%end
%packages
@base
@compat-libraries
@debugging
@development
chrony
gcc
gcc-c++
glibc
kexec-tools
lrzsz
nmap
openssh
openssl-devel
sysstat
tree
vim
%end

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

将部分IP等参数更换一下,即可使用。
<think>好的,我需要回答用户关于original-ks.cfganaconda-ks.cfg文件的区别、功能和使用场景的问题。首先,我要回忆一下这两个文件CentOS或RHEL系统中的作用。 根据用户提供的引用内容,特别是引用[3],anaconda-ks.cfg安装过程中自动生成Kickstart文件,记录安装时的配置选项,比如分区、网络设置、root密码等。这个文件通常位于/root目录下,用户安装系统后可以使用它来复制相同的安装配置。而用户提到的original-ks.cfg可能是在某些特定情况下由用户手动创建或重命名的Kickstart文件。比如,用户可能在自动化安装前自己编写了一个原始的Kickstart模板,并保存为original-ks.cfg,用于定制安装过程。 接下来,需要确认这两个文件的功能区别。anaconda-ks.cfg是自动生成的,作为系统安装的应答文件,而original-ks.cfg可能是用户自定义的原始模板,可能在自动化部署时使用。使用场景方面,anaconda-ks.cfg适用于快速复制现有系统安装配置,而original-ks.cfg可能用于初次配置或作为模板供后续修改。 需要验证是否有官方文档或社区资料支持这些区别。根据引用[3]中的描述,anaconda-ks.cfg确实是由Anaconda安装程序生成的,包含安装时的具体参数。而original-ks.cfg可能不是标准文件名,可能是用户自定义的。因此,在回答中需要指出这一点,并说明用户可能根据需求自定义Kickstart文件。 最后,生成相关问题时要围绕Kickstart文件的作用、如何创建自定义文件以及自动化安装的最佳实践来提问。确保问题覆盖用户可能感兴趣的扩展内容。</think>### original-ks.cfganaconda-ks.cfg 的区别 #### 1. **来源与生成方式** - **anaconda-ks.cfg** 由CentOS/RHEL系统安装程序(Anaconda)自动生成,记录当前系统安装配置参数(如分区方案、软件包选择、网络设置等)[^3]。 - 文件路径:`/root/anaconda-ks.cfg` - 功能:用于复现当前系统安装过程。 - **original-ks.cfg** 通常是用户手动创建或重命名的自定义Kickstart文件,可能是系统初始安装前的模板文件- 文件路径:无固定位置,需用户指定 - 功能:作为自动化安装的配置模板,支持灵活定制。 #### 2. **内容差异** - **anaconda-ks.cfg** 包含实际安装过程中使用的参数,例如: ```plaintext zerombr clearpart --all part /boot --size=500 rootpw --plaintext mypassword timezone Asia/Shanghai ``` 可能包含敏感信息(如明文密码)。 - **original-ks.cfg** 内容更偏向模板化,例如占位符或通用配置: ```plaintext rootpw --iscrypted $6$加密字符串 network --device=eth0 --bootproto=dhcp %packages @^minimal %end ``` #### 3. **使用场景** - **anaconda-ks.cfg** - 克隆现有系统安装配置 - 快速重建相同环境(如测试服务器)[^1] - **original-ks.cfg** - 自动化批量部署新系统 - 定制特殊需求(如预装软件、安全加固) --- ### 功能对比表 | 特性 | anaconda-ks.cfg | original-ks.cfg | |--------------------|--------------------------------|-----------------------------| | **生成方式** | 自动生成Anaconda安装程序) | 手动创建或模板修改 | | **用途** | 复现当前系统安装 | 定义新系统安装模板 | | **敏感信息** | 可能包含明文密码 | 通常使用加密参数 | | **路径** | `/root/` 目录 | 用户自定义路径 | --- ### 操作示例 **查看anaconda-ks.cfg内容**: ```bash cat /root/anaconda-ks.cfg ``` **使用Kickstart文件自动化安装**: ```bash # 在安装启动命令中指定文件 linux ks=hd:sda1:/original-ks.cfg ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值