通过kickstart自动安装系统

安装前准备:一定要配置好网络安装服务器
1.yum install httpd
2.关闭SElinux,关闭防火墙
setenforce 0
service iptables stop ; service iptables off
3.启动服务service httpd start ;service httpd status
4.在/var/www/html目录下创建文件夹
mkdir -p /var/www/html/centos/{6,7}
mkdir /var/www/html/ksdir
5.分别把centos6.9,centos7.4的光盘挂载到 /var/www/html/centos/6, /var/www/html/centos/7上
mount /dev/sr0 /var/www/html/centos/6
mount /dev/sr1 /var/www/html/centos/7
6.打开浏览输入路径能访问到如下页面则说明成功
在这里插入图片描述
在这里插入图片描述

1、准备kickstart文件,可以根据anaconda-ks.cfg文件进行修改,也可使用创建工具:system-config-kickstart生成新的配置。(不过centos7上使用该工具时得修改一下yum源中base源的名字,改为development,否则安装包无法显示,同时也要注意kickstart文件属性,通过浏览器能打开,建议改为644)

centos6的kickstart文件:

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.239.129/centos/6"
# Root password
rootpw --plaintext 123456
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=static --device=eth0 --gateway=192.168.239.1 --ip=192.168.239.131 --netmask=255.255.255.0 --onboot=on
# System bootloader configuration
bootloader --append="selinux=0" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --size=500
part / --fstype="ext4" --size=20000
part swap --fstype="swap" --size=2048

%post
mkdir /etc/yum.repos.d/yum.bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/yum.bak
cat >/etc/yum.repos.d/base.repo<<EOF
[base]
name=base
baseurl=http://192.168.239.129/centos/6
gpgcheck=0
EOF

useradd cwj
echo 123456 | passwd --stdin cwj
%end

%packages
@core
@server-policy
@workstation-policy

%end

centos7的kickstart文件:

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url="http://192.168.239.129/centos/7"
# Use graphical install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
reboot
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate
network  --hostname=centos7.cwj.com

# Root password
rootpw --iscrypted $6$Gc0Xp64gwbnbXaz/$oto/r0KN.uARfEvqsKu3Vax0NAGZGISe.fugaFHGtsqt5RQsLTWA/vYf/ANUbKm6zwJ3/8GYWVYTq9WPmbPhz1
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=cwj --password=$6$q2Mexpvnzn0BJzu8$a3iWuNCurYMqPpmfU5aXYsTVso98J2asMdZJe9Pks6iKn0nV9NfLfMVpUYd8HaAOtE7OAf8W7re8Ebr2aXGNh0 --iscrypted --gecos="cwj"
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
#autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel
zerombr
#Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part / --fstype="xfs" --ondisk=sda --size=51200
part /data --fstype="xfs" --ondisk=sda --size=30000
part swap --fstype="swap" --ondisk=sda --size=2048

%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@internet-browser
@multimedia
@x11
kexec-tools

%end

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

%end

%post
mkdir /etc/yum.repos.d/yum.bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/yum.bak
cat >/etc/yum.repos.d/base.repo<<EOF
[base]
name=base
baseurl=http://192.168.239.129/centos/7
gpgcheck=0
EOF

useradd cwj
echo 123456 | passwd --stdin cwj
%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

2、在安装界面下按ESC键,然后在boot:下输入linux ks=http://192.168.239.129/ksidr/ks7_desktop.cfg指定kickstart的路径,接着即可根据ks文件的配置自动完成安装。(这里启动引导还是通过本地光盘引导,所以本地光盘还得准备)

在这里插入图片描述
在这里插入图片描述

3、下面几张图是安装过程,采用的是文本方式安装。

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值