キックスタート構築方法

キックスタート構成図

f:id:ando_ando_ando:20101005233810j:image

TFTP-SERVERの構築


  • インストール方法



yum install tftp-server


  • 起動の有効化 /etc/xinetd.d/tftpの編集


#######################################################################
# <変更内容> disable = yesからdisable = noしてtftpを有効にしました。
#######################################################################

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}


  • tftp-serverの起動


/etc/init.d/xinetd start

PXEブート環境の構築


  • PXEブート用のOS準備



cd /tftpboot
mkdir install
cd /install
cp /usr/lib/syslinux/pxelinux.0 .


  • 起動イメージを適当なミラーサーバからダウンロード



cd /tftpboot/install
mkdir centos5.4
cd centos5.4
wget -P /tftpboot/install/centos_5.4/ http://ftp.iij.ad.jp/pub/linux/centos/5.4/os/i386/images/pxeboot/initrd.img
wget -P /tftpboot/install/centos_5.4/ http://ftp.iij.ad.jp/pub/linux/centos/5.4/os/i386/images/pxeboot/vmlinuz


  • PXEブート用のOSファイルの構成



/tftpboot/
`-- install
|-- boot.msg
|-- centos_5.3
| |-- initrd.img
| `-- vmlinuz
|-- centos_5.4
| |-- initrd.img
| `-- vmlinuz
|-- general.msg
|-- options.msg
|-- param.msg
|-- pxelinux.0
|-- pxelinux.cfg
| |-- default
| `-- default.first
|-- pxelinux.cfg.5.4
| |-- default
| `-- default.first
`-- rescue.msg

DHCPサーバの構築


  • インストール方法



yum install dhcp


  • etc/dhcpd.confの編集



vi /etc/dhcpd.conf


##################################################################
# ファイル名 : dhcpd.conf
# ファイル説明 : DHCPの設定ファイル
# 変更履歴
# <バージョン> <変更日(YYYY/MM/DD)> <変更者> <変更内容>
# 1.0 2010/04/05 Ando 新規作成
# 1.1 2010/04/07 Ando IP変更
# 1.2 2010/04/08 Ando コメント追加
##################################################################

ddns-update-style interim;
ignore client-updates;

subnet 192.168.23.0 netmask 255.255.255.0 {

# --- default gateway
# option routers 192.168.21.254;
option subnet-mask 255.255.255.0;

#option nis-domain "domain.org";
#option domain-name "domain.org";
# option domain-name-servers 192.168.17.62;

option time-offset -18000; # Eastern Standard Time
# 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 :IPアドレスの割り振る範囲
# default-lease-time :標準の IP 貸し出し時間
# max-lease-time :最大の IP 貸し出し時間
###########################################################
range dynamic-bootp 192.168.23.80 192.168.23.150;
default-lease-time 21600;
max-lease-time 43200;

#  allow booting;
# allow bootp;



class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
filename "/install/pxelinux.0";
###########################################################
# DHCP サーバの IP アドレス
###########################################################
next-server 192.168.23.1;
}
}


※next-serverを指定しないと、DELLpoweredge製品だと、キックスタートが動かなかった。

  • DHCPサーバの起動



/etc/init.d/dhcpd start

NFSの構築


  • OSのイメージファイルの作成方法



cd /misc
mkdir kickstart
cd kickstart
mkdir centos-5.4
mount -t iso9660 -o loop /tmp/CentOS-5.4-i386-bin-DVD.iso /mnt/
cp -Rp /mnt/* /misc/kickstart/centos-5.4/
umount /mnt/


  • portmapの起動方法


/etc/init.d/portmap start

※「portmap」がインストールされていない場合は以下のコマンドでインストールして下さい
yum -y install portmap


※portmapの時の注意点
Portmapを起動する前に、nfsを起動すると以下のエラーメッセージが出力されます。portmap起動後に、nfsを起動するように注意して下さい。

# /etc/rc.d/init.d/nfs start
NFS サービスを起動中: [ OK ]
NFS クォータを起動中: サービスを登録できません: RPC: 受け取れません; errno = 接続を拒否されました
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[失敗]
NFS デーモンを起動中: [失敗]
NFS mountd を起動中: Cannot register service: RPC: Unable to receive; errno = Connection refused
[失敗]
RPC idmapd を起動中: [ OK ]


  • NFSの設定ファイルの編集



vi /etc/exports
/misc *(ro,no_root_squash)



/etc/init.d/nfslock start
/etc/init.d/nfs start


  • OSのイメージファイルのマウント



mount -t nfs localhost:/misc/ /mnt/
umount /mnt/

Kickstart ファイル(ks.cfg)の編集



  • ディレクトリに移動



cd /misc/kickstart/centos-5.4


  • Kickstartの編集



# Kickstart file automatically generated by anaconda.
##################################################################
# ファイル名 : ks.cfg
# ファイル説明 : キックスタート ファイル
# 用途 : Ando-Server
# OS : CentOs-5.4
# 変更履歴
# <バージョン> <変更日(YYYY/MM/DD)> <変更者> <変更内容>
# 1.0 2010/04/13 Ando 新規作成
# 1.1 2010/04/16 Ando Andoユーザ作成・シェルコマンド追加
# 1.2 2010/05/12 Ando OSの種類を追加
# 1.3 2010/05/14 Ando 停止するサービスを追加
##################################################################


##############################################
# テキストベースのインストールプログラムで起動
############################################
text

##############################
# インストール方法の選択
# 例:cdrom
# nfs --server name/ip --dir directory
##############################
nfs --server=192.168.23.1 --dir=/misc/kickstart/centos-5.4

##############################
# システムのデフォルト言語
##############################
lang ja_JP.eucJP

##############################
# 使用するキーボードのタイプ
##############################
keyboard jp106

##############################
# ネットワーク設定
##############################
network --device eth0 --bootproto dhcp

####################################################
# ルートパスワード
# Ando作成
# --name=<ユーザ名>
# --groups=<グループ名リスト>
# --homedir=<ホームディレクトリ>
# --password=<パスワード文字列> 「--iscrypted」オプションを併用すると暗号化文字列
######################################################
rootpw --iscrypted $Ando
user --name=Ando --groups=Ando --homedir=/home/Ando --iscrypted --password=$Ando/

##############################
# ファイヤーウォール
# 設定をdisabledにする
##############################
firewall --disabled

##############################
# 認証方式
##############################
authconfig --enableshadow --enablemd5

##############################
# セキュリティ
# disabledにする
##############################
#selinux --enforcing
selinux --disabled

##############################
# タイムゾーンの指定
##############################
timezone --utc Asia/Tokyo

##############################
# ブートローダ指定
##############################
bootloader --location=mbr --driveorder=cciss/c0d0

##############################
# パーティションの削除
##############################
clearpart --all

##############################
# パーティションの作成
##############################

##############################
#bootファイル --asprimary プライマリパーティション
##############################
part /boot --fstype ext3 --size=100 --asprimary

##############################
#swapファイル
##############################
part swap --size=2048

##############################
#/
##############################
part / --fstype ext3 --size=1 --grow

##############################
# パッケージの選択
# GUI機能を追加
##############################
%packages
@development-libs
@editors
@system-tools
@japanese-support
@text-internet
@x-software-development
@gnome-desktop
@core
@base
@base-x
@graphics
@sound-and-video
@development-tools
@graphical-internet
festival
audit
sysstat
mesa-libGLU-devel
device-mapper-multipath
xorg-x11-server-Xnest
libsane-hpaio
imake
-db4-devel
-python-devel
-coolkey-devel
-boost-devel
-dbus-devel
-gdbm-devel
-expat-devel
-libvorbis-devel
-nmap
-bluez-hcidump
-bluez-gnome
-apmd
-vconfig
-mdadm
-ibmasm
-rsh
-ipsec-tools
-rp-pppoe
-irda-utils
-jwhois
-bluez-utils
-ltrace
-diffstat
-valgrind
-systemtap
-subversion
-texinfo
-byacc
-gcc-gfortran
-pfmon
-rcs
-automake16
-automake17
-automake14
-automake15
-ctags
-dogtail
-swig
-dev86
-doxygen
-indent
-pstack
-oprofile
-cscope

###############################
# インストール後のシェルコマンド
###############################
%post
###############################
# Andoの作業ディレクトリ作成
###############################
cd /home/Ando
mkdir tmp work src
chown Ando:Ando *

###############################
# 停止するサービス
###############################
chkconfig acpid off
chkconfig apmd off
chkconfig atd off
chkconfig autofs off
chkconfig cups off
chkconfig gpm off
chkconfig ip6tables off
chkconfig netfs off
chkconfig nfslock off
chkconfig portmap off
#chkconfig rhnsd off #CentOSにはない。理由はRPMパッケージのupdate機能ため。
chkconfig sendmail off
chkconfig smartd off
chkconfig xfs off
chkconfig yum-updatesd off

###############################
# 不要な起動プロセスの排除
###############################
cd /etc/rc3.d
rm -f S13portmap S14nfslock S25netfs S26apmd S28autofs S26acpid S56cups S56rawdevices S80sendmail S90xfs S95atd S08iptables S85gpm K24irda S25bluetooth
cd /etc/rc6.d
rm -f K10xfs K10cups K15gpm K24irda K30sendmail K74acpid K74apmd K75netfs K90bluetooth