USBメモリを使ったインストールをpreseedingである程度自動化(昔書いたやつをまとめて転記)

この記事はUbuntu 18.04では使えない。preseed.txtをUSBメモリに書き込めないから。回避策を探している。

インストール作業環境・モチベーション

  • コンピュータの素人がコンピュータクラスタを管理している。Ubuntuのインストールが仕事の中心ではない。
  • たくさんのインストール作業を行うわけではない。数ヶ月に一度、例えば10台程度。
  • コンピュータの横にいて様子を見ながら作業する。
  • インストール中に本を読んだりしたいので、Ubuntuのインストールで、途中での入力作業を減らしたい。

参考にしたサイト

一般

preseedingの設定ファイル

preseedingのブートオプション

ssh-serverのrootログインの設定

d-i preseed/late_command string \
    in-target sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config

手順

Ubuntu 14.04.1 server 64bit環境でテストしました。手持ちのコンピュータではUbuntu (14.04.2|14.04.3) server 64bitではそもそもUSBメモリをブート可能なデバイスとして認識しなかった。

  1. preseedingの設定をpreseed.cfgなどに保存し、ubuntuのUSBインストーラのトップディレクトリに置く。
  2. USBメモリを挿して、電源ON
  3. ブートの選択画面で、ESC,F6,ESCとキーボードを叩き、ブートオプションを書き込める状態にする。
  4. 次の文字列を加え、リターンキーを叩いて起動する。
 priority=critical locale=en_US file=/cdrom/preseed.cfg

preseedingの設定ファイルに間違いがあり途中でインストールがこけた場合は、手動でのインストールに切りかわる。

HDD(/dev/sdaなど)にすでにパーティションがあってマウントされてしまう場合

テストしてないけどメモを残す。

d-i preseed/early_command string umount /media || true

preseed.cfg

Ubuntu 14.04の時のもの。

boot option

ESC --> F6 --> ESC のあと、次の文字列を追加する。

priority=critical locale=en_US file=/cdrom/preseed.cfg

preseed.cfg (https://help.ubuntu.com/lts/installation-guide/example-preseed.txt)

# https://help.ubuntu.com/lts/installation-guide/example-preseed.txt
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/splash boolean false
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
#d-i    preseed/early_command string killall.sh dhclient ; netcfg
d-i netcfg/choose_interface select auto
#d-i netcfg/dhcp_timeout string 30
# If you prefer to configure the network manually, uncomment this line and
# the static network configuration below.
#d-i netcfg/use_autoconfig boolean false 
#d-i netcfg/disable_autoconfig boolean true 
#d-i netcfg/disable_dhcp boolean true
#d-i netcfg/choose_interface select eth0
#d-i netcfg/disable_autoconfig boolean true
#d-i netcfg/dhcp_failed note
#d-i netcfg/dhcp_options select Configure network manually
#d-i netcfg/get_nameservers string 192.168.1.254
#d-i netcfg/get_ipaddress string 192.168.1.33
#d-i netcfg/get_netmask string 255.255.255.0
#d-i netcfg/get_gateway string 192.168.1.1
#d-i netcfg/confirm_static boolean true
d-i netcfg/get_hostname string hoge33
d-i netcfg/get_domain string localdomain

d-i mirror/http/mirror select jp.archive.ubuntu.com
d-i mirror/country string manual
d-i mirror/http/hostname string jp.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-lvm/confirm boolean true
d-i partman/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/default_filesystem string ext4
d-i clock-setup/utc boolean false
d-i time/zone string Japan
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
d-i base-installer/kernel/image string linux-generic
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password {MD5 hash}
d-i passwd/make-user boolean false
d-i user-setup/encrypt-home boolean false
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string security.ubuntu.com
d-i apt-setup/security_path string /ubuntu
d-i debian-installer/allow_unauthenticated string false
d-i pkgsel/upgrade  select safe-upgrade
d-i pkgsel/language-packs multiselect 
d-i pkgsel/update-policy select none
d-i pkgsel/updatedb boolean true
d-i grub-installer/skip boolean false
d-i lilo-installer/skip boolean false
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i finish-install/keep-consoles boolean false
d-i finish-install/reboot_in_progress note 
d-i cdrom-detect/eject boolean true
d-i debian-installer/exit/halt boolean false
d-i debian-installer/exit/poweroff boolean false
d-i pkgsel/include string openssh-server
d-i preseed/late_command string \
    in-target sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config