Difference between revisions of "Install from existing Linux"

From ArchWiki
Jump to: navigation, search
m (Prepare /dev nodes: added force flag)
m (Typos, grammar, consistency (article said it assumes i686, helped it do so), tar.gz -> tar.xz, and added article link.)
Line 11: Line 11:
 
Arch Linux's [[pacman]] can be configured (-r) to perform operations in any directory you like, using that as the context of "root" while running.  
 
Arch Linux's [[pacman]] can be configured (-r) to perform operations in any directory you like, using that as the context of "root" while running.  
 
   
 
   
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 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 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.
Line 32: Line 32:
 
==Setup the host system==
 
==Setup the host system==
  
You need to install the archlinux package manager pacman on your host linux environment. In addition you will need a list of pacman mirrors sites which is used to download data on available packages as well as the packages themselves. If you are already using arch, skip this step and go to [[Install from Existing Linux#Setup the target system]].
+
You need to install the Arch Linux package manager, pacman, on your host Linux environment. In addition you will need a list of pacman mirror sites which is used to download data on available packages as well as the packages themselves. If you are already using Arch, skip this step and go to [[Install from Existing Linux#Setup the target system]].
  
 
===Get the required packages===
 
===Get the required packages===
Line 38: Line 38:
 
====Introduction====
 
====Introduction====
  
You need to get the required packages for your host linux environment. The examples given here assume you are using a i686 environment. '''If you are running on an 64bit linux instead you should replace each occurance of "i686" with "x86_64".'''
+
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:
+
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:
 
* {{pkg|pacman}}
 
* {{pkg|pacman}}
 
* {{pkg|pacman-mirrorlist}}
 
* {{pkg|pacman-mirrorlist}}
  
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):
+
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):
  
 
  ARCH=i686
 
  ARCH=i686
Line 53: Line 53:
 
====Download the pacman's binaries and shared libraries====
 
====Download the pacman's binaries and shared libraries====
  
You want to install pacman in the order to be able to install softwares in your new base directory. We first download the binaries for [[pacman]], the arch package manager.
+
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.
* pacman: https://www.archlinux.org/packages/core/$ARCH/pacman/download/ . Change $ARCH according to your system  
+
* pacman: https://www.archlinux.org/packages/core/$ARCH/pacman/download/ . Change $ARCH according to your system.
 
* pacman-mirrorlist: https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/
 
* pacman-mirrorlist: https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/
  
Line 61: Line 61:
 
  wget https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/ --no-check-certificate --trust-server-names
 
  wget https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/ --no-check-certificate --trust-server-names
  
or this direct way (give attention to the date string in the file name) :
+
or this direct way (give attention to the date string in the file name, as it may need changing) :
{{bc|wget http://mirrors.kernel.org/archlinux/core/os/x86_64/pacman-mirrorlist-20110703-1-any.pkg.tar.gz}}
+
{{bc|wget http://mirrors.kernel.org/archlinux/core/os/i686/pacman-mirrorlist-20120626-1-any.pkg.tar.xz}}
  
 
See [http://pwet.fr/man/linux/commandes/wget the man page] and the [http://www.gnu.org/software/wget/manual/wget.html official manual] of wget for further details.
 
See [http://pwet.fr/man/linux/commandes/wget the man page] and the [http://www.gnu.org/software/wget/manual/wget.html official manual] of wget for further details.
Line 68: Line 68:
 
==== Using lftp to download ====
 
==== Using lftp to download ====
 
If you have issues with downloading '''pacman-mirrorlist''' use this direct way with lftp :
 
If you have issues with downloading '''pacman-mirrorlist''' use this direct way with lftp :
{{bc|1=link_name=http://mirrors.kernel.org/archlinux/core/os/x86_64/
+
{{bc|1=link_name=http://mirrors.kernel.org/archlinux/core/os/i686/
lftp -e "mget pacman-mirrorlist-*.tar.gz" "${link_name}"}}
+
lftp -e "mget pacman-mirrorlist-*.tar.xz" "${link_name}"}}
  
 
==== Additional libraries====
 
==== Additional libraries====
You may need additional libraries to make pacman work, for newer distribution:
+
You may need additional libraries to make pacman work, for newer distributions:
  
  for software_name in libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ ; done
+
  for software_name in libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --trust-server-names ; done
  
When using an older distribution to bootstrap, a few more libraries may be needed to work, for example :
+
When using an older distribution to bootstrap, a few more libraries may be needed for it to work, for example :
{{bc|for software_name in glibc gcc-libs binutils libssh2 curl gcc libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --trust-server-names; done}}
+
{{bc|for software_name in glibc gcc-libs binutils libssh2 curl gcc libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --trust-server-names ; done}}
 
Also note that below when you set LD_LIBRARY_PATH you have to add /lib and /lib64:
 
Also note that below when you set LD_LIBRARY_PATH you have to add /lib and /lib64:
 
{{bc|1=export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:${base_chroot}/archlinux/lib:${base_chroot}/archlinux/usr/lib64:$LD_LIBRARY_PATH}}
 
{{bc|1=export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:${base_chroot}/archlinux/lib:${base_chroot}/archlinux/usr/lib64:$LD_LIBRARY_PATH}}
Line 84: Line 84:
 
  for f in *.pkg.tar*; do tar xvf $f; done
 
  for f in *.pkg.tar*; do tar xvf $f; done
  
To prepare for using pacman, do not forget to edit {{Ic|/tmp/archlinux/etc/pacman.conf}} to point to {{Ic|/tmp/archlinux/etc/pacman.d/mirrorlist}} and select your favorite mirror. For easier use (assuming you are using {{Ic|bash}} or {{Ic|zsh}}), you may set up an environment
+
To prepare for using pacman, do not forget to edit {{Ic|/tmp/archlinux/etc/pacman.conf}} to point to {{Ic|/tmp/archlinux/etc/pacman.d/mirrorlist}} and select your favorite mirror. For easier use (assuming you are using {{Ic|bash}} or {{Ic|zsh}}), you may set up an environment:
 
  export PATH=${base_chroot}/archlinux/usr/bin:$PATH
 
  export PATH=${base_chroot}/archlinux/usr/bin:$PATH
 
  export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:$LD_LIBRARY_PATH
 
  export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:$LD_LIBRARY_PATH
Line 90: Line 90:
  
 
====Install pacman on the host system====
 
====Install pacman on the host system====
{{Note|('''Issues while running pacman on 64 bit host''') If while running pacman you end up with {{ic|/tmp/archlinux/usr/bin/pacman: No such file or directory}} please symlink ld-linux-x86-64.so.2: {{ic|ln -s /lib64/ld-linux-x86-64.so.2 /lib/}}}}
+
{{Note|('''Issues while running pacman on 64-bit host''') If while running pacman you end up with {{ic|/tmp/archlinux/usr/bin/pacman: No such file or directory}} please symlink ld-linux-x86-64.so.2: {{ic|ln -s /lib64/ld-linux-x86-64.so.2 /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:
 
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 /
 
  cd /
 
  for f in /tmp/archlinux/pacman-*pkg.tar.gz ; do
 
  for f in /tmp/archlinux/pacman-*pkg.tar.gz ; do
 
   tar xzf $f
 
   tar xzf $f
 
  done
 
  done
 
However, keep in mind that this operation could erase some of your files, and break your system.
 
  
 
<ol>
 
<ol>
Line 105: Line 104:
  
 
</div></li>
 
</div></li>
<li><div>Alternatively, you can instead turn these tarballs into packages for your distribution with the [http://kitenet.net/~joey/code/alien/ 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:
+
<li><div>Alternatively, you can instead turn these tarballs into packages for your distribution with the [http://kitenet.net/~joey/code/alien/ 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
 
  cd /tmp/archlinux
  alien -d pacman-3.3.3-1-i686.pkg.tar.gz
+
  alien -d pacman-*-i686.pkg.tar.xz
  alien -d pacman-mirrorlist-20101223-1-any.pkg.tar.gz
+
  alien -d pacman-mirrorlist-20120626-1-any.pkg.tar.xz
  
 
RPM based systems will need to replace the parameter "-d" with "-r".
 
RPM based systems will need to replace the parameter "-d" with "-r".
Line 138: Line 137:
 
However, most users will want to be installing Arch onto its own partition.
 
However, most users will want to be installing Arch onto its own partition.
  
Prepare any partitions and filesystems you need for your installation. If your host system has any gui tools for this, such as gparted, cfdisk, or mandrakes diskdrake, feel free to use them.  
+
Prepare any partitions and filesystems you need for your installation. If your host system has any GUI tools for this, such as gparted, cfdisk, or Mandrake's diskdrake, feel free to use them.  
 
   
 
   
 
To format a partition as ext4, you run (where /dev/sdxx is the partition you want to setup):  
 
To format a partition as ext4, you run (where /dev/sdxx is the partition you want to setup):  
Line 150: Line 149:
 
  swapon /dev/sdxx
 
  swapon /dev/sdxx
  
Most other filesystems can be setup with their own mkfs variant, take a look with tab completion. Available filesystems depend entirely on your host system.  
+
Most other filesystems can be setup with their own mkfs variant, take a look using tab completion. Available filesystems depend entirely on your host system.  
 
   
 
   
 
Once you have your filesystems setup, mount them. Throughout this guide, we will refer to the new Arch root directory as /newarch, however you can put it wherever you like.  
 
Once you have your filesystems setup, mount them. Throughout this guide, we will refer to the new Arch root directory as /newarch, however you can put it wherever you like.  
Line 195: Line 194:
 
  cp /etc/pacman.d/mirrorlist ${new_arch}/etc/pacman.d
 
  cp /etc/pacman.d/mirrorlist ${new_arch}/etc/pacman.d
  
Finally edit pacman configuration file {{ic|${new_arch}/etc/pacman.conf}} setting the Architecture so that is matches the one of target system.
+
Finally edit the pacman configuration file {{ic|${new_arch}/etc/pacman.conf}} setting "Architecture" so that it matches the one of the target system.
The default auto might fails if it is different from the host system.
+
The default of "auto" might fail if it is different from the host system.
  
 
  Architecture = i686 or x86_64
 
  Architecture = i686 or x86_64
Line 225: Line 224:
 
Edit your {{ic|/etc/fstab}}, remembering to add /, swap and any other partitions you may wish to use. Be sure to use the /dev/sd* (sda1, sda2, sdb1, etc) for the partitions instead of /dev/hd*, as Arch uses the sdxx convention for all drives.
 
Edit your {{ic|/etc/fstab}}, remembering to add /, swap and any other partitions you may wish to use. Be sure to use the /dev/sd* (sda1, sda2, sdb1, etc) for the partitions instead of /dev/hd*, as Arch uses the sdxx convention for all drives.
 
   
 
   
Edit your {{ic|/etc/rc.conf}}, {{ic|/etc/hosts}} and {{ic|/etc/mkinitcpio.conf}} to your needs. If you are installing arch linux to a usb flash drive, don't forget to add the {{ic|usb}} hook to {{ic|/etc/mkinitcpio.conf}}. Then rebuild the initcpio image:  
+
Edit your {{ic|/etc/rc.conf}}, {{ic|/etc/hosts}} and {{ic|/etc/mkinitcpio.conf}} to your needs. If you are installing Arch Linux to a USB flash drive, don't forget to add the {{ic|usb}} hook to {{ic|/etc/mkinitcpio.conf}}. Then, rebuild the initcpio image:  
 
  mkinitcpio -p linux
 
  mkinitcpio -p linux
 
   
 
   
Line 243: Line 242:
 
  grub  
 
  grub  
 
  grub> find /boot/grub/stage1    (You should see some results here if you have done everything right so far.  If not, back up and retrace your steps.)
 
  grub> find /boot/grub/stage1    (You should see some results here if you have done everything right so far.  If not, back up and retrace your steps.)
  grub> root (hd0,X)  
+
  grub> root (hd0,X)    (Note that Grub 1 and Grub 2 differ in how they each handle partition numbering. See the GRUB articles for info.)
 
  grub> setup (hd0)  
 
  grub> setup (hd0)  
 
  grub> quit  
 
  grub> quit  
Line 251: Line 250:
 
====Manual recovery of GRUB libs ====
 
====Manual recovery of GRUB libs ====
  
The {{ic|*stage*}} files are expected to be in {{ic|/boot/grub}}, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damages, accidentally deleted, etc.   
+
The {{ic|*stage*}} files are expected to be in {{ic|/boot/grub}}, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc.   
  
 
Manually copy the grub libs like so:
 
Manually copy the grub libs like so:
Line 292: Line 291:
 
Mounting these is essential for the installation of a bootloader later on.
 
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:
+
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:
 
From 64-bit to a 32-bit system:
 
  Architecture = i686
 
  Architecture = i686
Or from 32-bit to a 64-bit system::
+
Or from 32-bit to a 64-bit system:
 
  Architecture = x86_64
 
  Architecture = x86_64
  
Line 337: Line 336:
 
=== Preparing the installation environment ===
 
=== Preparing the installation environment ===
  
You can grab whatever image from Arch's Download Page and get the content of image by mount loopback:
+
You can grab whatever image from Arch's Download Page and get the content of the image by mounting it as a loopback device:
  
 
i686 CD Image:   
 
i686 CD Image:   
Line 343: Line 342:
 
  $ mount -o loop archlinux-2011.08.19-core-i686.iso /mnt/image
 
  $ mount -o loop archlinux-2011.08.19-core-i686.iso /mnt/image
  
create directories for image extraction and chroot environment
+
create directories for image extraction and chroot environment:
 
  $ mkdir -v /mnt/extract
 
  $ mkdir -v /mnt/extract
 
  $ mkdir -pv /mnt/archlinux/lib/modules
 
  $ mkdir -pv /mnt/archlinux/lib/modules
Line 353: Line 352:
 
  $ cd /mnt/image/arch/i686/
 
  $ cd /mnt/image/arch/i686/
 
    
 
    
  # root-image  
+
  # root-image:
 
  $ unsquashfs -dest /mnt/extract/root root-image.fs.sfs  
 
  $ unsquashfs -dest /mnt/extract/root root-image.fs.sfs  
 
  $ mount -t ext4 /mnt/extract/root/root-image.fs /mnt/archlinux
 
  $ mount -t ext4 /mnt/extract/root/root-image.fs /mnt/archlinux
 
    
 
    
  # lib-modules  
+
  # lib-modules:
 
  $ unsquashfs -dest /mnt/extract/modules lib-modules.fs.sfs  
 
  $ unsquashfs -dest /mnt/extract/modules lib-modules.fs.sfs  
 
  $ mount -t ext4 /mnt/extract/modules/lib-modules.fs /mnt/archlinux/lib/modules
 
  $ mount -t ext4 /mnt/extract/modules/lib-modules.fs /mnt/archlinux/lib/modules
 
    
 
    
  # repo-core-i686  
+
  # repo-core-i686:
 
  $ mount -o loop -t squashfs repo-core-i686.sfs /mnt/archlinux/repo/core/i686
 
  $ mount -o loop -t squashfs repo-core-i686.sfs /mnt/archlinux/repo/core/i686
 
    
 
    
 
  $ cd /mnt/image/arch/any/
 
  $ cd /mnt/image/arch/any/
 
    
 
    
  # usr-share  
+
  # usr-share:
 
  $ unsquashfs -dest /mnt/extract/share usr-share.fs.sfs  
 
  $ unsquashfs -dest /mnt/extract/share usr-share.fs.sfs  
 
  $ mount -t ext4 /mnt/extract/share/usr-share.fs /mnt/archlinux/usr/share
 
  $ mount -t ext4 /mnt/extract/share/usr-share.fs /mnt/archlinux/usr/share
 
    
 
    
  # repo-core-any  
+
  # repo-core-any:
 
  $ mount -o loop -t squashfs repo-core-any.sfs /mnt/archlinux/repo/core/any
 
  $ mount -o loop -t squashfs repo-core-any.sfs /mnt/archlinux/repo/core/any
  
after this step, you will have a new archlinux directory which contain new Arch system.
+
After this step, you will have a new archlinux directory which contains a new Arch system.
  
 
=== Install from new environment ===
 
=== Install from new environment ===
Line 387: Line 386:
 
  $ aif -p interactive
 
  $ aif -p interactive
  
and you can install Arch as normal (from CD or Internet) with the following pointer:
+
And now you can install Arch as normal (from CD or Internet) with the following pointer:
* Your target partition must not be being used by host system
+
* Your target partition must not be being used by the host system.
  
After installing Arch from chroot's environment, you should unmount partitions mounted by aif before exit the chroot:
+
After installing Arch from the chroot's environment, you should unmount partitions mounted by aif before exiting the chroot:
 
  $ umount /mnt/boot,home...
 
  $ umount /mnt/boot,home...
 
  $ exit
 
  $ exit
Line 401: Line 400:
 
  $ rm -r /mnt/{archlinux,extract}  
 
  $ rm -r /mnt/{archlinux,extract}  
  
It is essential to unmount partitions before exit chroot, or you will not be able to unmount the chroot directory
+
It is essential to unmount partitions before exiting the chroot, or you will not be able to unmount the chroot directory.
  
 
=== Update and install packages from host system via chroot ===
 
=== Update and install packages from host system via chroot ===

Revision as of 19:18, 19 July 2012

This guide is intended to combine and update the three previously existing and highly similar alternative install guides on this wiki. 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.

Overview

Arch Linux's pacman can be configured (-r) to perform operations in any directory you like, using that as the context of "root" while running.

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.

Throughout this guide, we will refer to partitions as /dev/hdxx or /dev/sdxx. This refers to whatever dev entry you have on your system for the partition in question. The convention is:

Drive 1, Partition 1:  /dev/hda1 or /dev/sda1
Drive 1, Partition 2:  /dev/hda2 or /dev/sda2
Drive 2, Partition 1:  /dev/hdb1 or /dev/sdb1

etc...

We will refer to it as /dev/sdxx whenever possible, but realize depending on your system it could be /dev/hdxx.

In this article,

host
refers to the computer which is used to perform the installation.
target
refers to the computer where you want to install Arch.

These may be one and the same computer. The host does not need to be an Arch system -- it can be a Debian or Redhat system, for example. The section entitled "Setup the host system" explains how to install pacman on the host. The following section "Setup the target system" explains how to use pacman from the host system to install Arch on the target system. Therefore if the host system is already running Arch, you can skip to "Setup the target system".

Setup the host system

You need to install the Arch Linux package manager, pacman, on your host Linux environment. In addition you will need a list of pacman mirror sites which is used to download data on available packages as well as the packages themselves. If you are already using Arch, skip this step and go to Install from Existing Linux#Setup the target system.

Get the required packages

Introduction

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):

ARCH=i686
base_chroot=/tmp
mkdir ${base_chroot}/archlinux
cd ${base_chroot}/archlinux

Download the 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  https://www.archlinux.org/packages/core/$ARCH/pacman/download/ --no-check-certificate --trust-server-names
wget https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/ --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) :

wget http://mirrors.kernel.org/archlinux/core/os/i686/pacman-mirrorlist-20120626-1-any.pkg.tar.xz

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 :

link_name=http://mirrors.kernel.org/archlinux/core/os/i686/
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 https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --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 https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --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 ld-linux-x86-64.so.2: ln -s /lib64/ld-linux-x86-64.so.2 /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
done
  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 https://bbs.archlinux.org/viewtopic.php?pid=734336#p734336 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.

Configure the host system

The main goal of this operation is to make a proper configuration to pacman.

Configure your /etc/pacman.conf to your liking, and remove unnecessary mirrors from /etc/pacman.d/mirrorlist. Also, enabling at least a few mirrors might become necessary, as you may experience errors during syncing if you have no mirror set. You may want to manually resolve DNS in the /etc/pacman.d/mirrorlist, because pacman for i686 may not be able to get address information on x86_64 systems.

If you are installing from a LiveCD, and you have a system with a low amount of combined RAM and swap (< 1 GB), be sure to set the cachedir in /etc/pacman.conf to be in the new Arch partition (e.g. /newarch/var/cache/pacman/pkg). Otherwise you could exhaust memory between the overhead of the existing distro and downloading necessary packages to install.

Setup the target system

Prepare a partition for Arch

You do not have to install Arch on a separate partition. You could instead build up a root filesystem in a normal directory, and then create a master tarball from it, or transfer it across the network.

However, most users will want to be installing Arch onto its own partition.

Prepare any partitions and filesystems you need for your installation. If your host system has any GUI tools for this, such as gparted, cfdisk, or Mandrake's diskdrake, feel free to use them.

To format a partition as ext4, you run (where /dev/sdxx is the partition you want to setup):

mkfs.ext4 /dev/sdxx 

To format it as ext3 with journaling and dir_index:

mkfs.ext4 -j -O dir_index /dev/sdxx 

To format it as reiserfs:

mkreiserfs /dev/sdxx 

To format a partition as swap, and to start using it:

mkswap /dev/sdxx 
swapon /dev/sdxx

Most other filesystems can be setup with their own mkfs variant, take a look using tab completion. Available filesystems depend entirely on your host system.

Once you have your filesystems setup, mount them. Throughout this guide, we will refer to the new Arch root directory as /newarch, however you can put it wherever you like.

new_arch=/newarch
mkdir ${new_arch}
mount /dev/sdxx ${new_arch}

Install the core

Update pacman. You may have to create the /newarch/var/lib/pacman folder for it to work (see "Setup the host system" above):

mkdir -p ${new_arch}/var/lib/pacman 
pacman -Sy -r ${new_arch}

Install the 'base' group of packages:

mkdir -p ${new_arch}/var/cache/pacman/pkg
pacman  -Su base --cachedir ${new_arch}/var/cache/pacman/pkg -r ${new_arch}

Prepare /dev nodes

First, ensure the correct /dev nodes have been made for udev:

ls -alF ${new_arch}/dev

This result in a list containing lines similar to the following (the dates will differ for you):

crw-------  1 root root 5, 1 2008-12-27 21:40 console
crw-rw-rw-  1 root root 1, 3 2008-12-27 21:42 null
crw-rw-rw-  1 root root 1, 5 2008-12-27 21:40 zero

Delete and recreate any device which has a different set of permissions (the crw-... stuff plus the two root entries) and major/minor numbers (the two before the date).

cd ${new_arch}/dev 
rm -f console ; mknod -m 600 console c 5 1 
rm -f null ; mknod -m 666 null c 1 3 
rm -f zero ; mknod -m 666 zero c 1 5

All device nodes should have been created for you already with the right permissions and you should not need to recreate any of them.

Chroot

Now we will chroot into the new Arch system.

In order for DNS to work properly you need to edit ${new_arch}/etc/resolv.conf or replace it with the resolv.conf from your running distribution

cp /etc/resolv.conf ${new_arch}/etc/ 

Also, you need to copy a correctly setup mirrorlist into the new system:

cp /etc/pacman.d/mirrorlist ${new_arch}/etc/pacman.d

Finally edit the pacman configuration file ${new_arch}/etc/pacman.conf setting "Architecture" so that it matches the one of the target system. The default of "auto" might fail if it is different from the host system.

Architecture = i686 or x86_64

Mount various filesystems into the new Arch system:

mount -t proc proc ${new_arch}/proc
mount -t sysfs sys ${new_arch}/sys
mount -o bind /dev ${new_arch}/dev
mount -t devpts pts ${new_arch}/dev/pts

If you have a separate /boot partition, you will probably need to mount that too. See Change Root for more details.

Warning: If you have a separate /boot partition and plan on using grub2, make sure to mount /boot after chrooting. If you mount the /boot partition before the chroot, grub2 will assume that /boot and root are on the same partition and will not update correctly.

When everything is prepared, chroot into the new filesystem:

chroot ${new_arch} /bin/bash

Install the rest

Install your preferred kernel, and any other packages you may wish to install. For the default kernel (which is already installed!):

pacman -S --needed linux

If you wish to install extra packages now, you may do so with:

pacman -S packagename

Configure the target system

Edit your /etc/fstab, remembering to add /, swap and any other partitions you may wish to use. Be sure to use the /dev/sd* (sda1, sda2, sdb1, etc) for the partitions instead of /dev/hd*, as Arch uses the sdxx convention for all drives.

Edit your /etc/rc.conf, /etc/hosts and /etc/mkinitcpio.conf to your needs. If you are installing Arch Linux to a USB flash drive, don't forget to add the usb hook to /etc/mkinitcpio.conf. Then, rebuild the initcpio image:

mkinitcpio -p linux

Edit /etc/locale.gen, uncommenting any locales you wish to have available, and build the locales:

locale-gen

Setup Grub

To use GRUB when chrooted, you need to ensure that /etc/mtab is up-to-date:

diff /etc/mtab /proc/mounts

If you get any output from the previous command, run:

grep -v rootfs /proc/mounts > /etc/mtab  

You can now run:

grub-install /dev/sdx

If grub-install fails, you can manually install:

grub 
grub> find /boot/grub/stage1     (You should see some results here if you have done everything right so far.   If not, back up and retrace your steps.)
grub> root (hd0,X)    (Note that Grub 1 and Grub 2 differ in how they each handle partition numbering. See the GRUB articles for info.)
grub> setup (hd0) 
grub> quit 

Double-check your /boot/grub/menu.lst. Depending on the host, it could need correcting from hda to sda, and a prefix of /boot as well in the paths.

Manual recovery of GRUB libs

The *stage* files are expected to be in /boot/grub, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc.

Manually copy the grub libs like so:

# cp -a /usr/lib/grub/i386-pc/* /boot/grub
Note: Do not forget to mount the system's boot partition if your setup uses a separate one! The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!

Detailed instructions for GRUB, GRUB2, LILO, Burg and Syslinux are available; see also Category:Boot loaders.

Finishing touches

See Beginners Guide:Configure the system. You can ignore 2.11, but the rest of that guide should be of use to you in post-installation configuration of your system.

Exit your chroot:

exit
umount ${new_arch}/boot   # if you mounted this or any other separate partitions
umount ${new_arch}/{proc,sys,dev}
umount ${new_arch}

Reboot to your new Arch system!

An alternate, simpler installation method

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

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

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.

Troubleshooting

Kernel panic

If when you reboot into your new system you get a kernel panic saying console could not open:

kinit: couldn't open console, no such file... 

This means you did not follow the instructions above. Follow the steps to create basic device nodes at the beginning of preparation.

Root device '/dev/sd??' doesn't exist

If when you reboot into your new system you get a error messages like this:

Root device '/dev/sda1' doesn't exist, attempting to create it... etc. 

This means the drives are showing up as "hda1" instead of "sda1" In which case change your GRUB or LILO settings to use "hd??" or try the following.

Edit /etc/mkinitcpio.conf and change "ide" to "pata" in the "HOOKS=" line. Then regenerate your initrd. (Make sure you have chroot'ed into the new system first.)

mkinitcpio -p linux

If you are using LVM make sure you add "lvm2" in the HOOKS line. Regenerate your initrd as above.

If you are installing to a device that needs PATA hook make sure it is located before autodetect hook in mkinitcpio.conf.

If your root partition is on an USB device, you have to add “usb” into your “HOOKS=” line before anything else, even “base”.

Another method: Installing from an existing Linux with an Arch installation image

Preparing the installation environment

You can grab whatever image from Arch's Download Page and get the content of the image by mounting it as a loopback device:

i686 CD Image:

$ mkdir -v /mnt/image
$ mount -o loop archlinux-2011.08.19-core-i686.iso /mnt/image

create directories for image extraction and chroot environment:

$ mkdir -v /mnt/extract
$ mkdir -pv /mnt/archlinux/lib/modules
$ mkdir -pv /mnt/archlinux/usr/share
$ mkdir -pv /mnt/archlinux/repo/core/{i686,any} 

extract the image contents:

$ cd /mnt/image/arch/i686/
  
# root-image:
$ unsquashfs -dest /mnt/extract/root root-image.fs.sfs 
$ mount -t ext4 /mnt/extract/root/root-image.fs /mnt/archlinux
 
# lib-modules:
$ unsquashfs -dest /mnt/extract/modules lib-modules.fs.sfs 
$ mount -t ext4 /mnt/extract/modules/lib-modules.fs /mnt/archlinux/lib/modules
  
# repo-core-i686:
$ mount -o loop -t squashfs repo-core-i686.sfs /mnt/archlinux/repo/core/i686
  
$ cd /mnt/image/arch/any/
  
# usr-share:
$ unsquashfs -dest /mnt/extract/share usr-share.fs.sfs 
$ mount -t ext4 /mnt/extract/share/usr-share.fs /mnt/archlinux/usr/share
  
# repo-core-any:
$ mount -o loop -t squashfs repo-core-any.sfs /mnt/archlinux/repo/core/any

After this step, you will have a new archlinux directory which contains a new Arch system.

Install from new environment

Now chroot into the new Arch system:

$ mount -t proc /proc /mnt/archlinux/proc
$ mount -t sysfs /sys /mnt/archlinux/sys
$ mount -o bind /dev /mnt/archlinux/dev 
$ chroot /mnt/archlinux /bin/bash

At this point, go ahead and launch Arch's aif installer!

$ aif -p interactive

And now you can install Arch as normal (from CD or Internet) with the following pointer:

  • Your target partition must not be being used by the host system.

After installing Arch from the chroot's environment, you should unmount partitions mounted by aif before exiting the chroot:

$ umount /mnt/boot,home...
$ exit
$ umount /mnt/archlinux/{dev,sys,proc} 
$ umount /mnt/archlinux/lib/modules
$ umount /mnt/archlinux/usr/share
$ umount /mnt/archlinux/repo/core/{i686,any}
$ umount /mnt/archlinux
$ umount /mnt/image
$ rm -r /mnt/{archlinux,extract} 

It is essential to unmount partitions before exiting the chroot, or you will not be able to unmount the chroot directory.

Update and install packages from host system via chroot

Add an entry to your existing Grub bootloader's menu.lst, or if you installed a new Grub during the Arch installation process, add it to the /boot/grub/menu.lst on your Arch filesystem.

Now either reboot or chroot into the new Arch's partition to install further packages:

$ mkdir /mnt/arch
$ mount /dev/sdxx /mnt/arch
$ mount -t proc proc /mnt/arch/proc
$ mount -t sysfs sys /mnt/arch/sys
$ mount -o bind /dev /mnt/arch/dev 
$ chroot /mnt/arch /bin/bash

Update and install new packages:

# pacman -Syu