preseed.cfgの作成はまだまだかかるかなあと思ってたんだけど、オープンなソースな参考サイトを見つけたので一気にほぼ完成の域にまで進みました。
ほとんど自動でやってくれるようにまでなってます。
今回は中身を公開してくれていてかなり助かったので、OSSでいこうと思います。
(いままでもそうですけどw)
参考サイトはUbuntuなので、Debianの資料を見ていると削れるところが絶対あると思いますが・・・、まあとりあえず差分を変えていくということで今のバージョンを載せて進めたいと思います。
とするとGITを使うのが都合もいいんだろうなあとも思うけど、ひとまず日記に内に載せとくことにしま。
# cat /var/www/html/ks/preseed.cfg
#===========================================================================================
# BOOT SEQUENCE CONFIGURATIONS START
# ENDの設定のところまではDVDメディア、USBメディアに同梱している場合にのみ有効になる設定。
# PXEブートの場合はこのセクションは無視される。
# この場合はpxelinuxのconfigのappendに直接記述する必要がある。
#===========================================================================================
d-i debian-installer/language string ja
d-i debian-installer/country string japan
d-i debian-installer/locale string ja_JP.UTF-8
d-i localechooser/supported-locales ja_JP.UTF-8
d-i console-setup/ask_detect boolean true
d-i console-setup/layoutcode string jp
d-i console-setup/charmap select UTF-8
# キーボードレイアウトの特性の設定(日本語キーボード)
d-i console-keymaps-at/keymap select jp
d-i keyboard-configuration/layoutcode string jp
d-i keyboard-configuration/modelcode jp106
#===========================================================================================
# ネットワークまわりの設定
#-------------------------------------------------------------------------------------------
# 静的IP
#-------------------------------------------------------------------------------------------
# preseed.cfgを外から持ってこようとするとどうしてもいったんDHCP解決しないといけない。
# そして以下の netcfg 項目は一回目は無視されるので d-i preseed/run のところで
# ネットワーク設定をリセットするハックが必要になる。
# そうすると静的IPとして設定を直してくれるようになる。
#
# 詳しくは以下:
# - https://help.ubuntu.com/lts/installation-guide/i386/preseed-contents.html
# - http://debian.2.n7.nabble.com/Bug-688273-Preseed-netcfg-use-autoconfig-and-netcfg-disable-dhcp-doesn-t-work-td1910023.html
#
# 以下の2項目を設定しないと静的IPとして処理されないので重要
d-i netcfg/use_autoconfig boolean true
#d-i netcfg/disable_autoconfig boolean false
#d-i netcfg/choose_interface select eth0
#d-i netcfg/disable_dhcp boolean true
#d-i netcfg/get_nameservers string 8.8.8.8
#d-i netcfg/get_ipaddress string 192.168.24.65
#d-i netcfg/get_netmask string 255.255.255.0
#d-i netcfg/get_gateway string 192.168.24.1
#d-i netcfg/confirm_static boolean true
#d-i netcfg/get_hostname string take
#d-i netcfg/get_domain string
#d-i netcfg/wireless_wep string
#-------------------------------------------------------------------------------------------
# DHCPのとき
#-------------------------------------------------------------------------------------------
d-i netcfg/choose_interface select eth0
d-i netcfg/disable_autoconfig boolean false
d-i netcfg/get_hostname string take
d-i netcfg/get_domain string
d-i netcfg/wireless_wep string
# いったんリセット
#d-i preseed/run string http://gist.github.com/wnoguchi/6578034/raw/prescript.sh
#===========================================================================================
# BOOT SEQUENCE CONFIGURATIONS END
#===========================================================================================
# インストーラパッケージをダウンロードするミラーを選択する
#d-i mirror/protocol http
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.jp.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
# インストールするスイートを選択
#d-i mirror/suite precise
#d-i clock-setup/utc boolean false
d-i time/zone string Japan
#d-i clock-setup/ntp boolean false
#===========================================================================================
# PARTMAN PARTITIONING SECTION START
#===========================================================================================
# すべてのRAIDデバイス構成を破棄する
d-i partman-md/device_remove_md boolean true
# すべてのLVMデバイス構成を破棄する
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string root :: 19000 50 50000 ext4 \
$primary{ } $bootable{ } method{ format } \
format{ } use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
16384 90 32768 linux-swap \
$primary{ } method{ swap } format{ } \
. \
100 100 10000000000 ext3 \
$primary{ } method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /srv/extra } \
.
d-i partman-auto/choose_recipe select root
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
#===========================================================================================
# PARTMAN PARTITIONING SECTION END
#===========================================================================================
d-i base-installer/install-recommends boolean true
d-i base-installer/kernel/image string linux-generic
d-i passwd/root-login boolean true
d-i passwd/make-user boolean true
d-i passwd/root-password password takeken
d-i passwd/root-password-again password takeken
d-i passwd/user-fullname string takeken
d-i passwd/username string takeken
d-i passwd/user-password password takeken
d-i passwd/user-password-again password takeken
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean true
d-i apt-setup/use_mirror boolean true
d-i debian-installer/allow_unauthenticated boolean true
tasksel tasksel/first multiselect desktop
d-i pkgsel/include string openssh-server build-essential
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
d-i pkgsel/install-language-support boolean true
popularity-contest popularity-contest/participate boolean false
d-i pkgsel/updatedb boolean true
# GRUBインストーラー
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string /dev/sda
# インストールが終了したらサーバー再起動
d-i finish-install/reboot_in_progress noteCentOSはks.cfg作成用のツールがあるからあんまり不要な気もするけど、一応公開。
# cat /var/www/html/ks/ks.cfg #platform=x86, AMD64, 又は Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="http://192.168.24.62/CENTOS62-x86_64" # Root password rootpw --iscrypted $1$AILz91Wr$NzxYVo0/nKGvv4DBSZOV70 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical # System keyboard keyboard jp106 # System language lang ja_JP # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Asia/Tokyo # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part swap --fstype="swap" --size=1 part / --fstype="ext4" --grow --size=1
ブートファイルはこんな感じ。
# cat /var/lib/tftpboot/boot.msg ==================================== Welcome to kickstart installer ==================================== 1. CentOS 6 AUTO 2. debian 7 Manual 3. debian 7 AUTO test
# cat /var/lib/tftpboot/pxelinux.cfg/default prompt 1 display boot.msg label 1 kernel /CENTOS62-x86_64/vmlinuz append auto=true ks=http://192.168.24.62/ks/ks.cfg initrd=/CENTOS62-x86_64/initrd.img locale=ja_JP.UTF8 console-keymaps-at/keymap=jp106 label 2 kernel debian-installer/amd64/linux append initrd=debian-installer/amd64/initrd.gz locale=ja_JP.UTF8 console-keymaps-at/keymap=jp106 label 3 kernel debian-installer/amd64/linux append auto preseed/url=http://192.168.24.62/ks/preseed.cfg initrd=debian-installer/amd64/initrd.gz locale=ja_JP.UTF8 console-keymaps-at/keymap=jp106
今回のはなかなか勉強になったなあ。
参考サイト
Qiita
PreseedによるUbuntuの自動インストール入門
momoto.github.io
Debian 7.1.0をインストールする
ユニキャストラボ
PreseedによるUbuntuの自動インストール入門
50ply.com
Automating Debian Installs With Preseed and Puppet
http://www.debian.org
B.4. 事前設定ファイルの内容 (wheezy 用)