Difference between revisions of "Install from existing Linux"

From ArchWiki
Jump to: navigation, search
m (Method: Chroot into the Arch Linux LiveCD: added pounds)
m (Emphasized the fact that from existing Arch environments the steps are much easier)
(7 intermediate revisions by 4 users not shown)
Line 11: Line 11:
 
This guide is intended for anybody who wants to install Arch Linux from any other running Linux -- be it off a LiveCD or a pre-existing install of a different distro.
 
This guide is intended for anybody who wants to install Arch Linux from any other running Linux -- be it off a LiveCD or a pre-existing install of a different distro.
  
This is useful for building up new Arch Linux systems from scratch from another distro's LiveCD or existing installation. It is also useful for creating new chroot environments on a "host" system, maintaining a "golden-master" for development & distribution, or other fun topics like [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]].
+
This is useful for:
 +
* remotely installing Archlinux (e.g. a (virtual) root server)
 +
* creating a new linux distribution or LiveCD based on Archlinux
 +
* creating an Archlinux chroot environments
 +
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]
  
 
This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs.  In the case of an x86_64 host, it is possible to use i686-pacman to build a 32-bit chroot environment.  See [[Arch64 Install bundled 32bit system]].  However it is not so easy to build a 64-bit environment when the host only supports running 32-bit programs.
 
This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs.  In the case of an x86_64 host, it is possible to use i686-pacman to build a 32-bit chroot environment.  See [[Arch64 Install bundled 32bit system]].  However it is not so easy to build a 64-bit environment when the host only supports running 32-bit programs.
  
If you are already using Arch, instead of following this guide, just install {{Pkg|arch-install-scripts}} from the [[Official Repositories|official repositories]] and follow the [[Installation Guide]].
+
{{Note|If you are already using Arch, instead of following this guide, just install {{Pkg|arch-install-scripts}} from the [[Official Repositories|official repositories]] and follow the [[Installation Guide]]}}
  
 
'''This guide provides additional steps to the [[Installation Guide]]. The steps of that guide must still be followed as needed.'''
 
'''This guide provides additional steps to the [[Installation Guide]]. The steps of that guide must still be followed as needed.'''
Line 23: Line 27:
 
Follow the [[Installation Guide]] steps, until you have your partitions, keyboard and internet connection ready.
 
Follow the [[Installation Guide]] steps, until you have your partitions, keyboard and internet connection ready.
  
==Setup the enviroment for the arch install scripts==
+
==Setup the environment for pacman==
  
You need to create an environment where pacman and the arch install scripts can run on your current linux distro. In addition you will need a list of pacman mirror sites which are going to be used to download data on available packages as well as the packages themselves.
+
You need to create an environment where ''pacman'' and the ''arch install scripts'' can run on your current linux distro. (If you choose the Method 1, only pacman is necessary)
  
Here a different methods to prepare that environment:
+
There are in principle two different methods to prepare that environment: either by '''installing pacman natively''' on your linux distro or by setting up a '''chroot environment'''.
 +
The latter way should in general be considered as easier.
  
===Method: Installing pacman and other packages directly under another distro===
+
Considering the ''chroot'' way one further has two possibilities:
{{Warning|This method is potentially difficult, your mileage may vary from distro to distro. If you just want to do an arch installation from another distro and you are not interested in have pacman as a regular program under such distro, is better to use a different method.}}
+
* '''Using chroot as installation environment''': The prepared Archlinux chroot environment will be used temporarily to set up the actual Archlinux installation using the ''arch-install-scripts''. This is a bit more work and takes longer but once you set up the installation system you can quickly install Archlinux systems. '''However''', if you want to set up only a single Archlinux this might be overkill. You are actually setting up the system twice, have a lot more network traffic and especially need a lot more RAM, mostly due to the quite big iso image.
  
This method is about installing pacman and the arch install scripts directly under another distro, so they become regular programs on that distro.
+
* '''Installing Archlinux directly/Direct Bootstrapping''': Thanks to tokland's ''arch-bootstrap'' script this method is effectively a one-liner and very fast. After that one line of code your Archlinux base system is installed to disk. '''However''', when setting up multiple Archlinux the scripts downloads the base packages every time again.
  
This is really useful if you are planning to use another distro regularly to install arch linux, or do fancy things like updating packages of an arch installation using another distro. This is the only method that not imply creating a chroot to be able to execute pacman and the arch install scripts. (but since part of the installation includes entering inside a chroot, you'll end using a chroot anyway)
+
As a subjective conclusion, I, personally, would recommend using '''Direct bootstrapping''' as long as you want to set up only a small number of systems. If you set up lots of Archlinux based systems the chroot install environment or event the native pacman installation might suite you better.
  
==== Download pacman source code and pacman packages ====
+
===Method 1: Directly bootstrapping Archlinux===
Visit the pacman homepage: https://www.archlinux.org/pacman/#_releases and download the latest release.
+
  
Now, download the following packages:
+
This method will install a basic Archlinux system directly onto your previously prepared root file system mounted as {{ic|/mnt}}. This is known as [http://en.wikipedia.org/wiki/Bootstrapping#Computing bootstrapping].
 +
It is the recommended and easiest way to install an Archlinux from a foreign distribution.
  
* pacman-mirrorlist: https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/
+
It is also possible to set up a separate chroot environment and run the archlinux installer from there, however in this case the first LiveCD-image method above is easier.
* arch-install-scripts: https://www.archlinux.org/packages/extra/any/arch-install-scripts/download/
+
* pacman (necessary for the config files): https://www.archlinux.org/packages/core/x86_64/pacman/download/ (change x86_64 as necessary)
+
==== Install dependencies ====
+
Using your distribution mechanisms, install the required packages for pacman and the arch install scripts. libcurl, libarchive, fakeroot, xz, asciidoc, wget, and sed are among them. Of course, gcc, make and maybe some other "devel" packages are necessary too.
+
  
==== Compile pacman ====
+
This works best if you are in a LiveCD environment or, in the case of servers, a GNU/Linux-based rescue environment.
  
* Decompress the pacman source code and cd inside.
+
As described in the [[Installation Guide]] we assume your disk which should become your root device is mountet at {{ic|/mnt}}. At first grab ''tokland's'' ''arch-bootstrap'' script, c.f. [[Archbootstrap]],
* Execute configure, adapting the paths as necessary: {{bc|<nowiki> ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-doc</nowiki>}}
+
If you get errors here, chances are you are missing dependencies, or your current libcurl, libarchive or others, are too old. Install the dependencies missing using your distro options, or if they are too old, compile them from source.
+
* Compile {{bc|make}}
+
* If there were no errors, install the files {{bc|make install}}
+
* You may need to manually call {{ic|ldconfig}} to make your distro detect libalpm.
+
==== Prepare configuration files ====
+
Now is time to extract the configuration files. Change the x86_64 as necessary.
+
* Extract the pacman.conf and makepkg.conf files from the pacman package, and disable signature checking: {{bc|<nowiki>tar xJvf pacman-*-x86_64.pkg.tar.xz etc -C / ; sed -i 's/SigLevel.*/SigLevel = Never/g' /etc/pacman.conf</nowiki>}}
+
* Extract the mirror list: {{bc|tar xJvf pacman-mirrorlist-*-any.pkg.tar.xz -C /}}
+
* Enable some mirrors on {{ic|/etc/pacman.d/mirrorlist}}
+
* Extract the arch-install-scripts {{bc|tar xJvf arch-install-scripts-*-any.pkg.tar.xz -C /}}
+
  
Another option is using the {{ic|alien}} tool to convert the {{ic|pacman-mirrorlist}} and {{ic|arch-install-scripts}} (but no {{ic|pacman}}) to native packages of your distro.
+
# cd /tmp
 +
# wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh
 +
# chmod +x arch-bootstrap.sh
  
=== Method: Use the alternate easier method ===
+
This script will bootstrap a basic archlinux system, i.e., it will download the linux kernel, pacman basic tools like bash and all needed dependencies and unpack them to the given directory, in this case {{ic|/mnt}}.
{{Out of date|Needs to be updated for the new install scripts}}
+
  
This method is verified to be working as of 1-4-12.
+
{{Note|For an alternative, however, not so sophisticated script check out the  [[#Appendix: Alternative Bootstrapping script|appendix]] of this article}}
This works best if you are in a LiveCD environment (or, in the case of servers, a GNU/Linux-based rescue environment). Firstly, you need to mount the disk you want to use for the Archlinux installation at /mnt. In this example, /dev/sda1 is used.
+
  mnt /dev/sda1 /mnt
+
cd ~
+
wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh && chmod +x arch-bootstrap.sh
+
  
 
If you are wanting to install a 32-bit system:
 
If you are wanting to install a 32-bit system:
  ./arch-bootstrap.sh -a i686 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
+
  # ./arch-bootstrap.sh -a i686 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
 
Or a 64-bit system:
 
Or a 64-bit system:
  ./arch-bootstrap.sh -a x86_64 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
+
  # ./arch-bootstrap.sh -a x86_64 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
  
 
The bootstrapping will take 2-5 minutes depending on the speed of your system.
 
The bootstrapping will take 2-5 minutes depending on the speed of your system.
  
mount -t proc none /mnt/proc
+
If your LiveCD's architecture is not the same as the one of the newly bootstrapped system you might have to change the architecture in {{ic|/etc/pacman.conf}}.
mount -t sysfs none /mnt/sys
+
mount -o bind /dev /mnt/dev
+
  
Mounting these is essential for the installation of a bootloader later on.
+
If your bootstrapped system is 32-bit system:
 
+
If you have switched between architectures, ''pacman'' auto-detection might not work, in this case you need to edit /etc/pacman.conf to:
+
 
+
From 64-bit to a 32-bit system:
+
 
  Architecture = i686
 
  Architecture = i686
Or from 32-bit to a 64-bit system:
+
Or for a 64-bit system:
 
  Architecture = x86_64
 
  Architecture = x86_64
  
Now for the fun part, chroot into your newly installed Arch installation:
+
Before chrooting into the newly created system we need to set up some mount points.
  chroot /mnt bash
+
This is essential for the installation of a bootloader later on, c.f. [[Change Root]].
  pacman -Sy base
+
  # mount -t proc none /mnt/proc
  mkinitcpio -p linux
+
  # mount -t sysfs none /mnt/sys
 +
  # mount -o bind /dev /mnt/dev
 +
# mount -o bind /dev/pts /mnt/dev/pts # important for pacman (for signature check)
  
Choose a bootloader. You can find the installation instructions on their own dedicated pages. ([[Syslinux]], [[Grub]], [[Grub2]], etc.).
+
Now everything is prepared to chroot into your newly installed Arch environment
 +
# chroot /mnt bash
  
'''Remember:''' You will still need to do any final configuration touches as you would in a normal Arch install.
+
Before you can use ''pacman'' you have to initialize its keyring as explained below, in [[#Fix the Pacman Signature Keyring]].
  
''Credits to the Turkish site [http://raptiye.org/blog/2011/3/27/hetznerde-arch-linux-kurulumu/ Raptiye] for the original guide.''
+
From here on proceed with [[Installation Guide#Install the base system]], '''but''' remember, you are already working in your final system, thus no need for {{ic|pacstrap}}, simply use {{ic|pacman}}. So the next command you are most likely to execute will be
  
 +
  # pacman -S base # and evtl. also base-devel
  
===Method: Chroot into the Arch Linux LiveCD===
+
''Credit goes to [https://github.com/tokland Arnau Sanchez] alias tokland, the author of the arch-bootstrap script.''
  
Alternatively, you can mount the root image of the latest archlinux installation media and then chroot into it. This method has the advantage of providing you with a working Arch Linux installation right within your host system without the need to prepare it by installing specific packages.
+
===Method 2: Chroot into LiveCD-image===
  
====Unsquash the root image====
+
It is possible to mount the root image of the latest Archlinux installation media and then chroot into it. This method has the advantage of providing you with a working Arch Linux installation right within your host system without the need to prepare it by installing specific packages.
  
Mount the Live CD image:
+
{{Note|Before proceeding, make sure the latest version of {{Pkg|squashfs-tools}} is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}
# mount -o loop archlinux-{date}-dual.iso /mnt
+
  
The root image exists in squashfs format on the Live CD. The squashfs format is not editable as such. Hence, we unsquash the root image and then mount it.
+
* Download the lastest installation CD image from https://www.archlinux.org/download/
  
To unsquash the x86_64 root image, run
+
* Mount the Live CD image:
# unsquashfs -d /squashfs-root /mnt/arch/x86_64/root-image.fs.sfs
+
{{bc|# mount -o loop archlinux-{date}-dual.iso /mnt}}
  
For i686 replace in above command accordingly.
+
* The root image exists in [[Wikipedia:Squashfs|squashfs format]] on the Live CD. The squashfs format is not editable as such. Hence, we unsquash the root image and then mount it.
  
{{Note|Make sure the latest version of {{Pkg|squashfs-tools}} is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}
+
To unsquash the x86_64 (or i686 respectively) root image, run
 +
{{bc|# unsquashfs -d /squashfs-root /mnt/arch/x86_64/root-image.fs.sfs}}
  
====Mount root file system====
+
* Now you can unmount and remove the iso image
 +
{{bc|
 +
# umount /mnt
 +
# rm archlinux-{date}-dual.iso
 +
}}
  
Then, mount the unsquashed root file system to a suitable mount point. We shall mount it to /arch. You can mount it wherever you want.
+
* Now you can loop mount the root image
# livecd_arch=/arch
+
{{bc|# mount -o loop /squashfs-root/root-image.fs /arch}}
# mount /squashfs-root/root-image.fs ${livecd_arch}
+
  
====Chroot into the Live CD root file system====
+
* Before [[Change Root|chrooting]] to it, we need to set up some mount points.
 +
{{bc|
 +
# mount -t proc none /arch/proc
 +
# mount -t sysfs none /arch/sys
 +
# mount -o bind /dev /arch/dev
 +
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)
 +
}}
  
Mount various file systems into the Live CD root file system:
+
* Now everything is prepared to chroot into your newly installed Arch environment
# mount -t proc /proc ${livecd_arch}/proc
+
{{bc|# chroot /arch bash}}
# mount -t sysfs /sys ${livecd_arch}/sys
+
# mount -B /dev ${livecd_arch}/dev
+
# mount -t devpts /dev/pts ${livecd_arch}/dev/pts
+
 
+
Then, chroot into the Live CD root file system:
+
# chroot ${livecd_arch} /bin/bash
+
  
 
This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the {{ic|/mnt}} directory from this chroot.
 
This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the {{ic|/mnt}} directory from this chroot.
  
===Method: Script to bootstrap the arch install scripts===
+
===Method 3: Bootstrapping the arch installation scripts===
  
You can run the following script to automatically download the minimum packages required to run pacman and the arch install scripts.
+
Contrary to the other methods, '''this method is one-step only'''; you only have to execute the script below and thats it.
Your current linux environment require bash, wget, sed, xz, chroot and tar installed.
+
 
====Script====
+
This method can be considered an hybrid between Method 1 and Method 2. It provides a chroot enviroment from where to execute the arch install scripts (similar to Method 2), by using a bootstrapping script (similar to Method 1).
Create a file called archinstall-bootstrap.sh and put the following content:
+
 
 +
The script below is going to create a directory called {{ic|archinstall-pkg}} and download the required packages there. Then, is going to extract them into the {{ic|archinstall-chroot}} directory. Finally, is going to prepare mount points, configure pacman and enter into a chroot.
 +
 
 +
This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the {{ic|/mnt}} directory from this chroot.
  
 
{{hc|archinstall-bootstrap.sh|<nowiki>
 
{{hc|archinstall-bootstrap.sh|<nowiki>
Line 197: Line 188:
 
</nowiki>}}
 
</nowiki>}}
  
Execute it as root:
+
===Method 4: Install pacman natively on non-arch distro (advanced)===
# bash archinstall-bootstrap.sh
+
{{Warning|This method is potentially difficult, your mileage may vary from distro to distro. If you just want to do an arch installation from another distro and you are not interested in have pacman as a regular program under such distro, is better to use a different method.}}
The script is going to create a directory called {{ic|archinstall-pkg}} and download the required packages there. Then, is going to extract them into the {{ic|archinstall-chroot}} directory.
+
  
After that, is going to prepare mount points, configure pacman and enter into a chroot.
+
This method is about installing pacman and the arch install scripts directly under another distro, so they become regular programs on that distro.
 +
 
 +
This is really useful if you are planning to use another distro regularly to install arch linux, or do fancy things like updating packages of an arch installation using another distro. This is the only method that not imply creating a chroot to be able to execute pacman and the arch install scripts. (but since part of the installation includes entering inside a chroot, you'll end using a chroot anyway)
 +
 
 +
==== Download pacman source code and pacman packages ====
 +
Visit the pacman homepage: https://www.archlinux.org/pacman/#_releases and download the latest release.
 +
 
 +
Now, download the following packages:
 +
 
 +
* pacman-mirrorlist: https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/
 +
* arch-install-scripts: https://www.archlinux.org/packages/extra/any/arch-install-scripts/download/
 +
* pacman (necessary for the config files): https://www.archlinux.org/packages/core/x86_64/pacman/download/ (change x86_64 as necessary)
 +
 
 +
==== Install dependencies ====
 +
Using your distribution mechanisms, install the required packages for pacman and the arch install scripts. libcurl, libarchive, fakeroot, xz, asciidoc, wget, and sed are among them. Of course, gcc, make and maybe some other "devel" packages are necessary too.
 +
 
 +
==== Compile pacman ====
 +
 
 +
* Decompress the pacman source code and cd inside.
 +
* Execute configure, adapting the paths as necessary: {{bc|<nowiki> ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-doc</nowiki>}}
 +
If you get errors here, chances are you are missing dependencies, or your current libcurl, libarchive or others, are too old. Install the dependencies missing using your distro options, or if they are too old, compile them from source.
 +
* Compile {{bc|make}}
 +
* If there were no errors, install the files {{bc|make install}}
 +
* You may need to manually call {{ic|ldconfig}} to make your distro detect libalpm.
 +
==== Prepare configuration files ====
 +
Now is time to extract the configuration files. Change the x86_64 as necessary.
 +
* Extract the pacman.conf and makepkg.conf files from the pacman package, and disable signature checking: {{bc|<nowiki>tar xJvf pacman-*-x86_64.pkg.tar.xz etc -C / ; sed -i 's/SigLevel.*/SigLevel = Never/g' /etc/pacman.conf</nowiki>}}
 +
* Extract the mirror list: {{bc|tar xJvf pacman-mirrorlist-*-any.pkg.tar.xz -C /}}
 +
* Enable some mirrors on {{ic|/etc/pacman.d/mirrorlist}}
 +
* Extract the arch-install-scripts {{bc|tar xJvf arch-install-scripts-*-any.pkg.tar.xz -C /}}
 +
 
 +
Another option is using the {{ic|alien}} tool to convert the {{ic|pacman-mirrorlist}} and {{ic|arch-install-scripts}} (but no {{ic|pacman}}) to native packages of your distro.
 +
 
 +
 
 +
==Fix the Pacman Signature Keyring==
 +
 
 +
It is necessary to initialize ''pacman's'' keyring for signature checking.
 +
 
 +
This is done using
 +
# pacman-key --init # read the note below!
 +
# pacman-key --populate archlinux
 +
 
 +
'''However''', when connected via SSH you might run out of [http://en.wikipedia.org/wiki/Entropy_(computing) entropy]. In this case you can try something like
 +
 
 +
# cat /usr/bin/* > /dev/null &
 +
# find / > /dev/null &
 +
 
 +
before executing {{ic|pacman-key --init}}.
 +
 
 +
It might take some time. If nevertheless all this does help install {{Pkg|haveged}} and run prior to {{ic|pacman-key --init}}
 +
# /usr/sbin/haveged -w 1024 -v 1
  
This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the {{ic|/mnt}} directory from this chroot.
 
  
 
==Setup the target system==
 
==Setup the target system==
Line 209: Line 248:
 
At this point, follow the normal steps of [[Installation Guide]]. Remember to mount the destination partition under the {{ic|/mnt}} of the chroot.
 
At this point, follow the normal steps of [[Installation Guide]]. Remember to mount the destination partition under the {{ic|/mnt}} of the chroot.
  
After you have done {{ic|pacstrap /mnt base base-devel}}, do also
+
# pacstrap /mnt base base-devel
  pacstrap /mnt haveged
+
  # # ...
 
+
That is required later for fixing the pacman keyring.
+
  
 
===Edit the fstab file===
 
===Edit the fstab file===
  
Probably the {{ic|genfstab}} script wont work. In that case, you'll need to edit the {{ic|/mnt/etc/fstab}} file by hand.
+
Probably the {{ic|genfstab}} script won't work. In that case, you'll need to edit the {{ic|/mnt/etc/fstab}} file by hand.
 
You can use the content of {{ic|/etc/mtab}} as reference.
 
You can use the content of {{ic|/etc/mtab}} as reference.
  
===Fix the Pacman Signature Keyring===
 
 
After you have entered the {{ic|arch-chroot /mnt}}, is necessary to fix the pacman signature keyring.
 
This will fix it:
 
# /usr/sbin/haveged -w 1024 -v 1
 
# pacman-key --init
 
# pacman -U /var/cache/pacman/pkg/archlinux-keyring*
 
 
===Finish the Installation===
 
===Finish the Installation===
 
Now just do the rest of the steps normally.
 
Now just do the rest of the steps normally.
 +
 
==Tips and tricks==
 
==Tips and tricks==
* If you are using this method because you are trying to do a remote install, like a vps, and can't umount the root partition, and, assuming the system has a swap partition large enough (about 600mb or larger), one path is to delete that partition, create the partitions for arch in that area, and install arch there (only base, not base-devel). Once the system is installed, you can reboot to your new arch system, reformat the former partitions, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] there. At that point, next step would be to reconfigure grub or syslinux.
+
* In case you want to replace an existing system, but can for some reason not use a LiveCD, since, e.g., you have no physical access to the computer, the following tip might help: If you manage to get ~500MB of free space somewhere on the disk (e.g. by partitioning a swap partition) you can install the new Archlinux system there, reboot into the newly created system and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition. Finally don't forget to fix the bootloader configuration before rebooting.

Revision as of 11:35, 6 January 2013


This guide is intended for anybody who wants to install Arch Linux from any other running Linux -- be it off a LiveCD or a pre-existing install of a different distro.

This is useful for:

  • remotely installing Archlinux (e.g. a (virtual) root server)
  • creating a new linux distribution or LiveCD based on Archlinux
  • creating an Archlinux chroot environments
  • rootfs-over-NFS for diskless machines

This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs. In the case of an x86_64 host, it is possible to use i686-pacman to build a 32-bit chroot environment. See Arch64 Install bundled 32bit system. However it is not so easy to build a 64-bit environment when the host only supports running 32-bit programs.

Note: If you are already using Arch, instead of following this guide, just install arch-install-scripts from the official repositories and follow the Installation Guide

This guide provides additional steps to the Installation Guide. The steps of that guide must still be followed as needed.

Prepare the system

Follow the Installation Guide steps, until you have your partitions, keyboard and internet connection ready.

Setup the environment for pacman

You need to create an environment where pacman and the arch install scripts can run on your current linux distro. (If you choose the Method 1, only pacman is necessary)

There are in principle two different methods to prepare that environment: either by installing pacman natively on your linux distro or by setting up a chroot environment. The latter way should in general be considered as easier.

Considering the chroot way one further has two possibilities:

  • Using chroot as installation environment: The prepared Archlinux chroot environment will be used temporarily to set up the actual Archlinux installation using the arch-install-scripts. This is a bit more work and takes longer but once you set up the installation system you can quickly install Archlinux systems. However, if you want to set up only a single Archlinux this might be overkill. You are actually setting up the system twice, have a lot more network traffic and especially need a lot more RAM, mostly due to the quite big iso image.
  • Installing Archlinux directly/Direct Bootstrapping: Thanks to tokland's arch-bootstrap script this method is effectively a one-liner and very fast. After that one line of code your Archlinux base system is installed to disk. However, when setting up multiple Archlinux the scripts downloads the base packages every time again.

As a subjective conclusion, I, personally, would recommend using Direct bootstrapping as long as you want to set up only a small number of systems. If you set up lots of Archlinux based systems the chroot install environment or event the native pacman installation might suite you better.

Method 1: Directly bootstrapping Archlinux

This method will install a basic Archlinux system directly onto your previously prepared root file system mounted as /mnt. This is known as bootstrapping. It is the recommended and easiest way to install an Archlinux from a foreign distribution.

It is also possible to set up a separate chroot environment and run the archlinux installer from there, however in this case the first LiveCD-image method above is easier.

This works best if you are in a LiveCD environment or, in the case of servers, a GNU/Linux-based rescue environment.

As described in the Installation Guide we assume your disk which should become your root device is mountet at /mnt. At first grab tokland's arch-bootstrap script, c.f. Archbootstrap,

# cd /tmp
# wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh
# chmod +x arch-bootstrap.sh

This script will bootstrap a basic archlinux system, i.e., it will download the linux kernel, pacman basic tools like bash and all needed dependencies and unpack them to the given directory, in this case /mnt.

Note: For an alternative, however, not so sophisticated script check out the appendix of this article

If you are wanting to install a 32-bit system:

# ./arch-bootstrap.sh -a i686 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/

Or a 64-bit system:

# ./arch-bootstrap.sh -a x86_64 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/

The bootstrapping will take 2-5 minutes depending on the speed of your system.

If your LiveCD's architecture is not the same as the one of the newly bootstrapped system you might have to change the architecture in /etc/pacman.conf.

If your bootstrapped system is 32-bit system:

Architecture = i686

Or for a 64-bit system:

Architecture = x86_64

Before chrooting into the newly created system we need to set up some mount points. This is essential for the installation of a bootloader later on, c.f. Change Root.

# mount -t proc none /mnt/proc
# mount -t sysfs none /mnt/sys
# mount -o bind /dev /mnt/dev
# mount -o bind /dev/pts /mnt/dev/pts # important for pacman (for signature check)

Now everything is prepared to chroot into your newly installed Arch environment

# chroot /mnt bash

Before you can use pacman you have to initialize its keyring as explained below, in #Fix the Pacman Signature Keyring.

From here on proceed with Installation Guide#Install the base system, but remember, you are already working in your final system, thus no need for pacstrap, simply use pacman. So the next command you are most likely to execute will be

 # pacman -S base # and evtl. also base-devel

Credit goes to Arnau Sanchez alias tokland, the author of the arch-bootstrap script.

Method 2: Chroot into LiveCD-image

It is possible to mount the root image of the latest Archlinux installation media and then chroot into it. This method has the advantage of providing you with a working Arch Linux installation right within your host system without the need to prepare it by installing specific packages.

Note: Before proceeding, make sure the latest version of squashfs-tools is installed on the host system. Otherwise you will get errors like: FATAL ERROR aborting: uncompress_inode_table: failed to read block.
  • Mount the Live CD image:
# mount -o loop archlinux-{date}-dual.iso /mnt
  • The root image exists in squashfs format on the Live CD. The squashfs format is not editable as such. Hence, we unsquash the root image and then mount it.

To unsquash the x86_64 (or i686 respectively) root image, run

# unsquashfs -d /squashfs-root /mnt/arch/x86_64/root-image.fs.sfs
  • Now you can unmount and remove the iso image
# umount /mnt
# rm archlinux-{date}-dual.iso
  • Now you can loop mount the root image
# mount -o loop /squashfs-root/root-image.fs /arch
  • Before chrooting to it, we need to set up some mount points.
# mount -t proc none /arch/proc
# mount -t sysfs none /arch/sys
# mount -o bind /dev /arch/dev
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)
  • Now everything is prepared to chroot into your newly installed Arch environment
# chroot /arch bash

This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the /mnt directory from this chroot.

Method 3: Bootstrapping the arch installation scripts

Contrary to the other methods, this method is one-step only; you only have to execute the script below and thats it.

This method can be considered an hybrid between Method 1 and Method 2. It provides a chroot enviroment from where to execute the arch install scripts (similar to Method 2), by using a bootstrapping script (similar to Method 1).

The script below is going to create a directory called archinstall-pkg and download the required packages there. Then, is going to extract them into the archinstall-chroot directory. Finally, is going to prepare mount points, configure pacman and enter into a chroot.

This chroot is able to execute the arch install scripts. The destination partitions should be mounted under the /mnt directory from this chroot.

archinstall-bootstrap.sh
#!/bin/bash
# This script is inspired on the archbootstrap script.

PACKAGES=(acl attr bzip2 curl expat glibc gpgme libarchive libassuan libgpg-error libssh2 openssl pacman xz zlib pacman-mirrorlist coreutils bash grep gawk file tar ncurses readline libcap util-linux pcre arch-install-scripts)
# Change the mirror as necessary
MIRROR='http://mirrors.kernel.org/archlinux' 
# You can set the ARCH variable to i686 or x86_64
ARCH=`uname -m`
LIST=`mktemp`
CHROOT_DIR=archinstall-chroot
DIR=archinstall-pkg
mkdir -p "$DIR"
mkdir -p "$CHROOT_DIR"
# Create a list with urls for the arch packages
for REPO in core community extra; do  
        wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed  -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST  
done
# Download and extract each package.
for PACKAGE in ${PACKAGES[*]}; do
        URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`
        FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`
        wget "$URL" -c -O "$DIR/$FILE" 
        xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"
done
# Create mount points
mkdir -p "$CHROOT_DIR/dev" "$CHROOT_DIR/proc" "$CHROOT_DIR/sys" "$CHROOT_DIR/mnt"
mount -t proc proc "$CHROOT_DIR/proc/"
mount -t sysfs sys "$CHROOT_DIR/sys/"
mount -o bind /dev "$CHROOT_DIR/dev/"
mkdir -p "$CHROOT_DIR/dev/pts"
mount -t devpts pts "$CHROOT_DIR/dev/pts/"

# Hash for empty password  Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)
echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"
echo "root:x:0:0:root:/root:/bin/bash" > "$CHROOT_DIR/etc/passwd" 
touch "$CHROOT_DIR/etc/group"
echo "myhost" > "$CHROOT_DIR/etc/hostname"
test -e "$CHROOT_DIR/etc/mtab" || echo "rootfs / rootfs rw 0 0" > "$CHROOT_DIR/etc/mtab"
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"
sed -ni '/^[ \t]*CheckSpace/ !p' "$CHROOT_DIR/etc/pacman.conf"
sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$CHROOT_DIR/etc/pacman.conf"
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"

chroot $CHROOT_DIR /usr/bin/pacman -Sy 
chroot $CHROOT_DIR /bin/bash

Method 4: Install pacman natively on non-arch distro (advanced)

Warning: This method is potentially difficult, your mileage may vary from distro to distro. If you just want to do an arch installation from another distro and you are not interested in have pacman as a regular program under such distro, is better to use a different method.

This method is about installing pacman and the arch install scripts directly under another distro, so they become regular programs on that distro.

This is really useful if you are planning to use another distro regularly to install arch linux, or do fancy things like updating packages of an arch installation using another distro. This is the only method that not imply creating a chroot to be able to execute pacman and the arch install scripts. (but since part of the installation includes entering inside a chroot, you'll end using a chroot anyway)

Download pacman source code and pacman packages

Visit the pacman homepage: https://www.archlinux.org/pacman/#_releases and download the latest release.

Now, download the following packages:

Install dependencies

Using your distribution mechanisms, install the required packages for pacman and the arch install scripts. libcurl, libarchive, fakeroot, xz, asciidoc, wget, and sed are among them. Of course, gcc, make and maybe some other "devel" packages are necessary too.

Compile pacman

  • Decompress the pacman source code and cd inside.
  • Execute configure, adapting the paths as necessary:
     ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-doc

If you get errors here, chances are you are missing dependencies, or your current libcurl, libarchive or others, are too old. Install the dependencies missing using your distro options, or if they are too old, compile them from source.

  • Compile
    make
  • If there were no errors, install the files
    make install
  • You may need to manually call ldconfig to make your distro detect libalpm.

Prepare configuration files

Now is time to extract the configuration files. Change the x86_64 as necessary.

  • Extract the pacman.conf and makepkg.conf files from the pacman package, and disable signature checking:
    tar xJvf pacman-*-x86_64.pkg.tar.xz etc -C / ; sed -i 's/SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
  • Extract the mirror list:
    tar xJvf pacman-mirrorlist-*-any.pkg.tar.xz -C /
  • Enable some mirrors on /etc/pacman.d/mirrorlist
  • Extract the arch-install-scripts
    tar xJvf arch-install-scripts-*-any.pkg.tar.xz -C /

Another option is using the alien tool to convert the pacman-mirrorlist and arch-install-scripts (but no pacman) to native packages of your distro.


Fix the Pacman Signature Keyring

It is necessary to initialize pacman's keyring for signature checking.

This is done using

# pacman-key --init # read the note below!
# pacman-key --populate archlinux

However, when connected via SSH you might run out of entropy. In this case you can try something like

# cat /usr/bin/* > /dev/null &
# find / > /dev/null &

before executing pacman-key --init.

It might take some time. If nevertheless all this does help install haveged and run prior to pacman-key --init

# /usr/sbin/haveged -w 1024 -v 1


Setup the target system

At this point, follow the normal steps of Installation Guide. Remember to mount the destination partition under the /mnt of the chroot.

# pacstrap /mnt base base-devel
# # ...

Edit the fstab file

Probably the genfstab script won't work. In that case, you'll need to edit the /mnt/etc/fstab file by hand. You can use the content of /etc/mtab as reference.

Finish the Installation

Now just do the rest of the steps normally.

Tips and tricks

  • In case you want to replace an existing system, but can for some reason not use a LiveCD, since, e.g., you have no physical access to the computer, the following tip might help: If you manage to get ~500MB of free space somewhere on the disk (e.g. by partitioning a swap partition) you can install the new Archlinux system there, reboot into the newly created system and rsync the entire system to the primary partition. Finally don't forget to fix the bootloader configuration before rebooting.