The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.

The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.

Line 86:

Line 86:

Download the bootstrap image from a [https://www.archlinux.org/download mirror]:

Download the bootstrap image from a [https://www.archlinux.org/download mirror]:

Revision as of 04:15, 15 March 2018

This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.
After bootstrapping, the installation proceeds as described in the Installation guide.

The goal of the bootstrapping procedure is to setup an environment from which the scripts from arch-install-scripts (such as pacstrap and arch-chroot) can be run.

If the host system runs Arch Linux, this can be achieved by simply installing arch-install-scripts. If the host system runs another Linux distribution, you will first need to set up an Arch Linux-based chroot.

Note: This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs. This means it has to be an x86_64 host.

Warning: Please make sure you understand each step before proceeding. It is easy to destroy your system or to lose critical data, and your service provider will likely charge a lot to help you recover.

Delete /etc/machine-id so that a new, unique, one will be regenerated on boot

Make any other changes appropriate to the installation medium

Install the bootloader

When copying the filesystem root, use something like cp -ax or rsync -axX. This avoids copying contents of mountpoints (-x), and preserves the capabilities attributes of some system binaries (rsync -X).

From a host running another Linux distribution

There are multiple tools which automate a large part of the steps described in the following subsections. See their respective homepages for detailed instructions.

The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.

Creating the chroot

Two methods to setup and enter the chroot are presented below, from the easiest to the most complicated. Select only one of the two methods. Then, continue at #Using the chroot environment.

Method B: Using the LiveCD image

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

Note: Before proceeding, make sure the latest version of squashfs is installed on the host system. Otherwise, errors like the following are to be expected: FATAL ERROR aborting: uncompress_inode_table: failed to read block.

The root image can be found on one of the mirrors under arch/x86_64/. The squashfs format is not editable, so we unsquash the root image and mount it.

To unsquash the root image, run

# unsquashfs airootfs.sfs

Before chrooting to it, we need to set up some mount points and copy the resolv.conf for networking.

Now, everything is prepared to chroot into the newly installed Arch environment

# chroot squashfs-root bash

Using the chroot environment

The bootstrap environment is really barebones (no nano, no ping, no cryptsetup, no lvm). Therefore, we need to set up pacman in order to download the rest of the base and, if needed, base-devel.

Initializing pacman keyring

Before starting the installation, pacman keys need to be setup. Before running the following two commands, read pacman-key#Initializing the keyring to understand the entropy requirements:

# pacman-key --init
# pacman-key --populate archlinux

Tip: Installing and running haveged must be done on the host system, since it is not possible to install packages before initializing pacman keyring and because systemd will detect it is running in a chroot and ignore activation request.
If you go with doing ls -Ra / in another console (TTY, terminal, SSH session...), do not be afraid of running it in a loop a few times: five or six runs from the host proved sufficient to generate enough entropy on a remote headless server.

Installation tips

Some host systems or configurations may require certain extra steps. See the sections below for tips.

Debian-based host

/dev/shm

On some Debian-based host systems, pacstrap may produce the following error:

# pacstrap /mnt base

==> Creating install root at /mnt
mount: mount point /mnt/dev/shm is a symbolic link to nowhere
==> ERROR: failed to setup API filesystems in new root

This is because in some versions of Debian, /dev/shm points to /run/shm while in the Arch-based chroot, /run/shm does not exist and the link is broken. To correct this error, create a directory /run/shm:

# mkdir /run/shm

/dev/pts

While installing archlinux-2015.07.01-x86_64 from a Debian 7 host, the following error prevented both pacstrap and arch-chroot from working:

lvmetad

Trying to create LVMlogical volumes from an archlinux-bootstrap-2015.07.01-x86_64 environment on a Debian 7 host resulted in the following error:

# lvcreate -L 20G lvm -n root

/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
/dev/lvm/root: not found: device not cleared
Aborting. Failed to wipe start of new LV.

(Physical volume and volume group creation worked despite /run/lvm/lvmetad.socket: connect failed: No such file or directory being displayed.)

This could be easily worked around by creating the logical volumes outside the chroot (from the Debian host). They are then available once chrooted again.

The factual accuracy of this article or section is disputed.

Reason: This problem did not arise when installing from a Debian 7 host without lvmetad enabled. The recommended messaround with /etc/lvm/lvm.conf looks rather error prone (2015-07-26). (Discuss in Talk:Install from existing Linux#)

Also, if the system you are using has lvm, you might have the following output:

# grub-install --target=i386-pc --recheck /dev/mapper/main-archroot

Installing for i386-pc platform.
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.

This is because debian does not use lvmetad by default. You need to edit /etc/lvm/lvm.conf and set use_lvmetad to 0:

Fedora-based host

On Fedora based hosts and live USBs you may encounter problems when using genfstab to generate your fstab. Remove duplicate entries and the "seclabel" option where it appears, as this is Fedora-specific and will keep your system from booting normally.

Things to check before you reboot

Before rebooting, chroot into the newly-installed system.

Make sure to create a user with password, so you can login via ssh. Root login is disabled by default since OpenSSH-7.1p2.

Set up a boot loader and configure it to use the swap partition you appropriated earlier as the root partition. You might want to configure your bootloader to be able to boot into your old system; it is helpful to re-use the server's existing /boot partition in the new system for this purpose.

Replacing the existing system without a LiveCD

Find ~700MB of free space somewhere on the disk, e.g. by partitioning a swap partition. You can disable the swap partition and set up your system there.

Set old swap partition as new root partition

Check cfdisk, /proc/swaps or /etc/fstab to find your swap partition. Assuming your hard drive is located on sdaX (X will be a number).

Finally, mount the new directory for installing the intermediate system.

# mount -t ext4 /dev/sdaX /mnt/newsys

Installation

If less than 700MB are available, examine the packages in the group base, and select only those required to get a system with internet connection up and running in the temporary partition. This will mean explicitly specifying individual packages to pacstrap, as well as passing it the -c option, to get packages downloaded to the host system to avoid filling up valuable space.

Once the new Arch Linux system is installed, reboot into the newly created system, and rsync the entire system to the primary partition.
Fix the bootloader configuration before rebooting.