Install Arch from within another distro

From ArchWiki
Revision as of 01:15, 6 July 2008 by Georgia tech swagger (talk | contribs) (LiveCD gotchas)
Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

How to install Arch from within a liveCD or other distro


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

The pacman package available from the mirrors includes a static-linked version of the binary (pacman.static) which should run in most any modern linux environment, without the need of dependencies.

This is useful for building up new Archlinux systems from scratch from other LiveCDs or different systems running another Linux environment, 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.

In the case of an x86_64 host, it is even possible to use i686-pacman to build a 32-bit chroot environment. See Arch64 Install bundled 32bit system.

Setup host system

Install pacman within the host distro. The simplest way is to grab the latest pacman package, which matches the install-host. (i686 host) (x86_64 host)

Since we will use pacman.static for the initial setup, we only need a few files installed into the host:


If you don't mind to litter your install-host, you can just cd to /, and extract the pacman.pkg.tar.gz you downloaded.

Configure your /etc/pacman.conf to your liking, and perhaps set a mirror in /etc/pacman.d/mirrorlist.

If you're 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 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.

Prepare disk for Arch

Prepare the new Arch system's filesystems and then mount them. If your host system has any gui tools for this, such as gparted, cfdisk, or mandrakes diskdrake, feel free to use them.

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

mkfs.ext3 /dev/hdxx

as reiserfs:

mkreiserfs /dev/hxx


mkswap /dev/hdxx

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.

Once you have setup the filesystems, mount them. Throughout this, We will reference the new Arch / at /newarch, however you can put it wherever you like.

mkdir /newarch
mount /dev/hdxx /newarch

It is also possible to build the root filesystem in a normal directory on the install-host, for transfer to a target system over the network, or to create a master tarball etc.

Install Base System

Update pacman, you may have to create the /newarch/var/lib/pacman folder for it to work

mkdir -p /newarch/var/lib/pacman
pacman.static -Sy -r /newarch
pacman.static -S pacman -r /newarch

Install all of base. I put a list of base packages in a file called 'packages' which is at the end of this page.

pacman.static -S `cat packages` -r /newarch

or you can just do

pacman.static -Sy base -r /newarch

as arch groups the entire collection of base packages into the 'base' group.

Prepare System

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

cd /newarch/dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3

Mount various filesystems into the new Arch system.

mount /dev/ /newarch/dev/ --bind
mount /sys/ /newarch/sys/ --bind
mount /proc/ /newarch/proc/ --bind

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

cp /etc/resolv.conf /newarch/etc/

Chroot into the new system

chroot /newarch

Install The Rest

Install your preferred kernel, and any other packages you may wish to install.

Note: You may want to edit /etc/mkinitcpio.conf and change "ide" to "pata" so that you can refer to your drives in the "sda1" format instead of "hda1". As of May 2008, this was already the default.

pacman -S kernel26
pacman -S kernel26beyond
pacman -S kernel26mm

Note: if pacman fails with a not enough disk space error, try the trick for installing grub while chroot'ed, found below. cat /proc/mounts > /etc/mtab fixed this error for me. YMMV. If you wish to install extra packages now, you may do so with:

pacman -S packagename

Configure System

Edit your /etc/fstab, remembering to add /, swap and any other partitions you may wish to use.

Edit your rc.conf to your liking

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

# locale-gen

Setup Bootloader

Edit your preferred bootloader's config and install it. I had problems with grub, so I configured and installed lilo.

NOTE: for grub use an old trick from the gentoo handbook

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

this allows grub-install to run properly while chrooted.

Also, if you want to keep grub from your existing install, you may use grub-install from the Arch chroot, then redo a grub-install from your existing installation. In my case, grub-install failed, si I had to do :

# grub
grub> root (hd0,X)
grub> setup (hd0)
grub> quit

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

Instructions for GRUB and LILO are available on this wiki.

Install Complete

Reboot to your new system!

Package list

You can get an up to date list by using below command:

wget or
wget <Your preferred CURRENT mirror server>/packages.txt
cat packages.txt | grep "base" | cut -c 6- | awk -F "-[0-9]" '{print $1}' > packages

Kernel Panic

If when you reboot into your new system you get a kernel panic saying console couldn't open:

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

This means you didn't follow the instructions above. Follow the steps to create basic device nodes at the beginning of preparation.

Trouble Shoot: 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 kernel26