作業ログ源泉垂れ流し

しがないIT技術者の作業ログを垂れ流す

Debian bullseye (RC1)のインストール練習 2 〜自動インストール〜

自動インストールを試してみる。

まずは前回インストールしたシステムでpreseedファイルを取得する。
参考: https://www.debian.org/releases/testing/amd64/apbs03.en.html

# apt install debconf-utils
# echo "#_preseed_V1" > /tmp/kvm-preseed.cfg
# debconf-get-selections --installer >> /tmp/kvm-preseed.cfg
# debconf-get-selections >> /tmp/kvm-preseed.cfg 

Example preconfiguration fileをベースに、取得したpreseedファイルの内容をマージして preseed.cfg を作成

パスワードのハッシュは以下で取得

$ mkpasswd -m sha-512

編集後のpreseed.cfg

$ grep -v -e '^#' -e '^$' preseed.cfg
d-i debian-installer/language string en
d-i debian-installer/country string JP
d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string debian
d-i netcfg/get_domain string 
d-i netcfg/wireless_wep string
d-i mirror/country string JP
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i passwd/root-password-crypted password $秘密
d-i passwd/user-fullname string Debian User
d-i passwd/username string debian
d-i passwd/user-password-crypted password $秘密
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Tokyo
d-i clock-setup/ntp boolean true
d-i partman-auto/disk string /dev/vda
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 10 GB
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select multi
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
apt-cdrom-setup apt-setup/cdrom/set-failed boolean true
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
apt-cdrom-setup apt-setup/cdrom/set-double boolean true
apt-cdrom-setup apt-setup/cdrom/set-next boolean false
choose-mirror-bin mirror/http/mirror select deb.debian.org
tasksel tasksel/first multiselect standard, ssh-server
popularity-contest popularity-contest/participate boolean false
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev  string /dev/vda
d-i finish-install/reboot_in_progress note

前回作ったVMを消す。

$ virsh undefine bullseye
$ rm vda.img

再びvirt-installで今度は自動インストール

$ virt-install \
--name bullseye \
--memory 4096 --vcpus 1 \
--location $PWD/debian-bullseye-DI-rc1-amd64-netinst.iso \
--os-variant debiantesting \
--disk path=vda.img,size=16,format=qcow2 \
--network network=default \
--graphics none \
--serial pty --console pty \
--initrd-inject preseed.cfg \
--extra-args 'console=ttyS0,115200n8 serial'

なおauto=trueを設定しないのは、予期せぬ自動設定を防ぐため。 preseed.cfgが適切ならauto=trueなしでも自動インストールされるはず。

ちゃんと自動インストールできた!