Install from Existing Linux

From ArchWiki

Jump to: navigation, search


Article summary
Available in languages
Українська

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.

Contents

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.

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

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.

If you have a broadband connection available through the installation process and just want to do a basic install, UNetbootin may also be an easy solution worth to have a look at.

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.

Get the required packages

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

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 here for pacman and here for pacman-mirrorlist. Once you are sure of the version numbers download the required packages:

mkdir /tmp/archlinux
cd /tmp/archlinux
wget ftp://ftp.archlinux.org/core/os/i686/pacman-3.3.0-3-i686.pkg.tar.gz
wget ftp://ftp.archlinux.org/core/os/i686/pacman-mirrorlist-20090616-1-i686.pkg.tar.gz
tar xzvf pacman-3.3.0-3-i686.pkg.tar.gz
tar xzvf pacman-mirrorlist-20090616-1-i686.pkg.tar.gz

In addition to the dynamically linked pacman there is a statically linked version available. This does integrate better into all the different host linux systems possible. This static version is not part of the normal archlinux setup anymore but can be found at http://repo.archlinux.fr/i686/. Use the following command to get it:

cd /tmp/archlinux
wget http://repo.archlinux.fr/i686/pacman-static-3.2.2-1.pkg.tar.gz
tar xzvf pacman-static-3.2.2-1.pkg.tar.gz

Install the required files onto the host system

Since we will use pacman.static for the initial setup, we only need a few files installed into the host. This can be done by running the following commands as root:

cp /tmp/archlinux/etc/pacman.conf /etc
mkdir /etc/pacman.d
cp /tmp/archlinux/etc/pacman.d/* /etc/pacman.d
cp /tmp/archlinux/usr/bin/pacman.static /usr/bin

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

cd /
for f in /tmp/archlinux/pacman-*pkg.tar.gz
  tar xzf $f
done

You may also 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-3.3.0-3-i686.pkg.tar.gz
alien -d pacman-mirrorlist-20090108-1-i686.pkg.tar.gz
alien -d pacman-static-3.2.2-1-i686.pkg.tar.gz

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.

Configure the host system

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-static for i686 may not be able to get address information on x86_64 systems.

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.

Setup the target system

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/sdxx is the partition you want to setup):

# mkfs.ext3 /dev/sdxx 

as reiserfs:

# mkreiserfs /dev/sdxx 

swap:

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

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/sdxx /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 the core

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

# mkdir -p /newarch/var/lib/pacman 

Install the 'base' group of packages:

# pacman.static -Sy base -r /newarch

NOTE: Pacman cache directory is not modified by -r parameter. If you don't want cache to be created in pre-existing distro use --cachedir or modify pacman.conf as mentioned in host system setup!

Prepare the system

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

ls -alF /newarch/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 /newarch/dev 
rm console ; mknod -m 600 console c 5 1 
rm null ; mknod -m 666 null c 1 3 
rm 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.

Mount various filesystems into the new Arch system.

mount -o bind /dev /newarch/dev
mount -t proc none /newarch/proc
mount -o bind /sys /newarch/sys

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/ 

Copy your pacman mirror list into the new system:

cp /etc/pacman.d/mirrorlist /newarch/etc/pacman.d

Make sure that it is set up correctly.

Chroot into the new system

chroot /newarch /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 kernel26 

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 rc.conf to your liking

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

locale-gen

Setup Grub

Allow grub-install to run properly while chrooted:

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

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

Finishing touches

See Beginners Guide:Configure your 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.

Reboot to your new system!

Troubleshooting

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.

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

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

Personal tools