您的位置:首页 > 其它

半自动化安装系统(本地引导)

2017-09-28 09:39 204 查看

一、kickstart文件的制作方法1

使用system-config-kickstart制作kickstart

system-config-kickstart
#没有安装的话使用epel源yum安装
yum -y  install system-config-kickstart‘
#注意,system-config-kickstart必须在图形桌面环境运行




各项解释

Basic Configuration:指明各种安装前配置,如键盘类型等

1.语言
2.键盘类型
3.时区
4.将当前系统时间作为UTC时间
5.root用户密码
6.在kickstart中,root密码加密
7.体系结构
8.安装后是否重启
9.perform installation in text mode (graphical default)
在文本模式进行安装(图形默认)




Installation Method

1.安装方式’
安装一个新的
安装一个已经存在的
2.安装源




Boot Loader Options



Partition Information



Centos7 BUG在Package Selection选项



需要修改 /etc/yum.repos.d/base.repo
把[base] 改为[development]即可


二、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$gKnEUhgA$5EeYyX7tBEzS9QueZjlsj1
# Use network installation
url --url="http://172.17.0.1/centos/7"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx

# Network information
network  --bootproto=static --device=eth0 --gateway=172.17.0.1 --ip=172.17.0.200 --netmask=255.255.0.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=1024
part /home --fstype="ext4" --size=50000
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --size=50000

%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo  <<EOF
[development]
name=yum-base-centos-$releasever
baseurl=http://172.16.0.1/centos/$releasever/
gpgcheck=0
enabled = 1
[epel]
name=epel
baseurl=http://172.17.0.1/fedora-epel/$releasever/x86_64/
gpgcheck=0
enabled=1
EOF

useradd muzigan
echo muzigan |paswd --stdin  muzigan

mkdir /root/.ssh
cat > /root/.ssh/authorized_keys  <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRdZZhKgHvdIirAoE3l951Zsmds3pybWVDy3JU93J3HCm5/YX5O/K5cCxz1f/r5M7P7uqHUGk94YwkNg4h960Xy87WBYgHL0E6sr4RemT0OU8RhC+zdsEW3jbdaOaHkyfGbfmeIPaPYNl64/wJ5mU3pWzIuXB96MltPtb33l34OGTZJI0I4edV/QVfHw0R2O2Nez7FO14sf+URcLEVwws/9YehhZV2bNirXwSjefJqh9F7w1CHBjQuGgpX6585+YVjKgw8AkyadmhLxYx/eJJGjb5vEXBjL/Hw8Oqljjkn0k8lmyTbmDrdcf9AtyBNHKh8quNxtqtz+SGq142N4w0X root@localhost.localdomain
EOF
%end


kickstart文件格式

kickstart文件的格式
命令段:
指明各种安装前配置,如键盘类型等
命令段中的命令:
必备命令
authconfig: 认证方式配置
authconfig --useshadow --passalgo=sha512
bootloader:
bootloader的安装位置及相关配置
bootloader --location=mbr --driveorder=sda – append="crashkernel=auto rhgb quiet"
keyboard: 设定键盘类型
lang: 语言类型
part: 创建分区
rootpw: 指明root的密码
timezone: 时区
kickstart文件的格式
可选命令
install OR upgrade
text: 文本安装界面
network
firewall
selinux
halt
poweroff
reboot
repo
user:安装完成后为系统创建新用户
url: 指明安装源
key –skip 跳过安装序列号,适用于rhel版本
程序包段:
指明要安装的程序包组或程序包,不安装的程序包等
%packages
@group_name
package -package
%end
脚本段:
%pre: 安装前脚本
运行环境:运行于安装介质上的微型Linux环境
%post: 安装后脚本
运行环境:安装完成的系统


三、将kickstart文件放入ftp服务下

systemctl status vsftpd
cp ks.cfg  /var/ftp/pub/




四、使用kickstart文件安装一个新的系统

注意:需要从对应版本光盘引导

在引导界面

ESC
linux ks=ftp://172.17.0.117/pub/ks.cfg


注意:在centos7中安装过程中需要输入b;
才能 开始安装
但在centos6中不需要,只要在生成ks文件时不选择交互式安装的选项就好


五、成功

安装后的脚本测试



安装的新系统包太少,不支持yum源中的$releasever变量;所以应该改为对应版本号

sed -r "s/.* ([0-9]+)[.].*/\1/" /etc/redhat-release
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息