kickstart+pxe+yum仓库 实现无人值守安装机器的流程 (1)kickstart

本文介绍了如何使用kickstart文件和PXE(网络引导)实现无人值守的CentOS 7安装。首先,通过U盘创建一个最小化的启动盘,并配置ks.cfg文件。接着,利用system-config-kickstart工具生成自动应答文件,包含网络配置、时区设置、用户创建等步骤。最后,调整isolinux.cfg以指定ks.cfg位置,并在系统安装后执行自定义脚本进行后处理。
摘要由CSDN通过智能技术生成

构思:

一.使用kickstart制作自动应答文件

kickstar依赖于一个最小的系统才可以跑,所以为了试验自动应答文件的可用性,我们需要用U盘制作一个最小化的启动盘。(后期通过网络启动就不需要U盘做启动盘了)

实现原理:

U盘通过读取 ks.cfg 文件(它指明了非交互式安装环境时的设置内容)来实现安装操作系统,ks.cfg 配置文件放在U盘的isolinux目录里即可,然后修改 isolinux/isolinux.cfg 文件(  ISOLINUX是  SYSLINUX项目的一系列引导程序中的一个,简单的说就是类似GRUB的一个东西,就是启动然后引导内核。 ISOLINUX启动后,默认会去读出cd光盘根目录的一个isolinux.cfg 文件,isolinux.cfg 类似grub的menu.lst,指定的内核镜像位置等。),设置内核参数,指定 ks.cfg 文件的位置即可。  

官网镜像:http://archive.kernel.org/centos-vault/7.5.1804/isos/x86_64/

选netinstall的话里面是没有yum源的,我们现在先选everything

Livecd 做成的启动盘里自带source

接下来是安装kickstart configurator (也可以自己从头写。。) centos用这俩条命令启动和安装

yum install system-config-kickstart -y

system-config-kickstart 

配置post install可以参考这个 因为我有自己的shell安装系统脚本 在这里可以用

http://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-sag-en-4/s1-kickstart2-postinstallconfig.html

https://people.centos.org/jperrin/Kickstart2.html#_sect_kickstart_postinstall

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/installation_guide/s1-kickstart2-file

 

生成的ks.cfg文件:

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --enforcing

# Firewall configuration
firewall --disabled

ignoredisk --only-use=sda
# Network information
network  --bootproto=dhcp --device=eno1 --ipv6=auto --activate
network  --bootproto=dhcp --device=eno2 --onboot=off --ipv6=auto
network  --bootproto=dhcp --hostname=spgpu

# Root password
rootpw 123
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --groups=wheel --name=gouzi --password=123

# Reboot after installation
reboot
# System timezone
timezone Africa/Abidjan
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda

%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb=auto
%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

 

%post --interpreter=/usr/bin/sh --log=/root/postinstall.log
mkdir -p /home/install
wget -c http://120.27xxxxxxx/software/xxx-workstation_post_install_v1.2.3.sh > /home/install/xxx-workstation_post_install_v1.2.3.sh
cd /home/install
chmod 777 xxx-workstation_post_install_v1.2.3.sh
./xxx-workstation_post_install_v1.2.3.sh
%end

 

isolinux.cfg文件:

default vesamenu.c32
timeout 600

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title CentOS 7
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux-1
  menu label ^Install CentOS 7-1
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS\x207\x20X8 inst.ks=hd:LABEL=CENTOS\x207\x20X8:/isolinux/ks.cfg

label linux-2
  menu label ^Install CentOS 7-2
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS\x207\x20X8 inst.ks=hd:LABEL=CENTOS\x207\x20X8:/isolinux/ks.cfg

label check
  menu label Test this ^media & install CentOS 7
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS\x207\x20X8 rd.live.check quiet

menu separator # insert an empty line

# utilities submenu
menu begin ^Troubleshooting
  menu title Troubleshooting

label vesa
  menu indent count 5
  menu label Install CentOS 7 in ^basic graphics mode
  text help
    Try this option out if you're having trouble installing
    CentOS 7.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS\x207\x20X8 xdriver=vesa nomodeset quiet

label rescue
  menu indent count 5
  menu label ^Rescue a CentOS system
  text help
    If the system will not boot, this lets you access files
    and edit config files to try to get it booting again.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS\x207\x20X8 rescue quiet

label memtest
  menu label Run a ^memory test
  text help
    If your system is having issues, a problem with your
    system's memory may be the cause. Use this utility to
    see if the memory is working correctly.
  endtext
  kernel memtest

menu separator # insert an empty line

label local
  menu label Boot from ^local drive
  localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
  menu label Return to ^main menu
  menu exit

menu end

 

烧录的镜像里这样安排

启动机器走U盘 就可以甩手啦

跑完之后去/root 看

最基础的就是自带的/root/anaconda.cfg改来的

参考

东哥(俺师傅)

https://docs.oracle.com/cd/E52668_01/E54695/html/ol7-kickstart-postinstall-options.html

https://blog.csdn.net/Filter_CPH/article/details/52711607

https://www.cnblogs.com/liwei0526vip/p/6416225.html

https://www.cnblogs.com/lpfuture/p/5704416.html

https://blog.csdn.net/turnaroundfor/article/details/79277034

https://blog.csdn.net/code__l/article/details/77131475

https://blog.csdn.net/heshijie87/article/details/74090335

https://www.ibm.com/developerworks/cn/linux/l-lo-efficient-cluster-manage-system-LSF/index.html

https://blog.csdn.net/liujixin8/article/details/4029887

https://blog.csdn.net/nsdhy/article/details/38683107

https://www.cnblogs.com/liubaiedu/p/6756639.html\

https://blog.csdn.net/guofengdidai/article/details/52184374

https://www.cnblogs.com/mchina/p/centos-pxe-kickstart-auto-install-os.html

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值