Install from existing Linux

From ArchWiki
Revision as of 16:03, 7 November 2012 by Chrisl (Talk | contribs)

Jump to: navigation, search

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

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 enviroment for the arch install scripts

You need to create an enviroment 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.

Here a different methods to prepare that enviroment:

Method: Installing pacman and other packages directly under your current distro

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Needs to be updated for pacman 4, use another method instead (Discuss in Talk:Install from existing Linux#)


You need to get the required packages for your host Linux environment. The examples given here assume you are using an i686 environment. If you are running on a 64-bit Linux instead you should replace each occurrence of "i686" with "x86_64".

All version numbers given here may change. Please check the version numbers the packages are at first and note them down. The version numbers can be found at:

Once you are sure of the version numbers, download the required packages (change the value of ARCH to either x86_64 or i686, see above):

mkdir ${base_chroot}/archlinux
cd ${base_chroot}/archlinux

Download pacman's binaries and shared libraries

You want to install pacman in order to be able to install software in your new base directory. We first download the binaries for pacman, the Arch package manager.

Using wget to download

wget$ARCH/pacman/download/ --no-check-certificate --trust-server-names
wget --no-check-certificate --trust-server-names

or this direct way (give attention to the date string in the file name, as it may need changing) :


See the man page and the official manual of wget for further details.

Using lftp to download

If you have issues with downloading pacman-mirrorlist use this direct way with lftp :

lftp -e "mget pacman-mirrorlist-*.tar.xz" "${link_name}"

Additional libraries

You may need additional libraries to make pacman work, for newer distributions:

for software_name in libarchive openssl xz expat ; do wget$ARCH/${software_name}/download/ --no-check-certificate --trust-server-names ; done

When using an older distribution to bootstrap, a few more libraries may be needed for it to work, for example :

for software_name in glibc gcc-libs binutils libssh2 curl gcc libarchive openssl xz expat ; do wget$ARCH/${software_name}/download/ --no-check-certificate --trust-server-names ; done

Also note that below when you set LD_LIBRARY_PATH you have to add /lib and /lib64:

export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:${base_chroot}/archlinux/lib:${base_chroot}/archlinux/usr/lib64:$LD_LIBRARY_PATH

Unpack all needed packages:

for f in *.pkg.tar*; do tar xvf $f; done

To prepare for using pacman, do not forget to edit /tmp/archlinux/etc/pacman.conf to point to /tmp/archlinux/etc/pacman.d/mirrorlist and select your favorite mirror. For easier use (assuming you are using bash or zsh), you may set up an environment:

export PATH=${base_chroot}/archlinux/usr/bin:$PATH
export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:$LD_LIBRARY_PATH
alias pacman="pacman --config ${base_chroot}/archlinux/etc/pacman.conf"

Install pacman on the host system

Note: (Issues while running pacman on 64-bit host) If while running pacman you end up with /tmp/archlinux/usr/bin/pacman: No such file or directory please symlink ln -s /lib64/ /lib/

If you do not mind littering your install host, you can extract all the downloaded tar balls into your root directory by running as root:

Note: However, keep in mind that this operation could erase some of your files, and break your system.
cd /
for f in /tmp/archlinux/pacman-*pkg.tar.gz ; do
  tar xzf $f
  1. If installing from Ubuntu 9.10's LiveCD (perhaps other versions), you will need more than just the pacman files (shared libs) to use pacman at all. Use Lucky's script described in [this thread] to get/install them for you!
  2. Alternatively, you can instead turn these tarballs into packages for your distribution with the alien tool. See the man page of the tool for instructions. The packages created that way may be installed into your host distribution using the usual package management tools available there. This approach offers the best integration into the host Linux environment. For a Debian package based system this is done with the following commands:
    cd /tmp/archlinux
    alien -d pacman-*-i686.pkg.tar.xz
    alien -d pacman-mirrorlist-20120626-1-any.pkg.tar.xz

    RPM based systems will need to replace the parameter "-d" with "-r".

    These distribution packages can then get installed using the normal package management tools of the host Linux environment.

  3. Under Fedora 12, I was not able to install pacman with any of the other methods, but with the nice script at it will download and install it for you. Worked wonderfully for me.

  4. On Gentoo: Just unmask pacman by adding sys-apps/pacman to /etc/portage/package.keywords. Now just run emerge -av pacman.

    There is also a more detailed tutorial.

Method: Use the alternate easier method

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Needs to be updated for the new install scripts (Discuss in Talk:Install from existing Linux#)

This method is verified to be working as of 1-4-12. 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 && chmod +x

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

./ -a i686 -r "" /mnt/

Or a 64-bit system:

./ -a x86_64 -r "" /mnt/

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

mount -t proc none /mnt/proc
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 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

Or from 32-bit to a 64-bit system:

Architecture = x86_64

Now for the fun part, chroot into your newly installed Arch installation:

chroot /mnt bash
pacman -Sy base
mkinitcpio -p linux

Choose a bootloader. You can find the installation instructions on their own dedicated pages. (Syslinux, Grub, Grub2, etc.).

Remember: You will still need to do any final configuration touches as you would in a normal Arch install.

Credits to the Turkish site Raptiye for the original guide.

Method: Chroot into the Arch Linux LiveCD

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.

Unsquash the root image

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 root image, run

unsquashfs -d /squashfs-root root-image.fs.sfs

Mount root file system

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.

mount -B /squashfs-root ${livecd_arch}

Chroot into the Live CD root file system

Mount various file systems into the Live CD root file system:

mount -t proc /proc ${livecd_arch}/proc
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 /mnt directory from this chroot.

Method: Script to bootstrap the arch install scripts

You can run the following script to automatically download the minimum packages required to run pacman and the arch install scripts. Your current linux enviroment require bash, wget, sed, xz, chroot and tar installed.


Create a file called and put the following content:
# 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
# You can set the ARCH variable to i686 or x86_64
ARCH=`uname -m`
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  
# 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"
# 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 using: 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

Execute it as root:

# bash

The script 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.

After that, 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.

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.

After you have done pacstrap /mnt base base-devel, do also

pacstrap /mnt haveged

That is required later for fixing the pacman keyring.

Edit the fstab file

Probally the genfstab script wont 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.

Fix the Pacman Signature Keyring

After you have entered the 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

Now just do the rest of the steps normally.

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 enought (about 600mb or larger), one path is 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 rsync the entire system there. At that point, next step would be to reconfigure grub or syslinux.