1. 概念:
自动安装的脚本,这篇文章以RHEL6.8为例
kickstart for RHEL6.8官方教程:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Migration_Planning_Guide/sect-Migration_Guide-Installation-Graphical_Installer-Kickstart.html
1.1 安装程序:anaconda,有tui(基于cureses的文本配置窗口)和gui(图形界面)两种
1.2 启动顺序:bootloader --> kernel(initrd(rootfs)) --> anaconda
MBR:boot.cat
||
V
Stage2:执行isolinux/isolinux.bin
读取配置文件isolinux/isolinux.cfg,其中重要选项有
加载内核:isolinux/vmlinuz
向内核传递参数:append initrd=initrd.img
||
V
装载根文件系统,并启动anaconda
默认界面是图形界面:需要512MB+内存空间
若需要显式指定启动TUI接口: 向启动内核传递一个参数"text"即可
按ESC键可以键入boot命令行,键入linux text即可正常启动
键入linux method,即可手动指定仓库
1.3 anaconda的工作过程
1.3.1 安装前配置阶段
安装过程使用的语言;
键盘类型
安装目标存储设备
Basic Storage:本地磁盘
Special Storage: iSCSI
设定主机名
配置网络接口
时区
管理员密码
设定分区方式及MBR的安装位置;
创建一个普通用户;
选定要安装的程序包;
1.3.2 安装阶段
在目标磁盘创建分区并执行格式化;
将选定的程序包安装至目标位置;
安装bootloader;
1.3.3 首次启动
iptables
selinux
core dump
1.4 anaconda的配置方式:
交互式配置方式;
支持通过读取配置文件中事先定义好的配置项自动完成配置;遵循特定的语法格式,此文件即为kickstart文件;
2. 版本:
OS:RHEL6.8
kickstart:system-config-kickstart-2.8.6.6-1.el6.noarch.rpm
3. ks-scripts:
# Kickstart file automatically generated by anaconda.
lang en_US.UTF-8
keyboard us
skipx
rootpw --iscrypted $6$LFw8plSO4ZU9jfXp$oV4ywwfa0BbAVDFLKj/Mqnbbe5lCv/H0DgppcOWbcMc3JjvHsJ5bjncpf795fyxqGt.r3n31NVsVOdO.1mIwS/
authconfig --enableshadow --passalgo=sha512
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part pv.008002 --grow --size=200
volgroup vg_system --pesize=4096 pv.008002
logvol /home --fstype=ext4 --name=lv_home --vgname=vg_system --size=4096
logvol /opt --fstype=ext4 --name=lv_opt --vgname=vg_system --size=4096
logvol / --fstype=ext4 --name=lv_root --vgname=vg_system --size=4096
logvol swap --name=lv_swap --vgname=vg_system --size=4096
logvol /tmp --fstype=ext4 --name=lv_tmp --vgname=vg_system --size=4096
logvol /usr --fstype=ext4 --name=lv_usr --vgname=vg_system --size=4096
logvol /var --fstype=ext4 --name=lv_var --vgname=vg_system --size=4096
install
text
network --onboot yes --device eth0 --bootproto static --ip 10.30.2.1 --netmask 255.255.255.0 --gateway 10.30.2.254 --noipv6 --nameserver 10.24.2.1 --hostname hctjcobbler
firewall --disabled
selinux --disabled
zerombr yes
services --disabled=avahi-daemon,cups --enabled=auditd
reboot
repo --name="ftp" --baseurl=ftp://10.26.2.58/depot/yum/rhel65 --cost=1000
url --url ftp://10.26.2.58/depot/yum/rhel65/
%packages
@base
@compat-libraries
@console-internet
@core
@debugging
@development
@directory-client
@fonts
@graphical-admin-tools
@hardware-monitoring
@java-platform
@large-systems
@legacy-unix
@legacy-x
@network-file-system-client
@performance
@perl-runtime
@system-management-snmp
@server-platform
@server-policy
@storage-client-multipath
@system-management
@system-admin-tools
@system-management-wbem
@x11
@storage-client-iscsi
mtools
pax
python-dmidecode
oddjob
tunctl
yum-plugin-downloadonly
yum-plugin-versionlock
sgpio
x86info
zsh
ftp
lftp
compat-gcc-34
compat-gcc-34-g77
jpackage-utils
compat-gcc-34-c++
samba-winbind
certmonger
pam_krb5
krb5-workstation
nscd
pam_ldap
nss-pam-ldapd
system-config-lvm
lm_sensors
rsh
rwho
rusers
telnet
tcp_wrappers
finger
ksh
xterm
libXmu
perl-LDAP
perl-DBD-SQLite
ipmitool
OpenIPMI
rrdtool
screen
tree
lsscsi
tog-pegasus
rpm-devel
libuuid.i686
freetype.i686
libSM.i686
libICE.i686
libXau.i686
libxcb.i686
libX11.i686
libXext.i686
libXi.i686
libXrender.i686
libXrandr.i686
libXfixes.i686
libXcursor.i686
expat.i686
fontconfig.i686
zlib.i686
libstdc++.i686
pam.i686
libacl.i686
-pcmciautils
%end
4. 安装
4.1 安装引导选项:
ks:指明kickstart文件的位置;
ks=cdrom:/PATH/TO/KICKSTART_FILE #DVD drive
ks=hd:/DEVICE/PATH/TO/KICKSTART_FILE #Hard Driv
ks=http://HOST[:PORT]/PATH/TO/KICKSTART_FILE #HTTP Server
ks=ftp://HOST[:PORT]/PATH/TO/KICKSTART_FILE #FTP Server
ks=https://HOST[:PORT]/PATH/TO/KICKSTART_FILE #HTTPS Server
asknetwork:交互式填入网卡IP地址
text:文本安装方式
method:手动指定使用的安装方法
与网络相关的引导选项:
ip=IPADDR
netmask=MASK
gateway=GW
dns=DNS_SERVER_IP
远程访问功能相关的引导选项:
vnc
vncpassword='PASSWORD'
启动紧急救援模式:
rescue
装载额外驱动:
dd
4.2 kickstart文件的格式(详见脚本上的注释)
4.2.1 命令段:指定各种安装前配置选项,如键盘类型等
4.2.1.1 必备命令:
4.2.1.2 可选命令:
4.2.2 程序包段:
4.2.3 脚本段:
%pre:安装前脚本。运行环境:运行安装介质上的微型linux
%post:安装后脚本。运行环境:安装完成的系统;
4.3 kickstart图形工具:
名称:system-config-kickstart-2.8.6.6-1.el6.noarch.rpm
安装:yum install system-config-kickstart
检查语法错误命令:ksvalidator
4.4 安装过程:
4.4.1 光盘安装:
引导光盘制作:
挂载引导光盘到系统文件夹
mount /dev/sr0 /mnt
拷贝所有文件到要制作镜像的文件夹
cp -r /mnt/* /tmp/myboot/
下载ks文件到光盘镜像制作文件夹
wget ftp://10.26.2.58/scripts/kickstart/anaconda-ks2.cfg
制作镜像文件
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "RHEL 6 x86_64 boot" -c isolinux/boot.cat -b isolinux/isolinux.bin -o /tmp/boot.iso /tmp/myboot/
修改isolinux/isolinux.cfg文件,在需要引导的选项后面指定ks地址
append initrd=initrd.img ks=cdrom:/anaconda-ks.cfg
4.4.2 网络安装:
开机按ESC键进入引导选项
# 使用网络安装
boot: linux ip=10.30.2.1 netmask=255.255.255.0 ks=ftp://10.26.2.58/scripts/kickstart/annaconda-ks.cfg
手机扫一扫
移动阅读更方便
你可能感兴趣的文章