CentOS7でkickstart

RHEL7が正式にリリースされてしばらく経ちCentOS 7がリリースされたので、CentOS 7でkickstart試した。

といっても、前にRHEL 7 RCの時にやってたのと同じ手順 で出来たので詳しくはそちらをどうぞ。

違うのはイメージのダウンロード先と、yumの設定してないのと、自前リポジトリのパスを変えた程度。

前回やったときに、kickstart時にnetwork設定が適用されなくて困ったちゃん!って問題があったけど、やはりというか以下で上がってた。
http://bugs.centos.org/view.php?id=7319&nbn=5

--device足りないよ・・・ってそんなことは知ってんだよ!でもインストール時にデバイス名とかMACアドレスとか分かるわけないだろ!!って話だったんだけども、--device=link とするとlink upしてるデバイスを選んでくれるらしい。NICはまだ1枚しかない環境だからこれで充分。

というわけで、最終的なks.cfgはこんななった。

cat << '__EOF__' | sudo -u nfsnobody tee /opt/centos/7/os/x86_64/kickstart/ks.cfg
text
install
nfs --server=10.1.255.253 --dir=/opt/centos/7/os/x86_64/

lang ja_JP.UTF-8
keyboard jp106
timezone Asia/Tokyo
rootpw --iscrypted {しゃー256(ぱすわーど)}
authconfig --enableshadow --passalgo=-sha256

bootloader --location=mbr --driveorder=sda

selinux --enforcing

clearpart --all
autopart

reboot

user --name=ryozi --groups=wheel --iscrypted --password={しゃー256(ぱすわーど)}

network --bootproto=static --device=link --gateway=10.1.255.254 --ip=10.1.1.240 --nameserver=10.1.255.254 --netmask=255.255.0.0 --ipv6=auto

%packages --nobase
@core
%end

__EOF__

%postにnetwork-scriptに依存したクッソ情けない設定しなくて済むのは精神衛生的に良い。


RHELのドキュメントも見てみたらちゃんと書いてあった。ちゃんとよめってこった・・・

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html#sect-kickstart-commands

The behavior of any subsequent network command in the same Kickstart file is unspecified if its --device= option is missing. Make sure you specify this option for any network command beyond the first.
You can specify a device to be activated in any of the following ways:

the device name of the interface, for example, em1
the MAC address of the interface, for example, 01:23:45:67:89:ab
the keyword link, which specifies the first interface with its link in the up state
the keyword bootif, which uses the MAC address that pxelinux set in the BOOTIF variable. Set IPAPPEND 2 in your pxelinux.cfg file to have pxelinux set the BOOTIF variable.

追記(7/17)

通勤中にks.cfgのnetworkの--ipの設定がDHCPで割り振られる範囲(10.1.255.1〜で設定してた)だった事に気づいて、変えて検証した。

変更前

network --bootproto=static --device=link --gateway=10.1.255.254 --ip=10.1.255.1 --nameserver=10.1.255.254 --netmask=255.255.0.0 --ipv6=auto --activate

変更後

network --bootproto=static --device=link --gateway=10.1.255.254 --ip=10.1.1.240 --nameserver=10.1.255.254 --netmask=255.255.0.0 --ipv6=auto
  • --ip修正(DHCPの範囲にかぶらないようにした)
  • --activeteを削除(起動時に繋ぐ(アクティブにする)設定だと思ってつけてた。アクティベートだよバカ。)

うまくいったので、こっそり修正...

--activateがあるとうまくいかない。なんで前回うまくいったのかは不明。DHCPで割り当てたIPと設定したいIPが被ったからかなー。