Archiso

提供: ArchWiki
2015年10月31日 (土) 19:01時点におけるKusakata (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

関連記事

Archiso は Arch Linux をベースとしたライブ CD 及びライブ USB イメージを構築するための bash スクリプトの小さなセットです。公式の CD/USB イメージを生成するのに使われているツールですが、とても汎用的なツールなので、レスキューシステムやインストールディスクから、特殊なライブ CD/DVD/USB システムまで、あらゆるものを作成することができます。要するに、Arch に関係していることなら、何だって出来ちゃいます。Archiso の中心は mkarchiso です。mkarchiso のオプションは全てドキュメント化されているので、ここでは使用方法を直接説明することはありません。代わりに、この wiki 記事ではライブメディアをすぐに作り出すためのガイドを提供します。

設定

ノート:
  • Archiso を使う場合 x86_64 環境で動作させる必要があります [1]
  • 以下の作業は全て root で行うことを推奨します。そうしないと、後でパーミッションの問題が発生するでしょう。

初めに、公式リポジトリから archisoインストールする必要があります。もしくは、AURarchiso-gitAUR を使うこともできます。

作業用のディレクトリを作成します。ライブイメージへの変更はすべてこのディレクトリで行います: ~/archlive で問題ないでしょう。

$ mkdir ~/archlive

ホストシステムにインストール先に archiso スクリプトを新しく作成した作業ディレクトリにコピーしてください。

Archiso には2つの"プロファイル"があります: relengbaseline

  • インストール済みのお気に入りのプログラムや設定を使って、Arch Linux のフルカスタマイズライブ版を作りたい場合は、releng を使います。
  • インストール済みのパッケージは使わずに、最小設定を使って、ベーシックなライブメディアを作りたい場合は、baseline を使います。

必要に応じて、以下を実行してください ('PROFILE' は relengbaseline のどちらかに置き換えてください)。

# cp -r /usr/share/archiso/configs/PROFILE/ ~/archlive
  • releng プロファイルを使って完全にカスタマイズしたイメージを作成する場合は、#ライブメディアの設定 に進んで下さい。
  • baseline プロファイルを使って最低限のイメージを作成する場合は、カスタマイズをする必要がないので、#ISO の作成 に進んで下さい。

ライブメディアの設定

このセクションでは作成するイメージの設定について説明します。ライブイメージに含めたいパッケージや設定を定義することができます。

~/archlive ディレクトリには多数のファイルとディレクトリが存在しますが、ここでは以下のファイルとディレクトリにだけ触れます:

  • packages.* - インストールしたいパッケージを一行ごとに記述したリストです。
  • airootfs ディレクトリ - このディレクトリはオーバーレイとして機能し、カスタマイズを行うことができます。

Generally, every administrative task that you would normally do after a fresh install except for package installation can be scripted into ~/archlive/airootfs/root/customize-airootfs.sh. It has to be written from the perspective of the new environment, so / in the script means the root of the live-iso which is created.

パッケージをインストール

You will want to create a list of packages you want installed on your live CD system. A file full of package names, one-per-line, is the format for this. This is great for special interest live CDs, just specify packages you want in packages.both and bake the image. The packages.i686 and packages.x86_64 files allow you to install software on just 32-bit or 64-bit, respectively.

ノート: ライブ CD でウィンドウマネージャを使いたい場合、必要なビデオドライバーを追加する必要があります。追加しておかないとロード時に WM がフリーズします。

カスタムローカルリポジトリ

カスタムパッケージや AUR/ABS からパッケージを準備するためにカスタムローカルリポジトリを作成することもできます。両方のアーキテクチャでパッケージを用意する場合、問題が起きないように特定のディレクトリの順番を守るようにしてください。

例えば:

  • ~/customrepo
    • ~/customrepo/x86_64
      • ~/customrepo/x86_64/foo-x86_64.pkg.tar.xz
      • ~/customrepo/x86_64/customrepo.db.tar.gz
      • ~/customrepo/x86_64/customrepo.db (symlink created by repo-add)
    • ~/customrepo/i686
      • ~/customrepo/i686/foo-i686.pkg.tar.xz
      • ~/customrepo/i686/customrepo.db.tar.gz
      • ~/customrepo/i686/customrepo.db (symlink created by repo-add)

You can then add your repository by putting the following into ~/archlive/pacman.conf, above the other repository entries (for top priority):

# custom repository
[customrepo]
SigLevel = Optional TrustAll
Server = file:///home/user/customrepo/$arch

So, the build scripts just look for the appropriate packages.

If this is not the case you will be running into error messages similar to this:

error: failed to prepare transaction (package architecture is not valid)
:: package foo-i686 does not have a valid architecture

base グループに含まれているパッケージのインストールを避ける

By, default /usr/bin/mkarchiso, a script which is used by ~/archlive/build.sh, calls one of the arch-install-scripts named pacstrap without the -i flag, which causes Pacman to not wait for user input during the installation process.

When blacklisting base group packages by adding them to the IgnorePkg line in ~/archlive/pacman.conf, Pacman asks if they still should be installed, which means they will when user input is bypassed. To get rid of these packages there are several options:

  • Dirty: Add the -i flag to each line calling pacstrap in /usr/bin/mkarchiso.
  • Clean: Create a copy of /usr/bin/mkarchiso in which you add the flag and adapt ~/archlive/build.sh so that it calls the modified version of the mkarchiso script.
  • Advanced: Create a function for ~/archlive/build.sh which explicitly removes the packages after the base installation. This would leave you the comfort of not having to type enter so much during the installation process.

ユーザーを追加

ユーザー管理は通常のインストール方法と同じ方法で行うことができます。ただしコマンドは ~/archlive/releng/airootfs/root/customize_airootfs.sh に記述してください。ユーザー管理に関する情報はユーザー管理を見て下さい。

イメージにファイルを追加

ノート: You must be root to do this, do not change the ownership of any of the files you copy over, everything within the airootfs directory must be root owned. Proper ownerships will be sorted out shortly.

The airootfs directory acts as an overlay, think of it as root directory '/' on your current system, so any files you place within this directory will be copied over on boot-up.

So if you have a set of iptables scripts on your current system you want to be used on you live image, copy them over as such:

# cp -r /etc/iptables ~/archlive/airootfs/etc

Placing files in the users home directory is a little different. Do not place them within airootfs/home, but instead create a skel directory within airootfs/ and place them there. We will then add the relevant commands to the customize_root_image.sh which we are going to use to copy them over on boot and sort out the permissions.

First, create the skel directory:

# mkdir ~/archlive/airootfs/etc/skel

Now copy the 'home' files to the skel directory, e.g for .bashrc:

# cp ~/.bashrc ~/archlive/airootfs/etc/skel/

~/archlive/airootfs/root/customize-airootfs.sh が実行され新しいユーザーが作成されると、skel ディレクトリからファイルが自動的に新しいホームディレクトリにコピーされ、パーミッションが適切に設定されます。

ブートローダー

デフォルトのファイルで大抵は動作するので、触れる必要はほとんどありません。

Due to the modular nature of isolinux, you are able to use lots of addons since all *.c32 files are copied and available to you. Take a look at the official syslinux site and the archiso git repo. Using said addons, it is possible to make visually attractive and complex menus. See here.

ログインマネージャ

ブート時に X を起動させるのはログインマネージャの systemd サービスを有効化すれば出来ます。どの .service ファイルがソフトリンクを必要としているのかわからない場合、作成する iso と同じプログラムを使っていればすぐに確認することができます:

$ ls -l /etc/systemd/system/display-manager.service

そして ~/archlive/airootfs/etc/systemd/system に同じソフトリンクを作成します。LXDM の場合:

# ln -s /usr/lib/systemd/system/lxdm.service ~/archlive/airootfs/etc/systemd/system/display-manager.service

これでライブ環境でシステムを起動した時に LXDM が有効になります。

もしくは airootfs/root/customize_airootfs.sh で他のサービスと同じようにサービスを有効化することもできます。

起動時に自動的にグラフィカル環境が実行されるようにしたい場合 airootfs/root/customize_airootfs.sh を編集して以下の行を:

systemctl set-default multi-user.target

次のように置き換えてください:

systemctl set-default graphical.target

自動ログインの変更

The configuration for getty's automatic login is located under airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf.

You can modify this file to change the auto login user:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin isouser --noclear %I 38400 linux

Or remove it altogether to disable auto login.

ISO の作成

Now you are ready to turn your files into the .iso which you can then burn to CD or USB:

Inside ~/archlive, execute:

# ./build.sh -v

The script will now download and install the packages you specified to work/*/airootfs, create the kernel and init images, apply your customizations and finally build the iso into out/.

ISO の再作成

Rebuilding the iso after modifications is not officially supported. However, it is easily possible by appliying two steps. First you have to remove lock files in the work directory:

# rm -v work/build.make_*

Furthermore it is required to edit the script airootfs/root/customize_airootfs.sh, and add an id command in the beginning of the useradd line as shown here. Otherwise the rebuild stops at this point because the user that is to be added already exists [2].

! id arch && useradd -m -p "" -g users -G "adm,audio,floppy,log,network,rfkill,scanner,storage,optical,power,wheel" -s /usr/bin/zsh arch

ISO を使う

CD

iso を cd に書き込んでください。光学ディスクドライブ#焼き込みに従ってください。

USB

USB インストールメディアを見て下さい。

GRUB

Multiboot_USB_drive#Arch_Linux を見て下さい。

grub4dos

Grub4dos is a utility that can be used to create multiboot USBs, able to boot multiple linux distros from the same USB stick.

To boot the generated system on a USB with grub4dos already installed, loop mount the ISO and copy the entire /arch directory to the root of the USB. Then edit the menu.lst file from the grub4dos (it must be on the USB root) and add these lines:

title Archlinux x86_64
kernel /arch/boot/x86_64/vmlinuz archisolabel=<your usb label>
initrd /arch/boot/x86_64/archiso.img

Change the x86_64 part as necessary and put your real usb label there.

インターネットにアクセスできない環境でのインストール

If you wish to install the archiso(e.g. the offical monthly release) as it is without an Internet connection, or, if you do not want to download the packages you want again:

まず、(#インターネット接続の確立など) 複数のセクションを飛ばして#ベースシステムのインストールまでビギナーズガイドに従ってください。

新しい root に archiso をインストール

pacstrap でパッケージをインストールする代わりに (リモートのリポジトリからパッケージをダウンロードするわけですが今はインターネット接続がありません)、ライブ環境から新しい chroot に全てをコピーしてください:

# time cp -ax / /mnt
ノート: The option (-x) excludes some special directories, as they should not be copied to the new root.

次に、新しいシステムの整合性を保つために、ディレクトリを複数作成してカーネルイメージを新しい root にコピーします:

# cp -vaT /run/archiso/bootmnt/arch/boot/$(uname -m)/vmlinuz /mnt/boot/vmlinuz-linux

その後、ビギナーズガイド#fstab の生成に書かれているとおりに fstab を生成してください。

Chroot とベースシステムの設定

次に、新しくインストールしたシステムに chroot します:

# arch-chroot /mnt /bin/bash

Please note that before you configure the locale,keymap,etc,... there are something necessary to do, in order to get rid of the trace of a Live environment(in other words, the customization of archiso which does not fit a non-Live environment).

journald の設定の復旧

This customization of archiso will lead to storing the system journal in RAM, it means that the journal will not available after reboot:

# sed -i 's/Storage=volatile/#Storage=auto/' /etc/systemd/journald.conf

特殊な udev ルールの削除

この udev ルール は有線ネットワークインターフェイスが存在する場合に自動的に dhcpcd を起動します。

# rm /etc/udev/rules.d/81-dhcpcd.rules

archiso によって作成されたサービスの無効化と削除

Some service files are created for the Live environment, please disable the services and remove the file as they are unnecessary for the new system:

# systemctl disable pacman-init.service choose-mirror.service
# rm -r /etc/systemd/system/{choose-mirror.service,pacman-init.service,etc-pacman.d-gnupg.mount,getty@tty1.service.d}
# rm /etc/systemd/scripts/choose-mirror

ライブ環境の特殊なスクリプトの削除

ライブ環境には archiso スクリプトによっていくつかスクリプトがインストールされており、これらは新しい環境では必要ありません:

# rm /etc/systemd/system/getty@tty1.service.d/autologin.conf
# rm /root/{.automated_script.sh,.zlogin}
# rm /etc/mkinitcpio-archiso.conf
# rm -r /etc/initcpio

initial ramdisk 環境を作成

ビギナーズガイド#Initial ramdisk 環境の作成に書かれているように initial ramdisk を作成してください。

通常の設定

上記全てが終わったら、ビギナーズガイドに従ってインストールを完了します。

参照

ドキュメントとチュートリアル

カスタマイズテンプレートのサンプル