LoginSignup
9
13

More than 5 years have passed since last update.

Linux自動インストール = Kickstart

Posted at

Kiskstartファイル ks.cfg

Kickstartでは自動インストールのレシピをファイル化しそれをLinuxインストール時に読み込ませて自動インストール実施します。
Kickstartファイルはあちこちでサンプルが落ちていますが、前回CentOSをインストールした時にその記録が /root/anaconda-ks.cfg に保存されています。これがKickstartファイルとして利用できます。こんな感じです。

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
url --url=http://ftp.riken.jp/Linux/centos/6.5/os/x86_64/
lang en_US.UTF-8
keyboard jp106
network --onboot yes --device eth0 --bootproto dhcp --noipv6
network --onboot no --device eth1 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$xMBrykBveErIkSvJ$CX1l27S1.jpV7kGs9RtcMgrjchmhQ4PVApun5B/w/WEDQtTkRxDsyl/KcpwZtIG7JYwuEp3Rtj2k06rXjnwhc0
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Tokyo
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto 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 --drives=sda
#volgroup VolGroup --pesize=4096 pv.008002
#logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
#logvol swap --name=lv_swap --vgname=VolGroup --grow --size=819 --maxsize=819

#part /boot --fstype=ext4 --size=500
#part pv.008002 --grow --size=1


repo --name="CentOS"  --baseurl=http://ftp.riken.jp/Linux/centos/6.5/os/x86_64/ --cost=100

%packages --nobase
@core
%end
  1. eth1がonboot no になってますね。これを yes にすればいい感じになりそう
  2. selinux --enforcing ってなってるからこれを --disabled にしたらいい感じになりそう。
  3. firewallってのはiptablesのデフォルト設定みたいです。 などなど、色々なオプションはRedHadのドキュメント - https://access.redhat.com/site/documentation/ja-JP/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-kickstart2-options.html に記載されています。

まずはKickstartを試してみることを再優先にすべくあまり編集せずに以下の3行だけ変更

network --onboot yes --device eth1 --bootproto dhcp --noipv6
firewall --disabled
selinux --disabled

このファイルをLinuxインストール時にしているんですが、どうやって読み込ませるのか色いろあるんですが(FDDやCDROMからとか)、ネットワーク越しでHTTPダウンロードさせるのが楽で慣例っぽいのでそれにする。HTTPサーバは母艦にhttpdたてるのもよし、外部のサーバからダウンロードさせるもよし、今回はGitHubに保存してそこからダウンロードさせることにします。

Kiskstart での自動インストール

VirtualBoxで新規OSをエントリーするところまでは同じ。(CentOS.isoを指定したり、ホストオンリーアダプターアダプタの追加も忘れずに)
インストールCD-ROM起動直後のメニューで「esc」を押します。boot: プロンプトが出るので

> linux text ks=https://raw.githubusercontent.com/hiyuzawa/centos_install/master/anaconda-ks.cfg

として起動します。
...
...
と思ったらなぜか、「Error downloading kickstart file」って言われた。。
ホストPCにhttpd立ち上げて http://192.168.56.1/anaconda-ks.cfg だとうまくいった。(http://localhost/にしててハマった)

若干対話的な選択が残るもののおおかた自動でインストールされた。

9
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
13