Difference between revisions of "Install from existing Linux"

From ArchWiki
Jump to navigation Jump to search
(Remove broken bootstrap script)
(Method 1: Using the Bootstrap Image (RECOMMENDED): Update bootstrap URL)
Line 40: Line 40:
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:
   $ curl -O https://mirrors.kernel.org/archlinux/iso/2014.07.03/archlinux-bootstrap-2014.07.03-x86_64.tar.gz
   $ curl -O https://mirrors.kernel.org/archlinux/iso/2014.09.03/archlinux-bootstrap-2014.09.03-x86_64.tar.gz
Extract the tarball:
Extract the tarball:
   # cd /tmp
   # cd /tmp

Revision as of 21:09, 4 September 2014

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

The goal of the bootstrapping procedure is to setup an environment from which arch-install-scripts (such as pacstrap and arch-root) run. This goal is achieved by installing arch-install-scripts natively on the host system, or setting up an Arch Linux-based chroot.

If the host system runs Arch Linux, installing arch-install-scripts is straightforward.

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

Arch Linux-based chroot

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.

Note: Your host system must run Linux 2.6.32 or later.
Note: Select only one of the following two methods and then read the rest of the article to complete the install.

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/2014.09.03/archlinux-bootstrap-2014.09.03-x86_64.tar.gz

Extract the tarball:

 # cd /tmp
 # tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.07.03-x86_64.tar.gz

Select a repository server:

 # nano /tmp/root.x86_64/etc/pacman.d/mirrorlist
Note: If you are bootstrapping an i686 image from an x86_64 host system, you must also edit /tmp/root.i686/etc/pacman.conf and explicitly define Architecture = i686 in order for pacman to pull the proper i686 packages.

Enter the chroot

  • If you have bash 4 or later 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 --rbind /proc proc
  # mount --rbind /sys sys
  # mount --rbind /dev dev
  # mount --rbind /run run
    (assuming /run exists on your 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 you with a working Arch Linux installation right within your host system without the need to prepare it by installing specific packages.

Note: Before proceeding, make sure the latest version of squashfs is installed on the host system. Otherwise you will get errors like: 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 you can 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 your 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


Follow the Mount the partitions and Install the base system sections of the Installation guide.

Debian-based host

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

Configure the system

From that point, simply follow the Mount the partitions section of the Installation guide and following sections.

Replacing the Existing System without a LiveCD

Find ~650MB of free space somewhere on the disk, e.g. by partitioning a swap partition. If you can't find more than 600mb you will likely need to 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 you have installed the new Arch Linux system there, reboot into the newly created system, and rsync the entire system to the primary partition. Fix the bootloader configuration before rebooting.