第一百一十一天 : PXE快速部署CentOS系统

PXE 自动化部署

BootStrapping : (OS Install)

tftp server :

  • INSTALL : yum install tftp-server tftp
  • Start :
    • 7 : systemctl start tftp
    • 6 : chkconfig tftp on
      • : service xinetd restart
  • 默认的文件根目录 : /var/lib/tftpboot

安装syslinux :

  • 安装完成后, 复制相应的文件到/var/lib/tftpboot 目录下
    chain.c32
    mboot.c32
    memdisk
    menu.c32
    pxelinux.0
  • 然后从光盘镜像中 /mnt/cdrom/image/pxeboot/ 目录下复制
    vmlinuz
    initrd.img
  • 之后为启动时显示的菜单创建配置文件
    • 在 /var/lib/tftpboot/pxelinux.cfg/ 目录下新建default 文件来定义菜单
      内容如下
default menu.c32
    prompt 5
    timeout 30
    MENU TITLE CentOS 7 PXE

    LABEL linux
    MENU LABEL Install Centos 7 x86_64
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=ftp://192.168.48.100/pub/centos/7/

准备好后使用新的虚拟机试启动(在开启了DHCP服务, 和tftp服务的情况下)
虚拟机能正常运行.
- 准备kickstart文件
内容如下

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url="ftp://192.168.48.100/pub/centos/7/"
firewall --disabled

# Use graphical install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device=eno16777736 --ipv6=auto --activate
network  --hostname=new.nextkara.net

# Root password
rootpw --iscrypted $6$gdJX4wDty/nhfVIK$wNJvGPToK0pIxgFodf3hDpPK3RIMxsb8aGUU9/BZhyy8FOhmNimj8Si0KZ2Y6iFcVz3VjJNAuRmKOlA9a99In1
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=2049
part / --fstype="xfs" --ondisk=sda --size=81920
part /boot --fstype="xfs" --ondisk=sda --size=1024

%packages
@^minimal
@compat-libraries
@core
@development
@security-tools
vim
tree
net-tools
nmap
psmisc
%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

准备好了之后, 修改default文件

default menu.c32
    prompt 5
    timeout 30
    MENU TITLE CentOS 7 PXE

    LABEL linux_auto
    MENU LABEL Install Centos 7 x86_64 (Automatic)
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=ftp://192.168.48.100/pub/centos/7/ ks=ftp://192.168.48.100/pub/ks.cfg

    LABEL linux
    MENU LABEL Install Centos 7 x86_64
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=ftp://192.168.48.100/pub/centos/7/

在default 文件中指明软件源和Kickstart文件所在位置
CentOS 7 的PXE安装到此结束

CentOS 6 自动安装

  1. 在系统上安装syslinux
    yum -y install syslinux
  2. 复制文件到tftp目录下
cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img}  /var/lib/tftpboot/
cp /media/cdrom/isolinux/{boot.msg,vesamenu.c32,splash.jpg}  /var/lib/tftpboot/
  1. 为菜单配置文件创建目录
    mkdir /var/lib/tftpboot/pxelinux.cfg/
  2. 复制配置文件
    cp /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  3. 修改配置文件内容如下
menu background splash.jpg
        menu title Welcome to CentOS 6.8 Installer!
        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 autoinst
        menu label ^Auto Install CentOS
        menu default
        kernel vmlinuz
        append initrd=initrd.img ks=ftp://192.168.10.16/pub/centos6.cfg
        label linux
        menu label ^Install or upgrade an existing system
        kernel vmlinuz
        append initrd=initrd.img
        abel 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 -
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值