PXE推送,NFS切換本地源

yum -y install tftp-server

修改TFTP配置文件

vi /etc/xinetd.d/tftp 

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /var/lib/tftpboot

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}


yum -y install dhcp  

安裝DHCP 修改配置文件

cat > /etc/dhcp/dhcpd.conf << EOF

allow booting;

allow bootp;

ddns-update-style interim;

ignore client-updates;

subnet 192.168.10.0 netmask 255.255.255.0 {

        option subnet-mask      255.255.255.0;

        option domain-name-servers  192.168.10.1;

        range dynamic-bootp 192.168.10.100 192.168.10.200;

        default-lease-time      21600;

        max-lease-time          43200;

        next-server             192.168.10.1;

        filename                "pxelinux.0";

}

EOF


創建NFS目錄 

mkdir /nfs     ######存放安裝鏡像 

mkdir /config  #####存放KS文件

修改NFS配置

vi /etc/exports

/nfs  *(ro)

/config  *(ro)


yum -y install syslinux

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot

mkdir -p /var/lib/tftpboot/pxelinux.cfg

mount /dev/sr0 /nfs  掛載安裝源

cp /nfs/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

vim default


default文件配置

-----------------------

default linux

timeout 60

display boot.msg

label linux

  kernel vmlinuz

  append initrd=initrd.img inst.stage2=nfs:192.168.10.1:/nfs ks=nfs:192.168.10.1:/config/ks.cfg quiet

menu end


ks文件可以用system-config-kickstart生成

出現不能選擇安裝包的問題 增加YUM源

vi /etc/yum.repos.d/development.repo 

[development]

name=base

baseurl=file:///nfs

enabled=1

gpgcheck=0  


掛載ISO文件 切換安裝鏡像 每次攜帶虛擬機更換鏡像

#!/bin/bash

mount /dev/sr0 /nfs 

/bin/cp -f /nfs/images/pxeboot/initrd.img /var/lib/tftpboot/

/bin/cp -f /nfs/images/pxeboot/vmlinuz /var/lib/tftpboot/

/bin/cp -f /nfs/isolinux/vesamenu.c32 /var/lib/tftpboot/

/bin/cp -f /nfs/isolinux/boot.msg /var/lib/tftpboot/

systemctl stop firewalld.service 

systemctl start dhcpd

systemctl start xinetd.service 

systemctl start nfs-server.service


ks文件 

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Install OS instead of upgrade

install

# Keyboard layouts

keyboard 'us'# Reboot after installation

reboot

# Root password

rootpw --iscrypted $1$vcJPtcO6$cENeN0IzJRuP5nPaDsfMh.

# System timezone

timezone Asia/Shanghai

# System language

lang en_US

# Firewall configuration

firewall --disabled

# System authorization information

auth  --passalgo=sha512

# Use graphical install

graphical

# Run the Setup Agent on first boot

firstboot --enable

# SELinux configuration

selinux --disabled


# Use NFS installation media

nfs --server=192.168.10.1 --dir=/nfs

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all  


%packages

@base

@compat-libraries

@fonts

@gnome-desktop

@graphical-admin-tools

@legacy-x

@network-tools

@perl-runtime

@system-management

@x11

%end


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章