Install from existing Linux
zh-TW:Install from Existing Linux 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.
Installing Arch Linux from a running Linux is useful for:
- remotely installing Arch Linux, e.g. a (virtual) root server
- replacing an existing Linux without a LiveCD (see #Replacing the Existing System without a LiveCD)
- creating a new Linux distribution or LiveCD based on Arch Linux
- creating an Arch Linux chroot environment, e.g. for a Docker base container
- rootfs-over-NFS for diskless machines
The goal of the bootstrapping procedure is to setup an environment from which the scripts from
arch-chroot) can be run.
If the host system runs Arch Linux, this is can be achieved by simply installing. If the host system runs another Linux distribution, you will first need to set up an Arch Linux-based chroot.
- 1 From a host running Arch Linux
- 2 From a host running another Linux distribution
- 3 Replacing the Existing System without a LiveCD
From a host running Arch Linux
Install official repositories.from the
Follow Installation guide#Mount the partitions. If you already use the
/mnt directory for something else, just create another directory such as
/mnt/install, and use that instead.
From a host running another Linux distribution
The idea is to run an Arch system inside the host system. The actual installation is then executed from this Arch system. This nested system is contained inside a chroot. Two methods to setup and enter this chroot are presented below, from the easiest to the most complicated.
Creating the chroot
Method 1: Using the Bootstrap Image (recommended)
Download the bootstrap image from a mirror:
$ curl -O https://mirrors.kernel.org/archlinux/iso/2015.05.01/archlinux-bootstrap-2015.05.01-x86_64.tar.gz
Extract the tarball:
# cd /tmp # tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2015.05.01-x86_64.tar.gz
Select a repository server:
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist
/tmp/root.i686/etc/pacman.confand explicitly define
Architecture = i686in order for pacman to pull the proper i686 packages.
Enter the chroot
- If bash 4 or later is installed:
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/
- Else run the following commands:
# cd /tmp/root.x86_64 # cp /etc/resolv.conf etc # mount -t proc /proc proc # mount --rbind /sys sys # mount --rbind /dev dev # mount --rbind /run run (assuming /run exists on the system) # chroot /tmp/root.x86_64 /bin/bash
Method 2: 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.
FATAL ERROR aborting: uncompress_inode_table: failed to read block.
- The root image can be found on one of the mirrors under either arch/x86_64/ or arch/i686/ depending on the desired architecture. The squashfs format is not editable so we unsquash the root image and then mount it.
- To unsquash the root image, run
# unsquashfs -d /squashfs-root root-image.fs.sfs
- Now loop mount the root image
# mkdir /arch # mount -o loop /squashfs-root/root-image.fs /arch
- Before chrooting to it, we need to set up some mount points and copy the resolv.conf for networking.
# 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) # cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot
- Now everything is prepared to chroot into the newly installed Arch environment
# chroot /arch bash
Using the chroot Environment
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
On Debian-based host systems,
pacstrap produces 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
In Debian, /dev/shm points to /run/shm. However, 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
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 doesn't use lvmetad by default (security purpose they say). You need to edit /etc/lvm/lvm.conf and put use_lvmetad to 0:
use_lvmetad = 0
This will trigger later an error on boot in the initrd stage, therefore, you have to change it back after the grub generation. In a Software RAID + LVM, steps would be the following:
- After installing all the system, when you have to do all the initramfs (mkinitcpio) and grub thing.
- Change /etc/mdadm.conf to reflect your RAID config (if any)
- Change HOOKS and MODULES according to lvm and raid requirements (MODULES="dm_mod" HOOKS="base udev mdadm_udev ... block lvm2 filesystems ..."
- Generate initrd images with mkinitcpio
- Change /etc/lvm/lvm.conf to put use_lvmetad = 0
- Generate grub config (grub-mkconfig)
- Change /etc/lvm/lvm.conf to put use_lvmetad = 1
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.
Configure the system
Replacing the Existing System without a LiveCD
Find ~650MB of free space somewhere on the disk, e.g. by partitioning a swap partition. If less than 600mb 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.