Kickstart无人值守安装-阿里云开发者社区

开发者社区> 开发与运维> 正文

Kickstart无人值守安装

简介:

Kickstart无人值守安装操作系统

1.      什么是PXE?

他是一种引导方式.全称pre-bootexecution environment.通过网络接口启动计算机,不依赖本地存储设备(如硬盘)或本地已安装的操作系统;

一篇博客:http://www.zyops.com/autoinstall-kickstart

  1. 无人值守安装

总共分几个部分:

·        安装桌面:yum install –y “Desktop” “XWindow System”

·        安装httpd: yum install –y httpd

·        挂载ISO镜像文件,拷贝镜像文件到/var/www/html

·        Tftp-server配置:yum install –y tftp-server

Vi /etc/xinetd.d/tftp-server文件,修改disable值为no; server_args   = -s/tftpboot ;重启xinetd:service xinetd restart

建立/tftpboot目录,复制pxelinux.0文件到他下面.

Cp /usr/share/syslinux/pxelinux.0  /tftpboot/ 注意:如果这里找不到pxelinux.0文件需要我们安装syslinux

下面我们还需要复制另外3个文件到/tftpboot下面:

Cp /var/www/html/images/pxeboot/initrd.img  /tfptboot

Cp /var/www/html/images/pxeboot/vmlinuz   /tfptboot

Cp /var/www/html/isolinx/* /tfptboot

/tfptboot下面建立一个目录:

Mkdir  -p/tfptboot/pxelinux.cfg

复制文件isolinux.cfgpxelinux.cfg:

Cp /var/www/html/isolinux/isolinux.cfg  /tftpboot/pxelinux.cfg/default

这里我们需要修改/tftpboot/pxelinux.cfg/default文件黄色标注的值为被改过的值:

#default text ks = http://192.168.42.130/abc/ks.cfg

#default vesamenu.c32

defaultks

#prompt 1

#timeout 600

timeout1

 

display boot.msg

 

menu background splash.jpg

menu title Welcome to CentOS 6.8!

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

 

labelks

  menu label ^Installor upgrade an existing system

  menu default

  kernel vmlinuz

  appendinitrd=initrd.img ks=http://192.168.42.130/abc/ks.cfg

label vesa

  menu label Installsystem with ^basic video driver

  kernel vmlinuz

  appendinitrd=initrd.img nomodeset

label rescue

  menu label ^Rescueinstalled system

  kernel vmlinuz

  appendinitrd=initrd.img rescue

label local

  menu label Boot from^local drive

  localboot 0xffff

label memtest86

  menu label ^Memorytest

  kernel memtest

  append -

  • Dhcp配置:yum install dhcp –y 注意:新建的VM需要使用NAT模式

编辑配置文件:vi/etc/dhcp/dhcpd.conf

#

# DHCP Server Configuration file.

#   see/usr/share/doc/dhcp*/dhcpd.conf.sample

#   see 'man 5dhcpd.conf'

ddns-update-style interim;

log-facility local7;

ignore client-updates;

next-server192.168.42.130;  tftp-server服务器地址

filename"/pxelinux.0"; PXE启动文件

subnet 192.168.42.0 netmask 255.255.255.0 {

  range dynamic-bootp192.168.42.100 192.168.42.200;

  optiondomain-name-servers 192.168.42.2;

  option routers192.168.42.2;

  option subnet-mask255.255.255.0;

  default-lease-time21600;

  max-lease-time72000;

}

  • kickstart配置:记录人工干预填写的各个参数,生成ks.cfg文件.首先需要我们安装包:yuminstall –y system-config-kickstart之后执行这个命令即可.

Pxe配置:

spacer.gif

 

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url--url="http://192.168.42.130/OS"

# Root password

rootpw --iscrypted $1$LdXzG2rY$1ojDCc5//hi5EhFpp.E/z0

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --enforcing

# Installation logging level

logging --level=info

 

# System timezone

timezone America/Los_Angeles

# Network information

network --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part / --fstype="ext4" --size=50000

part /boot --fstype="ext4" --size=256

part /home --fstype="ext4" --grow --size=1

 

%post--interpreter=/bin/bash

echo "kickstart">/root/testok.txt

%end

 

  1. 报错:

Could not find kernel image text

spacer.gif

这个的根本原因是/tfptboot/pxelinux.cfg/default配置错误,正确的配置如下:

#default text ks = http://192.168.42.130/abc/ks.cfg

#default vesamenu.c32

default ks

#prompt 1

#timeout 600

timeout 1

 

display boot.msg

 

menu background splash.jpg

menu title Welcome to CentOS 6.8!

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 ks

  menu label ^Installor upgrade an existing system

  menu default

  kernel vmlinuz

  appendinitrd=initrd.img ks=http://192.168.42.130/abc/ks.cfg

label vesa

  menu label Installsystem with ^basic video driver

  kernel vmlinuz

  appendinitrd=initrd.img nomodeset

label rescue

  menu label ^Rescueinstalled system

  kernel vmlinuz

  appendinitrd=initrd.img rescue

label local

  menu label Boot from^local drive

  localboot 0xffff

label memtest86

  menu label ^Memorytest

  kernel memtest

  append -

 

 










本文转自chenzudao51CTO博客,原文链接:http://blog.51cto.com/victor2016/1949502 ,如需转载请自行联系原作者




版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章