preseed を利用したインストールの自動化 本付録は preseed の方法を説明します。 これは &d-i; の質問に回答しておきインストールを自動化するものです。 本付録で使用した設定の断片は、 &urlset-example-preseed; にある事前設定ファイルのサンプルで利用できます。 はじめに preseed は、インストールの実行中に手動で回答を入力せずに、 インストールプロセス中の質問の答を設定する方法を提供します。 これにより、ほとんどの方法のインストールを自動化し、 さらに通常のインストールでは利用できない特徴もあります。 preseed の方法 preseed を利用するには、 initrd, ファイル, ネットワーク と 3 種類の方法があります。 initrd preseed は、いずれのインストール方法でも動作し、 より多くの preseed をサポートしますが、大量の準備が必要です。 ファイル preseed やネットワーク preseed は、 それぞれインストール方法が異なる場合に使用されます。 以下の表では、各インストール方法で使用できる preseed 方法を示します。 インストール方法initrd ファイルネットワーク CD/DVD yes yes yes ネットワークアクセスを行う場合だけでなく、 適切な preseed/url を設定する場合。 netboot yes no yes hd-media (USB スティックを含む) yes yes yes フロッピーベース (CD ドライバ) yes yes yes フロッピーベース (ネットドライバ) yes no yes generic/tape yes no yes preseed 方法の重要な違いは、事前設定ファイルを読込・処理するポイントです。 initrd preseed では、インストールの始め (最初の質問が行われる前) に読み込まれます。 ファイル preseed では、CD や CD イメージが読み込まれた後です。 ネットワーク preseed では、ネットワークの設定の後でないと読み込まれません。 言うまでもなく、事前設定ファイルが読み込まれる前に処理される質問は、 preseed できません。 (最初のハードウェア検出のように、 優先度が中や低でしか表示されない質問も含んでいます) では、 そういった質問が出ないようにする方法を提供しています。 preseed が起動する前に、通常現れる質問を回避するのに、 自動 モードでインストーラを起動できます。 これによりネットワークの設定が終わるまで、preseed の前に行われる質問 (言語、国、キーボード選択など) を遅らせ、preseed にその質問を含められます。 また、インストールの優先度を最重要で行うため、 大量にある重要でない質問を回避できます。 詳細は をご覧ください。 制限 &d-i; で行われる質問のほとんどはこの方法で preseed できますが、 いくつか注目すべき例外があります。 ディスク全体を (再度) パーティション分割するか、 ディスクの空き領域を利用しなければなりません。 つまり既存のパーティションを利用できないと言うことです。 preseed の利用 事前設定ファイルを最初に作成し、使用する場所に配置する必要があります。 事前設定ファイルの作成は本付録で後ほど扱います。 ネットワーク preseed の場合や、 ファイルをフロッピーや USB スティックから読み込む場合、 簡単に正しい位置に事前設定ファイルを配置できます。 CD や DVD にファイルを含めたければ、 ISO イメージを再度マスタリングする必要があります。 initrd に含まれている事前設定ファイルを取り出す方法は、 この文書では扱いません。&d-i; の開発者向け文書を当たってください。 事前設定ファイルの手本にできる事前設定ファイルのサンプルは、 &urlset-example-preseed; から取得できます。 このファイルは、この付録にある設定の断片を元にしています。 事前設定ファイルの読み込み initrd preseed を使用する場合、preseed.cfg というファイルが initrd のルートディレクトリに確実にある必要があります。 インストーラは、このファイルがあるか自動的にチェックし、読み込みます。 他の preseed 方法では、ブート時にどのファイルを読み込むか、 インストーラに指定する必要があります。 通常、カーネルのブートパラメータで渡して行います。 これは起動時に手動で与えるか、 ブートローダ設定ファイル (例: syslinux.cfg) を編集し、 カーネルへの append 行の最後にパラメータを追加して与えます。 ブートローダの設定で事前設定ファイルを指定する場合、 設定を変更すれば、インストーラの起動時に ENTER を押す必要はありません。 syslinux ではこの設定をするのに、 syslinux.cfg でタイムアウトを 1 にします。 インストーラが確実に正しい事前設定ファイルを取得するのに、 このファイルのチェックサムを指定できます。 現在、これには md5sum 値の指定が必要です。 指定した値と事前設定ファイルの値は一致しなければなりません。 一致しない場合は、インストーラは事前設定ファイルを使用しません。 ブートパラメータの設定: - netboot の場合: preseed/url=http://host/path/to/preseed.cfg preseed/url/checksum=5da499872becccfeda2c4872f9171c3d - リマスタリングした CD で起動する場合: preseed/file=/cdrom/preseed.cfg preseed/file/checksum=5da499872becccfeda2c4872f9171c3d - USB メディアで起動する場合 (事前設定ファイルを USB スティックの トップレベルディレクトリに置くこと): preseed/file=/hd-media/preseed.cfg preseed/file/checksum=5da499872becccfeda2c4872f9171c3d ブートパラメータに渡す際に、 preseed/urlurl に、 preseed/filefile に 短縮できることに注意してください。 preseed が質問するブートパラメータの利用 事前設定ファイルを preseed の各段階で使用できない場合でも、 preseed の値をインストーラ起動時のコマンドラインに与えることで、 インストールを自動で行えます。 preseed を使用せず指定した質問への答を設定したい場合にも、 ブートパラメータを使用します。 有用な使用法のサンプルが、このマニュアルの別の場所にあります。 &d-i; 内部で使用する値をセットするには、 path/to/variable=value のように本付録の例にある preseed 変数を渡すだけです。 値がターゲットシステムのパッケージを設定することがある場合、 owner debconf 変数 (やテンプレート) の所有者 (owner) は、 debconf テンプレートに含まれるように、通常パッケージ名です。 インストーラ自体が使用する値は、d-i になっています。 テンプレートや変数は、複数の owner を持て、パッケージを完全削除する際に debconf データベースから削除できるかどうかを決定するのに利用されます。 変数を、あらかじめ用意し、 owner:path/to/variable=value で使用する必要があります。 owner を指定しない場合、 変数の値はターゲットシステムの debconf データベースにコピーされず、 関連パッケージの設定中使用されません。 ブートプロンプトによく使用される変数には、 短いエイリアスがあることに注意してください。 有効なエイリアスは、本サンプル内で完全な変数名の代わりに使用しています。 特に、preseed/url 変数には url というエイリアスがあり、短い URL が使えることによる技がいくつかあります。 もう一つ、tasks というエイリアスがあり、 これは tasksel:tasksel/first に変換されます。 ブートオプションの -- は特別な意味を持ちます。 最後の -- に続きカーネルパラメータがあると、 (インストーラがサポートするブートローダの場合) インストール済みのブートローダの設定にコピーされます。 インストーラは、(事前設定オプションのような) オプションを認識すると、 自動的にフィルタをかけます。 現在の Linux カーネル (2.6.9 以降) では、 最大 (インストーラがデフォルトで指定するオプションを含め) コマンドラインオプションを 32 個、環境オプションを 32 個受け取れます。 この数を超えると、カーネルはパニック (クラッシュ) してしまいます。 (初期のカーネルではこの数字がもっと少ないです) ほとんどのインストールでは、ブートローダ設定ファイルにある (vga=normal のような) デフォルトオプションを安全に削除できるかもしれません。 これにより preseed 用にもっとオプションを追加できます。 ブートパラメータに空白を含んだ値を設定するのは、 引用符で囲んだとしてもいつもうまくいくとは限りません。 自動モード かなりシンプルなコマンドラインをブートプロンプトに与え、 任意の複雑なカスタマイズを自動インストールに対して行う Debian Installer の機能があります。 これを説明するため、以下にブートプロンプトで使用できる例を示します。 auto url=autoserver これは、DNS で autoserver の名前解決ができ (おそらく DHCP でローカルドメイン追加後)、 そのマシンが DHCP サーバであることを前提にしています。 example.com というドメインのサイトが、 普通のまともな DHCP を設定していれば、 http://autoserver.example.com/d-i/etch/./preseed.cfg から、preseed ファイルを取得するようになります。 URL (d-i/etch/./preseed.cfg) の最後の部分は、 auto-install/defaultroot から取られています。 デフォルトでは、将来のバージョンでコードネームを指定して移行していけるように、 etch ディレクトリが含まれています。 /./ は、その後に続くパスが確定するように、 ルートからの相対パスを示します (preseed/include や preseed/run で使用)。 これにより、完全な URLや / で始まるパス、 前回 preseed が見つかった場所からの相対パスでファイルを指定できます。 スクリプトの階層構造を壊さずに新しい場所に移動できる (例えば ウェブサーバで開始し、USB スティックにコピーする)、 よりポータブルなスクリプトを構成するのに便利です。 このサンプルでは、preseed ファイルの preseed/run/scripts/late_command.sh が設定されている場合、 http://autoserver.example.com/d-i/etch/./scripts/late_command.sh からファイルを取得します。 手元に DHCP や DNS のインフラがない場合や、 preseed.cfg のデフォルトパスを使用したくない場合でも、 きちんとした URL を使用でき、/./ 要素を使用しない場合は、 パスの開始点を決定できます (例えば URL の 3 つ目の /)。 以下は、手元のネットワークインフラから最低限必要な物のサンプルです。 auto url=http://192.168.1.2/path/to/mypreseed.file この方法は次のように動作します。 URL が見つからない場合、http だと仮定します。 ホスト名セクションにピリオドがなければ、DHCP から引き出して追加します。 ホスト名の後に / がなければ、デフォルトパスを追加します。 URL を指定するのに加えて、 &d-i; 自身の振る舞いには直接影響しない設定も追加できますが、 読み込んだ preseed ファイルの preseed/run で指定した、 スクリプトに渡すことができます。 現在のところ、classes というエイリアスを持つ、 auto-install/classes のサンプルのみです。 以下のように使用します。 auto url=example.com classes=class_A;class_B classes にはこのサンプルでは、インストールするシステムのタイプや、 地域化を指定するのに使用できます。 この概念はもちろん拡張でき、もしそうする場合、 auto-install 名前空間を使用するのが妥当です。 ですから、次にあなたのスクリプトで使用する auto-install/style のような物かもしれません。 これが必要だと思うのなら、名前空間の衝突を避けるために debian-boot@lists.debian.org メーリングリストで提案してください。 おそらくパラメータのエイリアスが追加されます。 auto ブートラベルは、 どのアーキテクチャでもまだ定義されていません。 カーネルのコマンドラインに、単にパラメータを 2 つ auto=true priority=critical を追加すると、 同じ効果を得られます。 auto パラメータは auto-install/enabled のエイリアスで、ロケールやキーボードの質問を preseed で行えるよう遅らせます。 また、prioritypreseed/priority のエイリアスで、critical に設定すると、 優先度の低い質問を抑制するようになります。 DHCP を使用してインストールの自動化を行う際に、 関連する追加オプションは以下の通りです。interface=auto netcfg/dhcp_timeout=60 これはマシンが最初の使用可能 NIC を選択し、 DHCP 問い合わせに対する返答をもっと我慢強く待つようになります。 preseed で利用できるエイリアス 以下のエイリアスが (自動モード) preseed を使用する際に利用できます。 autoauto-install/enabled classesauto-install/classes fbdebian-installer/framebuffer localedebian-installer/locale prioritydebconf/priority filepreseed/file urlpreseed/url interfacenetcfg/choose_interface hostname   netcfg/get_hostname domainnetcfg/get_domain protocolmirror/protocol suitemirror/suite 事前設定ファイルを指定するための DHCP の利用方法 事前設定ファイルをネットワークからダウンロードするよう指定するのに、 DHCP も使用できます。DHCP はファイル名の指定ができます。 通常これは netboot のファイルですが、URL 形式になっていると、 ネットワーク preseed をサポートするインストールメディアが、 URL からファイルをダウンロードし、事前設定ファイルとして使用します。 以下は、ISC DHCP サーバのバージョン 3 用 dhcpd.conf で設定するサンプルです。 if substring (option vendor-class-identifier, 0, 3) = "d-i" { filename "http://host/preseed.cfg"; } 上記の例は、 "d-i" を名乗る DHCP クライアントにこのファイル名を渡すよう制限されており、 通常の DHCP クライアントではなく、 インストーラにのみ影響を与えることに注意してください。 この文字列で、ネットワーク上の全マシンに preseed でインストールするのではなく、 特定のホストに対して行うようにもできます。 DHCP preseed を使用するよい方法は、自分のネットワークには、 Debian ミラーサイトのような preseed の値のみ指定することです。 自分のネットワークにこの方法でインストールすると、 選択したよいミラーサイトから自動で取得しますが、 インストールの残りのプロセスはインタラクティブに行われます。 DHCP preseed を用いた Debian の完全自動インストールは、 十分注意しなければ行うべきではありません。 事前設定ファイルの作成 事前設定ファイルのフォーマットは、debconf-set-selections コマンドで使用されるものと同じです。 事前設定ファイルの行の一般的なフォーマットは以下のようになります。 <所有者> <質問名> <テンプレート型> <値> 事前設定ファイルを記述する際には、 ちょっとした規則があると気に留めておいてください 型と値の間には、空白かタブを 1 つだけおいてください。 空白を追加すると、値の一部として解釈されます。 行継続文字としてバックスラッシュ (\) を付けて複数行に分割できます。 質問名の後で分割するのが適当でしょう。 型と値の間はよくありません。 ほとんどの質問では、訳した値ではなく英語の値を指定する必要がありますが、 (partman など) 訳した値を使用できる質問もあります。 質問の中には、インストール中に表示される英語のテキストの代わりに、 コードを取るものがあります。 事前設定ファイルを作成する簡単な方法は、 にあるサンプルファイルを元にして作業することです。 その他には、手動インストールを行い、再起動してから debconf-utils パッケージの debconf-get-selections を使用します。 以下のように debconf データベースとインストーラの cdebconf データベースを 1 ファイルに出力してください。 $ debconf-get-selections --installer > file $ debconf-get-selections >> file しかし、この方法で生成したファイルでは preseed されない項目があります。 ほとんどのユーザはサンプルファイルから始めるのがよいでしょう。 この方法は、インストーラの cdebconf データベースが、 インストールしたシステムの /var/log/installer/cdebconf に保存されているのを前提にしています。 しかし、データベースに機密情報が含まれる可能性がありますので、 デフォルトでは root にのみ読み込みが許可されています。 /var/log/installer ディレクトリとその中のファイルは、 installation-report パッケージを完全削除することで、 削除されます。 有効な質問の値をチェックするのに、 インストール中に /var/lib/cdebconf のファイルを、 nano を使用して確認できます。 生のテンプレートは templates.dat を、 現在の値や変数に割り当てられた値は questions.dat を確認してください。 インストールを実行する前に、 事前設定ファイルのフォーマットが適切かどうかを調べるには、 debconf-set-selections -c preseed.cfg が使えます。 事前設定ファイルの内容 本付録で使用する設定の断片は、 &urlset-example-preseed; のサンプル事前設定ファイルでも利用できます。 本サンプルは、 Intel x86 アーキテクチャ用インストールを元にしていることに注意してください。 他のアーキテクチャにインストールする場合、 サンプルのいくつか (キーボードの選択やブートローダの選択など) は適切でないかもしれませんので、 そのアーキテクチャ用に適切な debconf 設定で置き換える必要があるでしょう。 地域化 地域化の設定値は initrd preseed を利用しているときのみ動作します。 他のすべての方法では、 この質問をされた後にしか事前設定ファイルを読み込めません。 ロケールは言語と国を両方指定します。 ブートパラメータでロケールを指定するには、 locale=en_US としてください。 # Locale sets language and country. d-i debian-installer/locale string en_US キーボード設定は、 キーボードアーキテクチャとキーマップを選択することから成っています。 ほとんどの場合、正しいキーボードアーキテクチャはデフォルトで選択されています。 そのため、通常 preseed する必要はありません。 キーマップは選択したキーボードアーキテクチャで、有効でなくてはなりません。 # Keyboard selection. #d-i console-tools/archs select at d-i console-keymaps-at/keymap select us # Example for a different keyboard architecture #d-i console-keymaps-usb/keymap select mac-usb-us キーボード設定をスキップするには、 console-tools/archsskip-config と preseed してください。 これにより、カーネルのキーマップが有効になったままとなります。 カーネル 2.6 では入力レイヤが変更され、 キーボードアーキテクチャは事実上時代遅れです。 カーネル 2.6 では通常、PC (at) キーマップが既に選択されています。 ネットワーク設定 もちろん、ネットワークから事前設定ファイルを読み込む場合、 preseed のネットワーク設定は動作しません。 しかし、CD や USB スティックから起動するときには重要です。 ネットワークから事前設定ファイルを読み込む場合、 ネットワーク設定パラメータは、カーネルブートパラメータで渡すことになります。 ネットワークから事前設定ファイルを読み込む前に netboot するとき、 特定のインターフェースを選ぶ必要があるなら、 interface=eth1 のようにブートパラメータを使用してください。 preseed/url でネットワーク preseed を使用する際、 ネットワーク設定の preseed は通常不可能ですが、 例えば、ネットワークインターフェースに静的アドレスを設定するといった、 以下のハックを利用して動作させることができます。 このハックは、以下の行を含む preseed/run スクリプトを作成し、 事前設定ファイルを読み込んだ後でネットワークの設定を強制的に再度行う、 というものです。 killall.sh dhclient netcfg # netcfg will choose an interface that has link if possible. This makes it # skip displaying a list if there is more than one interface. d-i netcfg/choose_interface select auto # To pick a particular interface instead: #d-i netcfg/choose_interface select eth1 # If you have a slow dhcp server and the installer times out waiting for # it, this might be useful. #d-i netcfg/dhcp_timeout string 60 # If you prefer to configure the network manually, uncomment this line and # the static network configuration below. #d-i netcfg/disable_dhcp boolean true # If you want the preconfiguration file to work on systems both with and # without a dhcp server, uncomment these lines and the static network # configuration below. #d-i netcfg/dhcp_failed note #d-i netcfg/dhcp_options select Configure network manually # Static network configuration. #d-i netcfg/get_nameservers string 192.168.1.1 #d-i netcfg/get_ipaddress string 192.168.1.42 #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 # Any hostname and domain names assigned from dhcp take precedence over # values set here. However, setting the values still prevents the questions # from being shown, even if values come from dhcp. d-i netcfg/get_hostname string unassigned-hostname d-i netcfg/get_domain string unassigned-domain # Disable that annoying WEP key dialog. d-i netcfg/wireless_wep string # The wacky dhcp hostname that some ISPs use as a password of sorts. #d-i netcfg/dhcp_hostname string radish ミラー設定 使用するインストール方法に依存しますが、 インストーラの追加コンポーネントのダウンロードや、基本システムのインストール、 インストールしたシステムの /etc/apt/sources.list の セットアップにミラーを使用できます。 mirror/suite パラメータでは、 インストールするシステム用の組を設定します。 mirror/udeb/suite パラメータでは、 インストーラの追加コンポーネントの組を設定します。 実際にコンポーネントをネットワークでダウンロードする場合に役立つだけです。 また、インストールで使用するインストール方法のための initrd を生成するには、 この組が一致していなければなりません。 mirror/udeb/suite のデフォルト値は、 mirror/suite と同じです。 d-i mirror/country string enter information manually d-i mirror/http/hostname string http.us.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string # Suite to install. #d-i mirror/suite string testing # Suite to use for loading installer components (optional). #d-i mirror/udeb/suite string testing パーティション分割 ハードディスクのパーティション分割に preseed を使用するのは、 partman-auto でサポートしている機能に限定されています。 パーティションはディスクに既存の空き領域とディスク全体のどちらかから選べます。 ディスクレイアウトは、あらかじめ定義したレシピ、 レシピファイルによるカスタムレシピ、 事前設定ファイルに書いたレシピから選択できます。 現在のところ、パーティションに preseed を用いて複数のディスクを割り当てることはできません。 ディスクの識別は、ドライバの読み込み順に依存します。 複数のディスクがシステムにある場合、preseed を使用する前に、 正しいディスクを確実に選択できるようにしなければなりません。 # If the system has free space you can choose to only partition that space. # Note: this must be preseeded with a localized (translated) value. #d-i partman-auto/init_automatically_partition \ # select Guided - use the largest continuous free space # Alternatively, you can specify a disk to partition. The device name # can be given in either devfs or traditional non-devfs format. # For example, to use the first disk: d-i partman-auto/disk string /dev/discs/disc0/disc # In addition, you'll need to specify the method to use. # The presently available methods are: "regular", "lvm" and "crypto" d-i partman-auto/method string lvm # If one of the disks that are going to be automatically partitioned # contains an old LVM configuration, the user will normally receive a # warning. This can be preseeded away... d-i partman-auto/purge_lvm_from_device boolean true # And the same goes for the confirmation to write the lvm partitions. d-i partman-lvm/confirm boolean true # You can choose from any of the predefined partitioning recipes. # Note: this must be preseeded with a localized (translated) value. d-i partman-auto/choose_recipe \ select All files in one partition (recommended for new users) #d-i partman-auto/choose_recipe \ # select Separate /home partition #d-i partman-auto/choose_recipe \ # select Separate /home, /usr, /var, and /tmp partitions # Or provide a recipe of your own... # The recipe format is documented in the file devel/partman-auto-recipe.txt. # If you have a way to get a recipe file into the d-i environment, you can # just point at it. #d-i partman-auto/expert_recipe_file string /hd-media/recipe # If not, you can put an entire recipe into the preconfiguration file in one # (logical) line. This example creates a small /boot partition, suitable # swap, and uses the rest of the space for the root partition: #d-i partman-auto/expert_recipe string \ # boot-root :: \ # 40 50 100 ext3 \ # $primary{ } $bootable{ } \ # method{ format } format{ } \ # use_filesystem{ } filesystem{ ext3 } \ # mountpoint{ /boot } \ # . \ # 500 10000 1000000000 ext3 \ # method{ format } format{ } \ # use_filesystem{ } filesystem{ ext3 } \ # mountpoint{ / } \ # . \ # 64 512 300% linux-swap \ # method{ swap } format{ } \ # . # This makes partman automatically partition without confirmation. d-i partman/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 RAID を用いたパーティション分割 ソフトウェア RAID アレイにパーティションをセットアップすることも、 preseed を使用してできます。 サポートしているのは、RAID 0, 1, 5、や縮退アレイの作成、 スペアデバイスの指定です。 RAID 1 を使用する際には、アレイで使用する全デバイスへインストールするよう、 preseed で探せます。 をご覧ください。 自動パーティション分割でのこの形式は、誤動作をしやすいです。 また、とても新しいコンポーネントで、まだバグやエラー処理漏れがあるはずです。 様々な条件で正しく動作するかの責任 (理解でき衝突しない限り) は、 ユーザの側にあります。 問題が発生したら、/var/log/syslog をチェックしてください。 コンポーネントの開発者によってテストされているのは、 RAID 0 と RAID 1 のみであることに注意してください。 RAID 5 はテストされていません。 縮退アレイやスペアデバイスを使用した、 拡張 RAID セットアップは軽くテストしただけです。 # NOTE: this option is of beta release quality and should be used carefully # The method should be set to "raid". #d-i partman-auto/method string raid # Specify the disks to be partitioned. They will all get the same layout, # so this will only work if the disks are the same size. #d-i partman-auto/disk string /dev/discs/disc0/disc /dev/discs/disc1/disc # Next you need to specify the physical partitions that will be used. #d-i partman-auto/expert_recipe string \ # multiraid :: \ # 1000 5000 4000 raid \ # $primary{ } method{ raid } \ # . \ # 64 512 300% raid \ # method{ raid } \ # . \ # 500 10000 1000000000 raid \ # method{ raid } \ # . # Last you need to specify how the previously defined partitions will be # used in the RAID setup. Remember to use the correct partition numbers # for logical partitions. # Parameters are: # <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \ # <devices> <sparedevices> # RAID levels 0, 1 and 5 are supported; devices are separated using "#" #d-i partman-auto-raid/recipe string \ # 1 2 0 ext3 / \ # /dev/discs/disc0/part1#/dev/discs/disc1/part1 \ # . \ # 1 2 0 swap - \ # /dev/discs/disc0/part5#/dev/discs/disc1/part5 \ # . \ # 0 2 0 ext3 /home \ # /dev/discs/disc0/part6#/dev/discs/disc1/part6 \ # . # This makes partman automatically partition without confirmation. d-i partman-md/confirm boolean true d-i partman/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 時計・タイムゾーン設定 # Controls whether or not the hardware clock is set to UTC. d-i clock-setup/utc boolean true # You may set this to any valid setting for $TZ; see the contents of # /usr/share/zoneinfo/ for valid values. d-i time/zone string US/Eastern Apt 設定 /etc/apt/sources.list のセットアップと基本設定オプションは、 インストール方法と初期の質問への回答から、完全に自動的に行われます。 さらに、他の (ローカルな) リポジトリを追加できます。 # You can choose to install non-free and contrib software. #d-i apt-setup/non-free boolean true #d-i apt-setup/contrib boolean true # Uncomment this to avoid adding security sources, or # add a hostname to use a different server than security.debian.org. #d-i apt-setup/security_host string # Additional repositories, local[0-9] available #d-i apt-setup/local0/repository string \ # deb http://local.server/debian stable main #d-i apt-setup/local0/comment string local server # Enable deb-src lines #d-i apt-setup/local0/source boolean true # URL to the public key of the local repository; you must provide a key or # apt will complain about the unauthenticated repository and so the # sources.list line will be left commented out #d-i apt-setup/local0/key string http://local.server/key アカウント設定 root アカウント用のパスワードや、 最初のユーザアカウントの名前・パスワードは preseed できます。 パスワードには、クリアテキストか MD5 ハッシュのどちらかを 使用できます。 preseed のパスワードは、 パスワードを知っている事前設定ファイルが誰でもアクセスできるために、 完全に安全でないことを知っておいてください。 MD5 ハッシュを使えば、セキュリティ的には多少ましと言えますが、 MD5 ハッシュは総当たり攻撃にかけられることを考えると、 誤った感覚を与えるかもしれません。 # Skip creation of a root account (normal user account will be able to # use sudo). #d-i passwd/root-login boolean false # Alternatively, to skip creation of a normal user account. #d-i passwd/make-user boolean false # Root password, either in clear text #d-i passwd/root-password password r00tme #d-i passwd/root-password-again password r00tme # or encrypted using an MD5 hash. #d-i passwd/root-password-crypted password [MD5 hash] # To create a normal user account. #d-i passwd/user-fullname string Debian User #d-i passwd/username string debian # Normal user's password, either in clear text #d-i passwd/user-password password insecure #d-i passwd/user-password-again password insecure # or encrypted using an MD5 hash. #d-i passwd/user-password-crypted password [MD5 hash] passwd/root-password-crypted 変数や passwd/user-password-crypted 変数では、 preseed で ! という値を取れます。 この場合、そのアカウントは無効となります。 もちろん管理権限での実行や root ログインを許可する代替手段 (例えば SSH キー認証や sudo) を用意しておいた上で、 root アカウントに設定すると便利です。 パスワードの MD5 ハッシュは以下のコマンドで生成できます。 $ echo "r00tme" | mkpasswd -s -H MD5 基本システムのインストール インストールのこの段階では、実際にはうまく preseed できないことがあります。 その唯一のものが、カーネルのインストールについての質問です。 # Select the initramfs generator used to generate the initrd for 2.6 kernels. #d-i base-installer/kernel/linux/initramfs-generators string yaird ブートローダのインストール # Grub is the default boot loader (for x86). If you want lilo installed # instead, uncomment this: #d-i grub-installer/skip boolean true # This is fairly safe to set, it makes grub install automatically to the MBR # if no other operating system is detected on the machine. d-i grub-installer/only_debian boolean true # This one makes grub-installer install to the MBR if it also finds some other # OS, which is less safe as it might not be able to boot that other OS. d-i grub-installer/with_other_os boolean true # Alternatively, if you want to install to a location other than the mbr, # uncomment and edit these lines: #d-i grub-installer/only_debian boolean false #d-i grub-installer/with_other_os boolean false #d-i grub-installer/bootdev string (hd0,0) # To install grub to multiple disks: #d-i grub-installer/bootdev string (hd0,0) (hd1,0) (hd2,0) パッケージ選択 有効なタスクを組み合わせてインストールするものを選ぶことができます。 有効なタスクを以下に書き出します。 standard desktop gnome-desktop kde-desktop web-server print-server dns-server file-server mail-server sql-database laptop タスクをインストールしないこともできますし、 他の方法でパッケージのセットが強制的にインストールされることもあります。 standard タスクは常に含めるのをお奨めします。 タスクでインストールするパッケージに加えて、 特定のパッケージをインストールする場合、 pkgsel/include パラメータを使用できます。 このパラメータの値は、カーネルコマンドラインにそのまま渡されるので、 カンマか空白で区切ったパッケージのリストを取れます。 tasksel tasksel/first multiselect standard, desktop #tasksel tasksel/first multiselect standard, web-server #tasksel tasksel/first multiselect standard, kde-desktop # Individual additional packages to install #d-i pkgsel/include string openssh-server build-essential # Some versions of the installer can report back on what software you have # installed, and what software you use. The default is not to report back, # but sending reports helps the project determine what software is most # popular and include it on CDs. #popularity-contest popularity-contest/participate boolean false インストール第 1 段階の仕上げ # Avoid that last message about the install being complete. d-i finish-install/reboot_in_progress note # This will prevent the installer from ejecting the CD during the reboot, # which is useful in some situations. #d-i cdrom-detect/eject boolean false メール設定 通常のインストールでは、exim は少々質問しますが、 さらにこれを避ける方法もあります。 もっと複雑な preseed も可能です。 exim4-config exim4/dc_eximconfig_configtype \ select no configuration at this time exim4-config exim4/no_config boolean true exim4-config exim4/no_config boolean true exim4-config exim4/dc_postmaster string X 設定 Debian の X 設定を preseed 可能です。 しかし、マシンのビデオハードウェアについて、 詳細を知っている必要があるかもしれません。 Debian の X コンフィグレータはすべてを自動設定するわけには行かないのです。 # X can detect the right driver for some cards, but if you're preseeding, # you override whatever it chooses. Still, vesa will work most places. #xserver-xorg xserver-xorg/config/device/driver select vesa # A caveat with mouse autodetection is that if it fails, X will retry it # over and over. So if it's preseeded to be done, there is a possibility of # an infinite loop if the mouse is not autodetected. #xserver-xorg xserver-xorg/autodetect_mouse boolean true # Monitor autodetection is recommended. xserver-xorg xserver-xorg/autodetect_monitor boolean true # Uncomment if you have an LCD display. #xserver-xorg xserver-xorg/config/monitor/lcd boolean true # X has three configuration paths for the monitor. Here's how to preseed # the "medium" path, which is always available. The "simple" path may not # be available, and the "advanced" path asks too many questions. xserver-xorg xserver-xorg/config/monitor/selection-method \ select medium xserver-xorg xserver-xorg/config/monitor/mode-list \ select 1024x768 @ 60 Hz 他パッケージの preseed # Depending on what software you choose to install, or if things go wrong # during the installation process, it's possible that other questions may # be asked. You can preseed those too, of course. To get a list of every # possible question that could be asked during an install, do an # installation, and then run these commands: # debconf-get-selections --installer > file # debconf-get-selections >> file 高度なオプション シェルコマンド # d-i preseeding is inherently not secure. Nothing in the installer checks # for attempts at buffer overflows or other exploits of the values of a # preconfiguration file like this one. Only use preconfiguration files from # trusted locations! To drive that home, and because it's generally useful, # here's a way to run any shell command you'd like inside the installer, # automatically. # This first command is run as early as possible, just after # preseeding is read. #d-i preseed/early_command string anna-install some-udeb # This command is run just before the install finishes, but when there is # still a usable /target directory. You can chroot to /target and use it # directly, or use the apt-install and in-target commands to easily install # packages and run commands in the target system. #d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh 事前設定ファイルの連鎖読み込み 事前設定ファイルから他の事前設定ファイルを読み込めます。 前に読み込まれたファイルの既存設定を、 後から読み込まれたいずれの設定でも上書きします。 これは例えば、あるファイルに一般的なネットワークの設定を書いておき、 他のファイルでより確かな設定を指定するという使い方ができます。 # More that one file can be listed, separated by spaces; all will be # loaded. The included files can have preseed/include directives of their # own as well. Note that if the filenames are relative, they are taken from # the same directory as the preconfiguration file that includes them. #d-i preseed/include string x.cfg # The installer can optionally verify checksums of preconfiguration files # before using them. Currently only md5sums are supported, list the md5sums # in the same order as the list of files to include. #d-i preseed/include/checksum string 5da499872becccfeda2c4872f9171c3d # More flexibly, this runs a shell command and if it outputs the names of # preconfiguration files, includes those files. #d-i preseed/include_command \ # string echo if [ "`hostname`" = bob ]; then echo bob.cfg; fi # Most flexibly of all, this downloads a program and runs it. The program # can use commands such as debconf-set to manipulate the debconf database. # More than one script can be listed, separated by spaces. # Note that if the filenames are relative, they are taken from the same # directory as the preconfiguration file that runs them. #d-i preseed/run string foo.sh