Difference between revisions of "Archiso (日本語)"

From ArchWiki
Jump to: navigation, search
(update link(s) (avoid redirect))
Line 1: Line 1:
 
[[Category:Live Arch systems (日本語)]]
 
[[Category:Live Arch systems (日本語)]]
 +
[[Category:Getting and installing Arch (日本語)]]
 
[[ar:Archiso]]
 
[[ar:Archiso]]
 
[[el:Archiso]]
 
[[el:Archiso]]
Line 8: Line 9:
 
[[nl:Archiso]]
 
[[nl:Archiso]]
 
[[ru:Archiso]]
 
[[ru:Archiso]]
 +
[[sk:Archiso]]
 
[[uk:Archiso]]
 
[[uk:Archiso]]
'''Archiso'''とはArch LinuxをベースとしたライブCD、及びライブUSBを構築するためのbashスクリプトの小さなセットです。とても汎用的なツールなので、レスキューシステムやインストールディスク、ライブCD/DVD/USBも作成することができます。Simply put, if it involves Arch on a shiny coaster, it can do it. Archisoの全てはmkarchisoです。全てのmkarchisoのオプションは使用方出力(manページ?)でドキュメント化されているので、ここでは直接その使用方法をカバーすることはしません。代わりに、このwikiの記事では、あなた自身のライブメディアをすぐに作成するためのガイドをします。
+
[[zh-CN:Archiso]]
 +
{{Related articles start (日本語)}}
 +
{{Related2|Remastering the Install ISO|インストール ISO のリマスター}}
 +
{{Related|Archiso as pxe server}}
 +
{{Related articles end}}
 +
'''Archiso''' は Arch Linux をベースとしたライブ CD 及びライブ USB イメージを構築するための bash スクリプトの小さなセットです。公式の CD/USB イメージを生成するのに使われているツールですが、とても汎用的なツールなので、レスキューシステムやインストールディスクから、特殊なライブ CD/DVD/USB システムまで、あらゆるものを作成することができます。要するに、Arch に関係していることなら、何だって出来ちゃいます。Archiso の中心は mkarchiso です。mkarchiso のオプションは全てドキュメント化されているので、ここでは使用方法を直接説明することはありません。代わりに、この wiki 記事ではライブメディアをすぐに作り出すためのガイドを提供します。
  
== Setup ==
+
== 設定 ==
{{Note|The script is to be used on an x86_64 machine.}}
+
 
 +
{{Note|It is recommended to act as root in all the following steps. If not, it is very likely to have problems with false permissions later.}}
 
Before we begin, we need to [[pacman|install]] {{Pkg|archiso}} from the [[official repositories]]. Alternatively, {{AUR|archiso-git}} can be found in the [[AUR]].
 
Before we begin, we need to [[pacman|install]] {{Pkg|archiso}} from the [[official repositories]]. Alternatively, {{AUR|archiso-git}} can be found in the [[AUR]].
  
Line 19: Line 27:
  
 
The archiso scripts that were installed to the host system earlier now need to be copied over into the newly created directory you will be working within.
 
The archiso scripts that were installed to the host system earlier now need to be copied over into the newly created directory you will be working within.
 +
 
Archiso comes with two "profiles": ''releng'' and ''baseline''.
 
Archiso comes with two "profiles": ''releng'' and ''baseline''.
 +
 
If you wish to create a fully customised live version of Arch Linux, pre-installed with all your favourite programs and configurations, use ''releng''.
 
If you wish to create a fully customised live version of Arch Linux, pre-installed with all your favourite programs and configurations, use ''releng''.
 +
 
If you just want to create the most basic live medium, with no pre-installed packages and a minimalistic configuration, use ''baseline''.
 
If you just want to create the most basic live medium, with no pre-installed packages and a minimalistic configuration, use ''baseline''.
  
 
So, depending on your needs, execute the following, replacing 'PROFILE' with either '''releng''' or '''baseline'''.
 
So, depending on your needs, execute the following, replacing 'PROFILE' with either '''releng''' or '''baseline'''.
  # cp -r /usr/share/archiso/configs/'''PROFILE'''/ ~USER/archlive
+
  # cp -r /usr/share/archiso/configs/'''PROFILE'''/ ~/archlive
  
 
If you are using the ''releng'' profile to make a fully customised image, then you can proceed onto [[#Configure our live medium]].
 
If you are using the ''releng'' profile to make a fully customised image, then you can proceed onto [[#Configure our live medium]].
Line 30: Line 41:
 
If you are using the ''baseline'' profile to create a bare image, then you won't be needing to do any customisations and can proceed onto [[#Build the ISO]].
 
If you are using the ''baseline'' profile to create a bare image, then you won't be needing to do any customisations and can proceed onto [[#Build the ISO]].
  
== Configure our live medium ==
+
== ライブメディアの設定 ==
  
 
This section details configuring the image you will be creating, allowing you to define the packages and configurations you want your live image to contain.
 
This section details configuring the image you will be creating, allowing you to define the packages and configurations you want your live image to contain.
Line 36: Line 47:
 
Change into the directory we created earlier (~/archlive/releng/ if you have been following this guide), you will see a number of files and directories; we are only concerned with a few of these, mainly:  
 
Change into the directory we created earlier (~/archlive/releng/ if you have been following this guide), you will see a number of files and directories; we are only concerned with a few of these, mainly:  
 
packages.* - this is where you list, line by line, the packages you want to have installed, and
 
packages.* - this is where you list, line by line, the packages you want to have installed, and
the root-image directory - this directory acts as an overlay and it is where you make all the customisations.
+
the airootfs directory - this directory acts as an overlay and it is where you make all the customisations.
  
=== Installing packages ===
+
Generally, every administrative task that you would normally do after a fresh install except for package installation can be scripted into {{ic|~/archlive/releng/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.
 
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 32bit or 64bit, respectively.
 
The packages.i686 and packages.x86_64 files allow you to install software on just 32bit or 64bit, respectively.
+
 
{{Tip|You can also create a '''[[custom local repository]]''' for the purpose of preparing custom packages or packages from [[AUR]]/[[ABS]]. Just add your local repository at the first position (for top priority) of your build machine's '''pacman.conf''' and you are good to go!}}
 
 
I recommend installing "rsync" if you wish to install the system later on with no internet connection or skipping downloading it all over again. ([[#Installation]])
 
I recommend installing "rsync" if you wish to install the system later on with no internet connection or skipping downloading it all over again. ([[#Installation]])
  
=== Adding a user ===
+
==== カスタムローカルリポジトリ ====
  
There are two methods to creating a user: either by adding the relevant useradd command to rc.local, or by copying over (and modifying) /etc/shadow, /etc/passwd, and /etc/group.
+
You can also [[custom local repository|create a custom local repository]] for the purpose of preparing custom packages or packages from [[AUR]]/[[ABS]]. When doing so with packages for both architectures, you should follow a certain directory order to not run into problems.
The latter method shall be discussed here.
 
  
Copy your /etc/shadow, /etc/passwd, and /etc/group from your '''host''' system to the /etc/ directory '''of the new live system''' (which should be ~/archlive/releng/root-image/etc)
+
For instance:
e.g.
 
# cp /etc/{shadow,passwd,group} ~/archlive/releng/root-image/etc/
 
  
{{Warning|The shadow file will contain your encrypted password. I recommend before you copy the shadow file over, you change the password of your host user to that which you want your live user to have, copy the shadow file over, and then change back your password.}}
+
*{{ic|~/customrepo}}
 +
**{{ic|~/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 {{ic|repo-add}})
 +
**{{ic|~/customrepo/i686}}
 +
***~/customrepo/i686/foo-i686.pkg.tar.xz
 +
***~/customrepo/i686/customrepo.db.tar.gz
 +
***~/customrepo/i686/customrepo.db (symlink created by {{ic|repo-add}})
  
=== Adding files to image ===
+
You can then add your repository by putting the following into {{ic|~/archlive/releng/pacman.conf}}, above the other repository entries (for top priority):
  
{{Note|You must be root to do this, do not change the ownership of any of the files you copy over, '''everything''' within the root-image directory must be root owned. Proper ownerships will be sorted out shortly.}}
+
# custom repository
 +
[customrepo]
 +
SigLevel = Optional TrustAll
 +
Server = file:///home/'''user'''/customrepo/$arch
  
The root-image 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, the build scripts just look for the appropriate packages.
  
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:
+
If this is not the case you will be running into error messages similar to this:
# cp -r /etc/iptables ~/archlive/releng/root-image/etc
+
 
 +
error: failed to prepare transaction (package architecture is not valid)
 +
:: package foo-i686 does not have a valid architecture
 +
 
 +
==== Avoid installation of packages belonging to base group ====
 +
 
 +
By, default {{ic|/usr/bin/mkarchiso}}, a script which is used by {{ic|~/archlive/releng/build.sh}}, calls one of the {{Pkg|arch-install-scripts}} named {{ic|pacstrap}} without the {{ic|-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 {{ic|IgnorePkg}} line in {{ic|~/archlive/releng/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 {{ic|-i}} flag to each line calling {{ic|pacstrap}} in {{ic|/usr/bin/mkarchiso}}.
 +
 
 +
* '''Clean''': Create a copy of {{ic|/usr/bin/mkarchiso}} in which you add the flag and adapt {{ic|~/archlive/releng/build.sh}} so that it calls the modified version of the mkarchiso script.
  
Placing files in the users home directory is a little different. Do not place them within root-image/home, but instead create a skel directory within root-image/ and place them there. We will then add the relevant commands to the rc.local we are going to create to copy them over on boot and sort out the permissions.
+
* '''Advanced''': Create a function for {{ic|~/archlive/releng/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.
  
First, create the skel directory; making sure you are within ~/archlive/releng/root-image/etc directory (if this is where you are working from):
+
=== ユーザーを追加 ===
# cd ~/archlive/releng/root-image/etc && mkdir skel
 
  
Now copy the 'home' files to the skel directory, again doing everything as root!
+
User management can be handled the same way as during the normal installation process, except you put your commands scripted into {{ic|~/archlive/releng/airootfs/root/customize_airootfs.sh}}. For further information have a look at [[Users and groups#User management|User management]].
e.g for .bashrc.
 
  # cp ~/.bashrc ~/archlive/releng/root-image/etc/skel/
 
  
Inside the root-image/etc/ directory, create the rc.local file, and '''make sure''' you make it executable:
+
=== イメージにファイルを追加 ===
  
# cd ~/archlive/releng/root-image/etc && touch rc.local && chmod +x rc.local
+
{{Note|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.}}
  
Now add the all of following to rc.local, replacing 'youruser' with the user you specified earlier.
+
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.
# Create the user directory for live session
 
if [ ! -d /home/'''youruser''' ]; then
 
    mkdir /home/'''youruser''' && chown '''youruser''' /home/'''youruser'''
 
fi
 
# Copy files over to home
 
su -c "cp -r /etc/skel/.* /home/'''youruser'''/" '''youruser'''
 
  
=== aitab ===
+
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/releng/airootfs/etc
  
The default file should work fine, so you should not need to touch it.
+
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.
  
The aitab file holds information about the filesystems images that must be created by mkarchiso and mounted at initramfs stage from the archiso hook.
+
First, create the skel directory; making sure you are within ~/archlive/releng/airootfs/etc directory (if this is where you are working from):
It consists of some fields which define the behaviour of images.
+
# cd ~/archlive/releng/airootfs/etc && mkdir skel
  
  # <img>        <mnt>                <arch>  <sfs_comp>  <fs_type>  <fs_size>
+
Now copy the 'home' files to the skel directory, again doing everything as root!
 +
e.g for .bashrc.
 +
  # cp ~/.bashrc ~/archlive/releng/airootfs/etc/skel/
  
; <img>: Image name without extension (.fs .fs.sfs .sfs).
+
When {{ic|~/archlive/releng/airootfs/root/customize-airootfs.sh}} is executed and a new user is created, the files from the skel directory will automatically be copied over to the new home folder, permissions set right.
; <mnt>: Mount point.
 
; <arch>: Architecture { i686 | x86_64 | any }.
 
; <sfs_comp>: SquashFS compression type { gzip | lzo | xz }.
 
; <fs_type>:  Set the filesystem type of the image { ext4 | ext3 | ext2 | xfs }. A special value of "none" denotes no usage of a filesystem. In that case all files are pushed directly to SquashFS filesystem.
 
; <fs_size>:  An absolute value of file system image size in MiB (example: 100, 1000, 4096, etc) A relative value of file system free space [in percent] {1%..99%} (example 50%, 10%, 7%). This is an estimation, and calculated in a simple way. Space used + 10% (estimated for metadata overhead) + desired %
 
  
{{Note|Some combinations are invalid. Example both sfs_comp and fs_type are set to none}}
+
=== ブートローダー ===
  
=== Boot Loader ===
 
 
The default file should work fine, so you should not need to touch it.
 
The default file should work fine, so you should not need to touch it.
  
 
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 [http://syslinux.zytor.com/wiki/index.php/SYSLINUX official syslinux site] and the [https://projects.archlinux.org/archiso.git/tree/configs/syslinux-iso/boot-files archiso git repo]. Using said addons, it is possible to make visually attractive and complex menus. See [http://syslinux.zytor.com/wiki/index.php/Comboot/menu.c32 here].
 
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 [http://syslinux.zytor.com/wiki/index.php/SYSLINUX official syslinux site] and the [https://projects.archlinux.org/archiso.git/tree/configs/syslinux-iso/boot-files archiso git repo]. Using said addons, it is possible to make visually attractive and complex menus. See [http://syslinux.zytor.com/wiki/index.php/Comboot/menu.c32 here].
  
=== Login manager ===
+
=== ログインマネージャ ===
  
Starting X at boot time was done by modifying ''inittab'' on [[sysvinit]] systems. On a [[systemd]] based system things are handled by enabling your login manager's service. If you know which .service file needs a softlink: Great. If not, you can easily find out in case you're using the same program on the system you build your iso on. Just use
+
Starting X at boot is done by enabling your login manager's [[systemd]] service. If you know which .service file needs a softlink: Great. If not, you can easily find out in case you're using the same program on the system you build your iso on. Just use
  
 
  # systemctl disable '''nameofyourloginmanager'''
 
  # systemctl disable '''nameofyourloginmanager'''
  
to temporarily turn it of. Next type the same command again and replace "disable" with "enable" to activate it again. Systemctl prints information about softlink it creates. Now change to ~/archiso/releng/root-image/etc/systemd/system and create the same softlink there.
+
to temporarily turn it off. Next type the same command again and replace "disable" with "enable" to activate it again. Systemctl prints information about softlink it creates. Now change to ~/archiso/releng/airootfs/etc/systemd/system and create the same softlink there.
  
An example (make sure you're either in ~/archiso/releng/root-image/etc/systemd/system or add it to the command):
+
An example (make sure you're either in ~/archiso/releng/airootfs/etc/systemd/system or add it to the command):
  
 
  # ln -s /usr/lib/systemd/system/lxdm.service display-manager.service
 
  # ln -s /usr/lib/systemd/system/lxdm.service display-manager.service
  
 
This will enable LXDM at system start on your live system.
 
This will enable LXDM at system start on your live system.
 +
 +
=== 自動ログインの変更 ===
 +
 +
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.
  
 
== Build the ISO ==
 
== Build the ISO ==
Line 131: Line 163:
 
  # ./build.sh -v
 
  # ./build.sh -v
  
The script will now download and install the packages you specified to work/*/root-image, create the kernel and init images, apply your customizations and finally build the iso into out/.
+
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/.
 +
 
 +
{{Note|If you want to use a [[window manager]] in the Live CD then you must add the necessary and correct [[video drivers]], or the WM may freeze on loading.}}
 +
 
 +
=== Rebuild the ISO ===
 +
 
 +
If you want to rebuild your iso again after a few modifications, you have to remove lock files in the work directory:
 +
 
 +
# rm -v work/build.make_*
 +
 
 +
== ISO を使う ==
  
== Using the ISO ==
 
 
=== CD ===
 
=== CD ===
 +
 
Just burn the iso to a cd. You can follow [[CD Burning]] as you wish.
 
Just burn the iso to a cd. You can follow [[CD Burning]] as you wish.
 +
 
=== USB ===
 
=== USB ===
You can now dd the iso file onto a USB using dd, an example of which:
+
 
# dd if=~/archlive/releng/out/*.iso of=/dev/sdx
+
See [[USB flash installation media]].
You will have to adjust accordingly, and make sure you choose the right output file! A simple mistake here will destory data on your harddisk.
+
 
 +
=== GRUB ===
 +
 
 +
See [[Multiboot_USB_drive#Arch_Linux]].
 +
 
 
=== grub4dos ===
 
=== grub4dos ===
 +
 
Grub4dos is a utility that can be used to create multiboot usbs, able to boot multiple linux distros from the same usb stick.
 
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 {{ic|/arch}} directory to the '''root of the usb'''.
 
To boot the generated system on a usb with grub4dos already installed, loop mount the ISO and copy the entire {{ic|/arch}} directory to the '''root of the usb'''.
Then edit the {{ic|menu.lst}} file from the grub4dos (it must be on the usb root) and add this lines:
+
Then edit the {{ic|menu.lst}} file from the grub4dos (it must be on the usb root) and add these lines:
 +
 
 
{{bc|<nowiki>
 
{{bc|<nowiki>
 
title Archlinux x86_64
 
title Archlinux x86_64
Line 150: Line 199:
 
initrd /arch/boot/x86_64/archiso.img
 
initrd /arch/boot/x86_64/archiso.img
 
</nowiki>}}
 
</nowiki>}}
 +
 
Change the {{ic|x86_64}} part as necessary and put your '''real''' usb label there.
 
Change the {{ic|x86_64}} part as necessary and put your '''real''' usb label there.
  
=== Installation ===
+
== インターネットにアクセスできない環境でのインストール ==
 +
 
 +
If you wish to install the archiso(e.g. [https://www.archlinux.org/download/ the offical monthly release]) as it is without an Internet connection, or, if you don't want to download the packages you want again:
 +
 
 +
First, please follow the [[Beginners' guide|beginners' guide]] and skip some parts(like [[Beginners'_guide#Establish_an_internet_connection|#Establish_an_internet_connection]]) until the [[Beginners'_guide#Install_the_base_system|#Install_the_base_system]] step.
 +
 
 +
=== 新しい root に archiso をインストール ===
 +
Instead of installing the packages with {{ic|pacstrap}}(as it downloads every packages from remote repository and we have no Internet access now), please copy ''everything'' in the Live environment to the new root:
 +
# time (cp -ax /{usr,bin,lib,lib64,sbin,etc,home,opt,root,srv,var} /mnt)
 +
{{Note|This command excludes some special directories, as they should not be copied to the new root.}}
 +
Then, create some directories and copy the kernel image to the new root, in order to keep the integrity of the new system:
 +
# mkdir -vm755 /mnt/{boot,dev,run,mnt}
 +
# cp -vaT /run/archiso/bootmnt/arch/boot/$(uname -m)/vmlinuz /mnt/boot/vmlinuz-linux
 +
# mkdir -vm1777 /mnt/tmp
 +
# mkdir -vm555 /mnt/{sys,proc}
 +
 
 +
After that, please generate a fstab as described in [[Beginners' guide#Generate_an_fstab]].
 +
 
 +
=== Chroot とベースシステムの設定 ===
 +
Next, chroot into your newly installed system:
 +
# 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).
 +
 
 +
==== Restore the configuration of journald ====
 +
[https://projects.archlinux.org/archiso.git/tree/configs/releng/airootfs/root/customize_airootfs.sh#n19 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
 +
 
 +
==== Reset the pam's configuration ====
 +
[https://projects.archlinux.org/archiso.git/tree/configs/releng/airootfs/etc/pam.d/su This configuration of pam] perhaps break the security of your new system, it's recommend to use the default configuration:
 +
{{hc|# nano /etc/pam.d/su|
 +
#%PAM-1.0
 +
auth            sufficient      pam_rootok.so
 +
# Uncomment the following line to implicitly trust users in the "wheel" group.
 +
'''#auth          sufficient      pam_wheel.so trust use_uid'''
 +
# Uncomment the following line to require a user to be in the "wheel" group.
 +
#auth          required        pam_wheel.so use_uid
 +
auth            required        pam_unix.so
 +
account        required        pam_unix.so
 +
session        required        pam_unix.so
 +
}}
 +
 
 +
==== Remove special udev rule ====
 +
[https://projects.archlinux.org/archiso.git/tree/configs/releng/airootfs/etc/udev/rules.d/81-dhcpcd.rules This rule of udev] starts the dhcpcd automatically if there are any wired network interfaces.
 +
 
 +
# rm /etc/udev/rules.d/81-dhcpcd.rules
 +
 
 +
==== Disable and remove the services created by 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
 +
 
 +
==== Remove special scripts of the Live environment ====
 +
There are some scripts installed in the live system by archiso scripts, which are unnecessary for the new system:
 +
# rm /etc/systemd/system/getty@tty1.service.d/autologin.conf
 +
# rm /root/{.automated_script.sh,.zlogin}
 +
# rm /etc/sudoers.d/g_wheel
 +
# rm /etc/mkinitcpio-archiso.conf
 +
# rm -r /etc/initcpio
 +
 
 +
==== arch のパスワードを設定 ====
 +
[https://projects.archlinux.org/archiso.git/tree/configs/releng/airootfs/root/customize_airootfs.sh#n13 The customization script] created a normal user called {{ic|arch}} for the Live environment. You can set a passwd for user {{ic|arch}} in order to login with this username(there is no passwd for {{ic|arch}} by default):
 +
# passwd arch
 +
 
 +
Or, if you don't want to use this username, please remove this user:
 +
# userdel -r arch
  
Boot the created CD/DVD/USB. If you wish to install the Archiso you created '''-as it is-''', there are several ways to do this, but either way we're following the [[Beginners' guide]] mostly.
+
==== initial ramdisk 環境を作成 ====
 +
Please create an initial ramdisk as described in [[Beginners'_guide#Create_an_initial_ramdisk_environment]].
  
If you don't have an internet connection on that PC, or if you don't want to download every packages you want again, follow the guide, and when you get to [[Beginners' guide#Install_the_base_system]], instead of downloading, use this: [[Full system backup with rsync]]. (more info here: [[Talk:Archiso]])
+
==== 通常の設定 ====
 +
After all of these, now you can follow the [[Beginners'_guide#Locale|beginners' guide]] and finish the installation.
  
You can also try: [[Archboot]], GUI installer.
+
== 参照 ==
 +
=== ドキュメントとチュートリアル ===
 +
* [https://projects.archlinux.org/archiso.git  Archiso project page]
 +
* [https://projects.archlinux.org/archiso.git/tree/docs Offical documentation]
 +
* [http://blog.jak.me/2011/09/07/creating-a-custom-arch-linux-live-usb/ Creating a custom Arch Linux live USB tutorial]
  
== See also ==
+
=== カスタマイズテンプレートのサンプル ===
*[https://projects.archlinux.org/?p=archiso.git;a=summary Archiso project page]
+
* [http://didjix.blogspot.com/ A live DJ distribution powered by ArchLinux and built with Archiso]
*[[Archiso_as_pxe_server|Archiso as pxe server]]
 
*[https://kroweer.wordpress.com/2011/09/07/creating-a-custom-arch-linux-live-usb Step-by-step tutorial on using ArchISO]
 
*[http://didjix.blogspot.com/ A live DJ distribution powered by ArchLinux and built with Archiso]
 

Revision as of 17:09, 22 November 2014

zh-CN:Archiso Template:Related articles start (日本語)

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

    設定

    Note: It is recommended to act as root in all the following steps. If not, it is very likely to have problems with false permissions later.

    Before we begin, we need to install archiso from the official repositories. Alternatively, archiso-gitAUR can be found in the AUR.

    Create a directory to work within, this is where all the modifications to the live image will take place: ~/archlive should do fine.

    $ mkdir ~/archlive
    

    The archiso scripts that were installed to the host system earlier now need to be copied over into the newly created directory you will be working within.

    Archiso comes with two "profiles": releng and baseline.

    If you wish to create a fully customised live version of Arch Linux, pre-installed with all your favourite programs and configurations, use releng.

    If you just want to create the most basic live medium, with no pre-installed packages and a minimalistic configuration, use baseline.

    So, depending on your needs, execute the following, replacing 'PROFILE' with either releng or baseline.

    # cp -r /usr/share/archiso/configs/PROFILE/ ~/archlive
    

    If you are using the releng profile to make a fully customised image, then you can proceed onto #Configure our live medium.

    If you are using the baseline profile to create a bare image, then you won't be needing to do any customisations and can proceed onto #Build the ISO.

    ライブメディアの設定

    This section details configuring the image you will be creating, allowing you to define the packages and configurations you want your live image to contain.

    Change into the directory we created earlier (~/archlive/releng/ if you have been following this guide), you will see a number of files and directories; we are only concerned with a few of these, mainly: packages.* - this is where you list, line by line, the packages you want to have installed, and the airootfs directory - this directory acts as an overlay and it is where you make all the customisations.

    Generally, every administrative task that you would normally do after a fresh install except for package installation can be scripted into ~/archlive/releng/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 32bit or 64bit, respectively.

    I recommend installing "rsync" if you wish to install the system later on with no internet connection or skipping downloading it all over again. (#Installation)

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

    You can also create a custom local repository for the purpose of preparing custom packages or packages from AUR/ABS. When doing so with packages for both architectures, you should follow a certain directory order to not run into problems.

    For instance:

    • ~/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/releng/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
    

    Avoid installation of packages belonging to base group

    By, default /usr/bin/mkarchiso, a script which is used by ~/archlive/releng/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/releng/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/releng/build.sh so that it calls the modified version of the mkarchiso script.
    • Advanced: Create a function for ~/archlive/releng/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.

    ユーザーを追加

    User management can be handled the same way as during the normal installation process, except you put your commands scripted into ~/archlive/releng/airootfs/root/customize_airootfs.sh. For further information have a look at User management.

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

    Note: 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/releng/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; making sure you are within ~/archlive/releng/airootfs/etc directory (if this is where you are working from):

    # cd ~/archlive/releng/airootfs/etc && mkdir skel
    

    Now copy the 'home' files to the skel directory, again doing everything as root! e.g for .bashrc.

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

    When ~/archlive/releng/airootfs/root/customize-airootfs.sh is executed and a new user is created, the files from the skel directory will automatically be copied over to the new home folder, permissions set right.

    ブートローダー

    The default file should work fine, so you should not need to touch it.

    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.

    ログインマネージャ

    Starting X at boot is done by enabling your login manager's systemd service. If you know which .service file needs a softlink: Great. If not, you can easily find out in case you're using the same program on the system you build your iso on. Just use

    # systemctl disable nameofyourloginmanager
    

    to temporarily turn it off. Next type the same command again and replace "disable" with "enable" to activate it again. Systemctl prints information about softlink it creates. Now change to ~/archiso/releng/airootfs/etc/systemd/system and create the same softlink there.

    An example (make sure you're either in ~/archiso/releng/airootfs/etc/systemd/system or add it to the command):

    # ln -s /usr/lib/systemd/system/lxdm.service display-manager.service
    

    This will enable LXDM at system start on your live system.

    自動ログインの変更

    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.

    Build the ISO

    Now you are ready to turn your files into the .iso which you can then burn to CD or USB: Inside the directory you are working with, either ~/archlive/releng, or ~/archlive/baseline, 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/.

    Note: If you want to use a window manager in the Live CD then you must add the necessary and correct video drivers, or the WM may freeze on loading.

    Rebuild the ISO

    If you want to rebuild your iso again after a few modifications, you have to remove lock files in the work directory:

    # rm -v work/build.make_*
    

    ISO を使う

    CD

    Just burn the iso to a cd. You can follow CD Burning as you wish.

    USB

    See USB flash installation media.

    GRUB

    See 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 don't want to download the packages you want again:

    First, please follow the beginners' guide and skip some parts(like #Establish_an_internet_connection) until the #Install_the_base_system step.

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

    Instead of installing the packages with pacstrap(as it downloads every packages from remote repository and we have no Internet access now), please copy everything in the Live environment to the new root:

    # time (cp -ax /{usr,bin,lib,lib64,sbin,etc,home,opt,root,srv,var} /mnt)
    
    Note: This command excludes some special directories, as they should not be copied to the new root.

    Then, create some directories and copy the kernel image to the new root, in order to keep the integrity of the new system:

    # mkdir -vm755 /mnt/{boot,dev,run,mnt}
    # cp -vaT /run/archiso/bootmnt/arch/boot/$(uname -m)/vmlinuz /mnt/boot/vmlinuz-linux
    # mkdir -vm1777 /mnt/tmp
    # mkdir -vm555 /mnt/{sys,proc}
    

    After that, please generate a fstab as described in Beginners' guide#Generate_an_fstab.

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

    Next, chroot into your newly installed system:

    # 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).

    Restore the configuration of 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
    

    Reset the pam's configuration

    This configuration of pam perhaps break the security of your new system, it's recommend to use the default configuration:

    # nano /etc/pam.d/su
    #%PAM-1.0
    auth            sufficient      pam_rootok.so
    # Uncomment the following line to implicitly trust users in the "wheel" group.
    #auth           sufficient      pam_wheel.so trust use_uid
    # Uncomment the following line to require a user to be in the "wheel" group.
    #auth           required        pam_wheel.so use_uid
    auth            required        pam_unix.so
    account         required        pam_unix.so
    session         required        pam_unix.so
    

    Remove special udev rule

    This rule of udev starts the dhcpcd automatically if there are any wired network interfaces.

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

    Disable and remove the services created by 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
    

    Remove special scripts of the Live environment

    There are some scripts installed in the live system by archiso scripts, which are unnecessary for the new system:

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

    arch のパスワードを設定

    The customization script created a normal user called arch for the Live environment. You can set a passwd for user arch in order to login with this username(there is no passwd for arch by default):

    # passwd arch
    

    Or, if you don't want to use this username, please remove this user:

    # userdel -r arch
    

    initial ramdisk 環境を作成

    Please create an initial ramdisk as described in Beginners'_guide#Create_an_initial_ramdisk_environment.

    通常の設定

    After all of these, now you can follow the beginners' guide and finish the installation.

    参照

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

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