1)必要なパッケージをインストール
yum -y install syslinux
yum -y install dhcpd
yum -y install xinetd
yum -y install nfs
yum install tftp-server tftp
rpm -qa | grep tftp
tftp-0.42-3.1.el5.centos
tftp-server-0.42-3.1.el5.centos
rpm -qa | grep dhcp
dhcpv6-client-1.0.10-4.el5
dhcp-3.0.5-18.el5
2)ISOイメージのアップロード
SCP等でOS(今回はCentOS5.9を使用)イメージをサーバに送る
今回は/tmp直下に置いた。
3)ISOイメージのマウント、展開
mkdir /mnt/centos
mount -t iso9660 -o loop /tmp/CentOS-5.9-x86_64-bin-DVD-1of2.iso /mnt/centos
cd /mnt/centos
mkdir /kickstart/isos
cp -r * /kickstart/isos
展開が終わったらISOイメージはumountしたうえで削除
(ディスク容量節約のため)
umount /mnt/centos
rm -rf /tmp/CentOS-5.9-x86_64-bin-DVD-1of2.iso
4)設定ファイルのコピー
mkdir /tftpboot
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /kickstart/isos/images/pxeboot/initrd.img /tftpboot/
cp /kickstart/isos/images/pxeboot/vmlinuz /tftpboot/
5)PXEブート用の設定ファイルを作成
mkdir /tftpboot/pxelinux.cfg
vi /tftpboot/pxelinux.cfg/default
/tftpboot/linux-install/pxelinux.cfg/defaultの中身
default centos5
label centos5
kernel vmlinuz
append load initrd=initrd.img devfs=nomount ks=nfs:[NFSサーバのIPアドレス]:/kickstart/ksconfig
6)DHCPサーバの設定
ネットワークアドレス:172.17.0.0/16
デフォルトゲートウェイ:172.17.0.1
Kickstart(PXE)サーバ兼DHCPサーバ兼NFSサーバ:172.17.0.254
とした場合の記載例。
vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 172.17.0.0 netmask 255.255.0.0 {
# --- default gateway
option routers [ルータのIPアドレス(デフォルトゲートウェイ)];
option subnet-mask 255.255.0.0;
#option nis-domain "domain.org";
#option domain-name "domain.org";
option domain-name-servers 8.8.8.8;
option time-offset -18000; # Eastern Standard Time
filename "pxelinux.0";
next-server 172.17.0.254;
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 172.17.1.0 172.17.1.253;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
# host ns {
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
# }
}
7)Kickstartコンフィグの作成
cp /root/anaconda-ks.cfg /kickstart/ksconfig
vi /kickstart/ksconfig
# Kickstart file automatically generated by anaconda.
install
#cdrom
nfs --server=172.17.0.254 --dir=/kickstart/isos
lang ja_JP.UTF-8
keyboard jp106
#network --device eth0 --bootproto static --ip 172.17.0.254 --netmask 255.255.0.0 --gateway 172.17.0.1 --nameserver 8.8.8.8,8.8.4.4 --hostname dhcp01
network --device eth0 --bootproto=dhcp --hostname localhsot
rootpw --iscrypted ******** ←実際はハッシュになってる。自分で書く必要なし
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Tokyo
bootloader --location=mbr --driveorder=sda
text
reboot
#clearpart --drives=sda --all --initlabel --linux
#clearpart --drives=sda --all --initlabel
#zerombr
clearpart --linux --drives=sda --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part / --fstype ext3 --size=10000 --ondisk=sda --grow
part swap --size=2048 --ondisk=sda
# 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 --all --drives=sda
#part /boot --fstype ext3 --size=100 --ondisk=sda
#part pv.2 --size=0 --grow --ondisk=sda
#volgroup VolGroup00 --pesize=32768 pv.2
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=4000
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
%packages
@base
@core
@development-tools
@japanese-support
@x-software-development
iscsi-initiator-utils
fipscheck
device-mapper-multipath
sgpio
imake
mesa-libGLU-devel
一番苦戦したのはここです。
clearpart --linux --drives=sda --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part / --fstype ext3 --size=10000 --ondisk=sda --grow
part swap --size=2048 --ondisk=sda
clearpartは結構細かく設定してあげないとインストールが途中で止まります。
仮想マシンへのOSインストールなので、ディスクがアンフォーマット状態だからです。
あと自動でパーティショニングさせるのもうまくいかなかったので
決め打ちでパーティショニングするようにpartを細かく書いています。
ここらへんは再考の余地がありそうです。
8)NFS設定
vi /etc/exports
/kickstart *
9)サービス無効化とか再起動とか
/etc/init.d/iptables stop
chkconfig iptables off
setenforce 0
/etc/init.d/dhcpd restart
/etc/init.d/xinetd restart
/etc/init.d/nfs restart
これで、ESXiとか使って空の仮想マシンを作成して
起動してPXEブートして自動でインストールできればおk。
なんか忘れてる気がするけれど、思い出したら修正しときます。
※参考URL
手順のベースになったサイト
http://blog.layer8.sh/ja/2011/12/21/pxe%E3%83%8D%E3%83%83%E3%83%88%E3%83%AF%E3%83%BC%E3%82%AF%E3%83%96%E3%83%BC%E3%83%88%E3%81%A7centos%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%ABkickstart%E3%81%AB%E3%82%88%E3%82%8B/
Kickstartのconfigを書くときに参考にしたサイト。オプションの説明が細かく書いてある。
https://access.redhat.com/site/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
partで苦戦してるときに参考にしたサイト。なんか見覚えのある名前です。
http://mikeda.jp/wiki/linux:%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E8%87%AA%E5%8B%95%E5%8C%96:kickstart
本日の作業では@kometchtechさんに大変お世話になりました。
ありがとうございました。