kickstart光盘一键部署系统和程序,包括centos6和Centos7

默认使用centos6.9来制作iso镜像

1.挂载iso光盘镜像到机器上,复制出来,不要漏了.discinfo和.treeinfo,不然安装会报 disc not found 错误

mount /dev/sr0 /mnt/

2.修改isolinux/isolinux.cfg文件

default kickstart   #默认执行label kickstart
#prompt 1
timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.9!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img nomodeset
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff
label memtest86
  menu label ^Memory test
  kernel memtest
  append -
label kickstart     #添加label kickstart
  kernel vmlinuz
  append ks=cdrom:/kickstart.cfg initrd=initrd.img    #cfg存放目录为根目录

3.添加kickstart.cfg文件

1)可以通过图形界面安装 kickstart-config图形界面配置生成cfg文件

[root@server] yum install system-config-kickstart -y
[root@server] system-config-kickstart

2)Centos6编辑cfg文件

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled  #关闭防火墙
# Install OS instead of upgrade
install                   #全新安装
# Use CDROM installation media
cdrom                       #光盘安装
# Root password
rootpw --iscrypted $1$ZPW7sRov$u7kkx9Zt5PTUcgGFctD1d1   #root密码加密
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text                    #字符界面安装
firstboot --disable
# System keyboard
keyboard us            #键盘类型
# System language
lang zh_CN            #字符集格式
# SELinux configuration
selinux --disabled           #关闭selinux
# Do not configure the X Window System
skipx                 #不安装图形工具
# Installation logging level
logging --level=info            #安装日志级别info
# Reboot after installation
reboot                     #安装完成后重启机器
# System timezone
timezone  Asia/Shanghai            #系统时间时区
# Network information
network  --bootproto=static --device=eth0 --gateway=10.0.0.1 --ip=10.0.0.1 --nameserver=114.114.114.114 --netmask=255.255.255.0 --onboot=on           #网卡配置
# System bootloader configuration
bootloader --location=mbr            #引导程序写入位置默认
# Clear the Master Boot Record
zerombr                              
# Partition clearing information
clearpart --all                  #清空磁盘所有分区
# Disk partitioning information
part swap --fstype="swap" --size=2000                   #分配磁盘
part /boot --fstype="ext4" --size=200
part / --fstype="ext4" --grow --size=1
%packages
@basic-desktop
@desktop-debugging
@fonts
@internet-browser
@general-desktop
@graphical-admin-tools
@kde-desktop
@legacy-x
@x11
%post --nochroot
if [ ! -d "/mnt/source" ]
   then ln -s /mnt/isodir /mnt/source;    #安装时iso镜像挂载的目录
fi
alias cp=cp
cp -r /mnt/source/install-single/ /mnt/sysimage/root/            #安装前操作,类似于windows的安全模式
#可以放置相应的程序安装包,安装包放在ISO目录的根目录
%post                               
-----------------安装后操作-------------------------
sed -i 's/quiet/quiet console=tty0 console=ttyS0,9600n8/' /boot/grub/grub.conf
echo "s0:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS0 vt100" >>/etc/inittab
echo "ttyS0" >> /etc/securetty
cd /root/install-single/
./web-install.sh
eject         #弹出光盘
-----------------安装后操作-------------------------
%end

3)Centos7编辑cfg文件,注意安装后操作。

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$zbG2nx3Y$aDX48..NoI3quW7r9uVBx.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /home --fstype="ext4" --size=51100
part swap --fstype="swap" --size=4096
part /boot --fstype="ext4" --size=1024
part / --fstype="ext4" --grow --size=1
%packages --nobase 
@core
%end
-------------------------安装后操作
%post
alias cp=cp
mount /dev/sr0 /mnt/
#安装程序包放置在上步复制出来的ISO目录的根目录
cp -R /mnt/install-3.0.2.2  /root/
cd /root/docker/
sh install-3.0.2.2.sh
eject
%end
--------------------------安装后操作

4.制作Centos6 iso镜像

mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/CentOS6.9.iso /tmp/iso/
#根据Centos版本,填写相应版本号,生成到/tmp/iso/目录。

4.制作Centos7 iso镜像

mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 7.X" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/CentOS7.X.iso /tmp/iso/
#根据Centos版本,填写相应版本号,生成到/tmp/iso/目录。

你可能感兴趣的:(学习笔记)