2013年4月2日星期二

How to make a PXE Server?

The title is really XXX. The PXE Service has a series small service to comprise. Such as tftp, dhcp , nfs and kickstart cfg file , etc.

# Install Syslinux

yum install -y syslinux
mkdir -p /tftpboot/
cp -rvf /usr/share/syslinux/* /tftpboot/

# Install tftp-server

yum install -y tftp-server
编辑/etc/xinetd.d/tftp 将disable改成no
service xinetd restart

# Install dhcp server
yum install -y dhcp

# Edit File /etc/dhcp/dhcpd.conf

subnet 172.172.172.0 netmask 255.255.255.0 {
subnet-specific parameters...
        range 172.172.172.2 172.172.172.254;
        option domain-name-servers 42.96.162.172;
option routers 172.172.172.1;
        max-lease-time 120;
        default-lease-time 120;
filename "pxelinux.0"
next-server 42.96.162.172;
}

Attention: DHCP配置的时候, subnet一定和 eth0 或者某个接口在同一个网段, 子接口好像有点问题。

# File:  /tftpboot/pxelinux.cfg/default
z
default menu.c32
prompt 0
timeout 600
ONTIMEOUT 5

MENU TITLE PXE Menu

LABEL CentOS 6.3 x86_64 WITH KS eth0
        MENU CentOS 6.3 x86_64 WITH KS eth0
        KERNEL images/centos/6.3/x86_64/vmlinuz
        APPEND ks initrd=images/centos/6.3/x86_64/initrd.img ramdisk_size=100000 ksdevice=eth0 ip=dhcp append ks=nfs:192.168.50.219:/net-install/kickstarts/ks.centos6.3.cfg

# Disable selinux
setenforce 0

# Maybe you can define your own kickstart file with the following installed sdoftware

yum search "kickstart"
yum install system-config-kickstart

# Edit file : /net-install/kickstarts/ks.centos63.cfg

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.50.219 --dir=/net-install/centos/6.3/x86_64/
# Root password
rootpw --iscrypted $1$LCNmaMaA$gGyp9YjKMWJfrzoLJsWSI1
# System authorization information
auth  --useshadow  --passalgo=md5
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info

# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
part swap --fstype="swap" --ondisk=sda --size=10240
part / --fstype="ext4" --grow --ondisk=sda --size=1

reboot

%packages
@base
@basic-desktop
@chinese-support
@client-mgmt-tools
@console-internet
@core
@debugging
@desktop-platform
@development
@fonts
@ftp-server
@general-desktop
@graphical-admin-tools
@graphics
@input-methods
@internet-applications
@internet-browser
@legacy-x
@mail-server
@network-file-system-client
@network-server
@network-tools
@perl-runtime
@php
@remote-desktop-clients
@system-admin-tools
@system-management
@system-management-messaging-server
@system-management-snmp
@web-server
@x11
crypto-utils
%end

# you should exact the iso file to the dir /net-install/centos/6.3/x86_64/
# if the iso is at /tmp/1.iso, the following are commands to do this job.
mkdir -p /net-install/centos/6.3/x86_64/
mkdir /a
mount -o loop /tmp/1.iso /a
cp -rvf /a/* /net-install/centos/6.3/x86_64





没有评论:

发表评论