参考URL: http://www.atmarkit.co.jp/flinux/rensai/linuxtips/710pxeserver.html
参考URL:http://www.atmarkit.co.jp/flinux/rensai/linuxtips/711pxeinst.html

PXE(Preboot eXecution Environment)は
Intelが開発したネットワークブートの規格のこと。

以下、設定例。

[テスト環境]
 インストールするOS: CentOS5.x (64bit)
 PXEサーバIPアドレス: 192.168.80.200

■PXE環境構築手順(例)■

1.TFTP環境の準備

 ・インストール
  # rpm -qa | grep tftp
  tftp-server-0.49-2.el5.centos
  tftp-0.49-2.el5.centos

  ※インストールされていなければ
  ※yum install tftp tftp-serverでインストール

 ・tftpを使用可能にする
  # vi /etc/xinetd.d/tftp
  ---
  disable = no にする
  ---
 ・xinetdを再起動
  # service xinetd restart

 ・ISOファイルのコピー
  # mkdir /mnt/iso
  # mkdir /var/www/html/iso-cent5.5-64bit

  -----(1枚目コピー)-----
  # mount -t iso9660 -o loop (ディレクトリ)/CentOS-5.5-x86_64-bin-DVD-1of2.iso /mnt/iso
  # cp -r /mnt/iso/* /var/www/html/iso-cent5.5-64bit/.
  # umount /mnt/iso

  ※自分の環境では最低パッケージしか選ばないので
   1枚目のみをコピーしておくものとする。

2.PXEサーバ(syslinux)のインストール

 ・インストール
  # rpm -qa | grep syslinux
  syslinux-3.11-4

  ※インストールされていなければ
  ※yum install syslinux

 ・PXE用のブートイメージディレクトリを作成
  # mkdir /tftpboot/install-CentOS5.5-32bit

 ・PXE用のブートイメージをTFTPサーバにコピー
  # cp /var/www/html/iso-cent5.5-64bit/images/pxeboot/vmlinuz /tftpboot/install-CentOS5.5-64bit/
  # cp /var/www/html/iso-cent5.5-64bit/images/pxeboot/initrd.img /tftpboot/install-CentOS5.5-64bit/

 ・ブートローダの準備
  # cp /usr/lib/syslinux/pxelinux.0 /tftpboot/install-CentOS5.5-64bit/

 ・複数OS選択できるようにメニュー環境を準備
  cp /usr/lib/syslinux/menu.c32 /tftpboot/install-CentOS5.5-64bit/

 ・PXEブート用の設定ファイルを作成
  以下のような内容のファイルを作成する。

  # mkdir /tftpboot/install-CentOS5.5-64bit/pxelinux.cfg
  # vim /tftpboot/install-CentOS5.5-64bit/pxelinux.cfg/default

---
default menu.c32

MENU TITLE ***** PXE Boot Menu (by Tomy) *****

label 11
menu label ^11. aaaa (ks=11-aaaa-ks.cfg)
kernel vmlinuz
append ks=http://192.168.80.200/11-aaaa-ks.cfg load initrd=initrd.img devfs=nomount

label 12
menu label ^12. bbbb (ks=12-bbbb-ks.cfg)
kernel vmlinuz
append ks=http://192.168.80.200/12-bbbb-ks.cfg load initrd=initrd.img devfs=nomount

label 13
menu label ^13. cccc (ks=13-cccc-ks.cfg)
kernel vmlinuz
append ks=http://192.168.80.200/13-cccc-ks.cfg load initrd=initrd.img devfs=nomount

---

3.DHCPサーバのインストール

yum install dhcp-devel
※dhcp, dhcp-develのインストール

# vim /etc/dhcpd.conf
---
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style none;
ignore client-updates;

subnet 192.168.80.0 netmask 255.255.255.0 {
option routers 192.168.80.200;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.80.2;
next-server 192.168.80.200;
range dynamic-bootp 192.168.80.201 192.168.80.250;
filename "/install-CentOS5.5-64bit/pxelinux.0";
}

※next-server: ブートファイルを持つサーバ
※filename : ブートファイル名

★ここでは念のためまだdhcpdを起動しない★
 ※環境によってほかのサーバに影響が発生する可能性があるため。

4.apacheの準備

 ・apacheインストール
  # rpm -qa | grep httpd
  httpd-2.2.3-43.el5.centos.3
  ※インストールされていない場合は
  ※yum install httpd でインストール

 ・apache起動
  # service httpd start

5.キックスタートファイルの作成

 ・インストールするサーバのrootパスワードの生成
  # openssl passwd -1
  Passwd: パスワード
  Verifying - Password: パスワード再入力
  <生成された文字列をコピー>

 ・kickstart用の設定ファイルを作成
  ※apacheのドキュメントルートに作る。
  # vim /var/www/html/11-aaa-ks.cfg

-----(例)-----
# Kickstart file automatically generated by anaconda.

install
###cdrom
url --url http://192.168.80.200/iso-cent5.5-64bit

lang ja_JP.UTF-8
keyboard jp106
network --device eth0 --bootproto static --ip 192.168.80.200 --netmask 255.255.255.0 --gateway 192.168.80.2 --nameserver 192.168.80.2 --hostname XXXX-wbXX
rootpw --iscrypted (↑でコピーしたパスワード)
firewall --disable
authconfig --enableshadow --enablemd5
###selinux --enforcing
selinux --disabled
timezone Asia/Tokyo
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --linux
clearpart --all ★(1)
part / --fstype ext3 --size=0 --grow ★(2)
part swap --size=512

%packages
@base
@core
@japanese-support
@development-tools
device-mapper-multipath
-----
★(1)
 新しいパーティションを作成する前に、システムからパーティションを削除するか。
 「--all」全てのパーティションが削除
 「--drives」パーティションを削除するドライブを指定
 「--linux」Linux パーティションだけを全て消去
 「--none」パーティションを削除しない
 省略時のデフォルトは「--none」(削除しない)

★(2)
 主なオプション
 「--size」パーティションの最小サイズを MB 単位で入力
 「--grow」最大許容量または指定サイズまで拡張するよう指示
 「--maxsize」パーティションを拡張する際の最大サイズを指定
 「--onpart」「--usepart」既に存在するパーティションを利用
 「--noformat」--onpart オプションと併用します。パーティションをフォーマットしない
 「--ondisk」「--ondrive」特定のディスク上にパーティションを作成
 「--asprimary」プライマリパーティションにするよう指示
 「--fstype」パーティションのファイルシステム形式を指定


3.PXEネットワークブート実行
■BIOS設定
OSをインストールするサーバのBIOSで
「ネットワークブートの順番をHDDより前にしておく」

■PXEネットワークブート
自動的にDHCPサーバからアドレスが取得されPXEブートメニュー(menu.c32)が表示される。
tftpbootのdefaultに記述した中からインストールしたいOSを選択する。