https://wiki.archlinux.org/api.php?action=feedcontributions&user=Collinmanderson&feedformat=atomArchWiki - User contributions [en]2024-03-28T19:45:30ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302949Install Arch Linux from existing Linux2014-03-02T21:47:28Z<p>Collinmanderson: /* Arch Linux-based chroot */ updated to 2014.03.01 image</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.03.01/archlinux-bootstrap-2014.03.01-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.03.01-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list of filenames for the arch packages<br />
wget -q -O- "$MIRROR/core/os/$ARCH/" | sed -n "s|.*href=\"\\([^\"]*xz\\)\".*|\\1|p" >> $LIST<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
FILE=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
wget "$MIRROR/core/os/$ARCH/$FILE" -c -O "$DIR/$FILE"<br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
# echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
mkdir -p "$CHROOT_DIR/etc/pacman.d/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR pacman-key --init<br />
chroot $CHROOT_DIR pacman-key --populate archlinux<br />
chroot $CHROOT_DIR pacman -Syu pacman --force<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
chroot $CHROOT_DIR<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302948Install Arch Linux from existing Linux2014-03-02T21:24:33Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ I find that I have a force reinstall everything officially again.</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list of filenames for the arch packages<br />
wget -q -O- "$MIRROR/core/os/$ARCH/" | sed -n "s|.*href=\"\\([^\"]*xz\\)\".*|\\1|p" >> $LIST<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
FILE=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
wget "$MIRROR/core/os/$ARCH/$FILE" -c -O "$DIR/$FILE"<br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
# echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
mkdir -p "$CHROOT_DIR/etc/pacman.d/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR pacman-key --init<br />
chroot $CHROOT_DIR pacman-key --populate archlinux<br />
chroot $CHROOT_DIR pacman -Syu pacman --force<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
chroot $CHROOT_DIR<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302947Install Arch Linux from existing Linux2014-03-02T21:18:20Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ we don't need community or extra repos which simplifies things</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list of filenames for the arch packages<br />
wget -q -O- "$MIRROR/core/os/$ARCH/" | sed -n "s|.*href=\"\\([^\"]*xz\\)\".*|\\1|p" >> $LIST<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
FILE=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
wget "$MIRROR/core/os/$ARCH/$FILE" -c -O "$DIR/$FILE"<br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
# echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
mkdir -p "$CHROOT_DIR/etc/pacman.d/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302946Install Arch Linux from existing Linux2014-03-02T20:51:49Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ now that i removed pacman-mirrorlist, we need to mkdir /etc/pacman.d/</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
# echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
mkdir -p "$CHROOT_DIR/etc/pacman.d/"<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302945Install Arch Linux from existing Linux2014-03-02T20:50:34Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ removed more unnecessary code</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
# echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302944Install Arch Linux from existing Linux2014-03-02T20:49:11Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ no need to create files and directories added by filesystem package</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
# echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
# Do you really want to switch the tests off?<br />
#sed -ni '/^[ \t]*CheckSpace/ !p' "$CHROOT_DIR/etc/pacman.conf"<br />
#sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$CHROOT_DIR/etc/pacman.conf"<br />
<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302943Install Arch Linux from existing Linux2014-03-02T20:46:20Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ simplify removing package metadata</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
rm -f "$CHROOT_DIR/.PKGINFO" "$CHROOT_DIR/.MTREE" "$CHROOT_DIR/.INSTALL"<br />
done<br />
# Create mount points<br />
mkdir -p "$CHROOT_DIR/dev" "$CHROOT_DIR/proc" "$CHROOT_DIR/sys" "$CHROOT_DIR/mnt"<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
echo "root:x:0:0:root:/root:/bin/bash" > "$CHROOT_DIR/etc/passwd" <br />
touch "$CHROOT_DIR/etc/group"<br />
echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
test -e "$CHROOT_DIR/etc/mtab" || echo "rootfs / rootfs rw 0 0" > "$CHROOT_DIR/etc/mtab"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
# Do you really want to switch the tests off?<br />
#sed -ni '/^[ \t]*CheckSpace/ !p' "$CHROOT_DIR/etc/pacman.conf"<br />
#sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$CHROOT_DIR/etc/pacman.conf"<br />
<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302942Install Arch Linux from existing Linux2014-03-02T20:44:57Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ enable a mirror by default so it JustWorks</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Change to the mirror which best fits for you<br />
# USA<br />
MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
<br />
# No error if they exist already<br />
if [ -f "$CHROOT_DIR/.PKGINFO" ]<br />
then <br />
rm "$CHROOT_DIR/.PKGINFO" <br />
fi <br />
if [ -f "$CHROOT_DIR/.MTREE" ]<br />
then <br />
rm "$CHROOT_DIR/.MTREE" <br />
fi <br />
if [ -f "$CHROOT_DIR/.INSTALL" ]<br />
then <br />
rm "$CHROOT_DIR/.INSTALL" <br />
fi <br />
done<br />
# Create mount points<br />
mkdir -p "$CHROOT_DIR/dev" "$CHROOT_DIR/proc" "$CHROOT_DIR/sys" "$CHROOT_DIR/mnt"<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
echo "root:x:0:0:root:/root:/bin/bash" > "$CHROOT_DIR/etc/passwd" <br />
touch "$CHROOT_DIR/etc/group"<br />
echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
test -e "$CHROOT_DIR/etc/mtab" || echo "rootfs / rootfs rw 0 0" > "$CHROOT_DIR/etc/mtab"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
# Do you really want to switch the tests off?<br />
#sed -ni '/^[ \t]*CheckSpace/ !p' "$CHROOT_DIR/etc/pacman.conf"<br />
#sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$CHROOT_DIR/etc/pacman.conf"<br />
<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmandersonhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_from_existing_Linux&diff=302941Install Arch Linux from existing Linux2014-03-02T20:41:21Z<p>Collinmanderson: /* Method 3: Assembling the chroot Manually (with a script) */ updated required packages.</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[es:Install from Existing Linux]]<br />
[[fr:Install chroot]]<br />
[[it:Install from Existing Linux]]<br />
[[ja:Install from Existing Linux]]<br />
[[pt:Install from Existing Linux]]<br />
[[ru:Install from Existing Linux]]<br />
[[uk:Install from Existing Linux]]<br />
[[zh-CN:Install from Existing Linux]]<br />
[[zh-TW:Install from Existing Linux]]<br />
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.<br />
After bootstrapping, the installation proceeds as described in the [[Installation guide]].<br />
<br />
Installing Arch Linux from a running Linux is useful for:<br />
* remotely installing Arch Linux, e.g. a (virtual) root server<br />
* replacing an existing Linux without a LiveCD (see [[#Replacing the Existing System without a LiveCD]])<br />
* creating a new Linux distribution or LiveCD based on Arch Linux<br />
* creating an Arch Linux chroot environment, e.g. for a Docker base container<br />
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]<br />
<br />
The goal of the bootstrapping procedure is to setup an environment from which {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-root}}) run.<br />
This goal is achieved by installing {{Pkg|arch-install-scripts}} natively on the host system, or setting up an Arch Linux-based chroot.<br />
<br />
If the host system runs Arch Linux, installing {{Pkg|arch-install-scripts}} is straightforward.<br />
<br />
{{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.}}<br />
<br />
==Arch Linux-based chroot==<br />
The idea is to run an Arch system inside the host system.<br />
The actual installation is then executed from this Arch system.<br />
This nested system is contained inside a chroot.<br />
Three methods to setup and enter this chroot are presented below, from the easiest to the most complicated.<br />
<br />
{{Note|Your host system must run Linux 2.6.32 or later.}}<br />
{{Note|Select only one of the following three methods and then read the rest of the article to complete the install.}}<br />
===Method 1: Using the Bootstrap Image===<br />
<br />
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:<br />
$ curl -O http://mirrors.kernel.org/archlinux/iso/2014.01.05/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Extract the tarball:<br />
# cd /tmp<br />
# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2014.01.05-x86_64.tar.gz<br />
Select a repository server:<br />
# nano /tmp/root.x86_64/etc/pacman.d/mirrorlist<br />
Enter the chroot<br />
* If you have bash 4 or later installed:<br />
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/<br />
* Else run the following commands:<br />
# cp /etc/resolv.conf /tmp/root.x86_64/etc<br />
# mount --rbind /proc /tmp/root.x86_64/proc<br />
# mount --rbind /sys /tmp/root.x86_64/sys<br />
# mount --rbind /dev /tmp/root.x86_64/dev<br />
# mount --rbind /run /tmp/root.x86_64/run<br />
(assuming /run exists on your system)<br />
# chroot /tmp/root.x86_64/<br />
<br />
===Method 2: Using the LiveCD Image===<br />
<br />
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.<br />
<br />
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise you will get errors like: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}<br />
<br />
* The root image can be found on one of the [https://www.archlinux.org/download 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.<br />
<br />
*To unsquash the root image, run<br />
{{bc|# unsquashfs -d /squashfs-root root-image.fs.sfs}}<br />
<br />
* Now you can loop mount the root image<br />
{{bc|<br />
# mkdir /arch<br />
# mount -o loop /squashfs-root/root-image.fs /arch<br />
}}<br />
<br />
* Before [[Change Root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.<br />
{{bc|<br />
# mount -t proc none /arch/proc<br />
# mount -t sysfs none /arch/sys<br />
# mount -o bind /dev /arch/dev<br />
# mount -o bind /dev/pts /arch/dev/pts # important for pacman (for signature check)<br />
# cp -L /etc/resolv.conf /arch/etc #this is needed to use networking within the chroot<br />
}}<br />
<br />
* Now everything is prepared to chroot into your newly installed Arch environment<br />
{{bc|# chroot /arch bash}}<br />
<br />
===Method 3: Assembling the chroot Manually (with a script)===<br />
<br />
The script creates a directory called {{ic|archinstall-pkg}} and downloads the required packages in it. It then extracts them in the {{ic|archinstall-chroot}} directory. Finally, it prepares mount points, configures pacman and enters a chroot.<br />
<br />
{{hc|archinstall-bootstrap.sh|<nowiki><br />
#!/bin/bash<br />
# last edited 02. March 2014<br />
# This script is inspired on the archbootstrap script.<br />
<br />
FIRST_PACKAGE=(filesystem)<br />
BASH_PACKAGES=(glibc ncurses readline bash)<br />
PACMAN_PACKAGES=(acl archlinux-keyring attr bzip2 coreutils curl e2fsprogs expat gnupg gpgme keyutils krb5 libarchive libassuan libgpg-error libgcrypt libssh2 lzo2 openssl pacman xz zlib)<br />
# EXTRA_PACKAGES=(pacman-mirrorlist tar libcap arch-install-scripts util-linux systemd)<br />
PACKAGES=(${FIRST_PACKAGE[*]} ${BASH_PACKAGES[*]} ${PACMAN_PACKAGES[*]})<br />
<br />
# Enable the mirror which best fits for you<br />
# USA<br />
# MIRROR='http://mirrors.kernel.org/archlinux' <br />
# Germany<br />
# MIRROR='http://archlinux.limun.org'<br />
<br />
# You can set the ARCH variable to i686 or x86_64<br />
ARCH=`uname -m`<br />
LIST=`mktemp`<br />
CHROOT_DIR=archinstall-chroot<br />
DIR=archinstall-pkg<br />
mkdir -p "$DIR"<br />
mkdir -p "$CHROOT_DIR"<br />
# Create a list with urls for the arch packages<br />
for REPO in core community extra; do <br />
wget -q -O- "$MIRROR/$REPO/os/$ARCH/" |sed -n "s|.*href=\"\\([^\"]*\\).*|$MIRROR\\/$REPO\\/os\\/$ARCH\\/\\1|p"|grep -v 'sig$'|uniq >> $LIST <br />
done<br />
# Download and extract each package.<br />
for PACKAGE in ${PACKAGES[*]}; do<br />
URL=`grep "$PACKAGE-[0-9]" $LIST|head -n1`<br />
FILE=`echo $URL|sed 's/.*\/\([^\/][^\/]*\)$/\1/'`<br />
wget "$URL" -c -O "$DIR/$FILE" <br />
xz -dc "$DIR/$FILE" | tar x -k -C "$CHROOT_DIR"<br />
<br />
# No error if they exist already<br />
if [ -f "$CHROOT_DIR/.PKGINFO" ]<br />
then <br />
rm "$CHROOT_DIR/.PKGINFO" <br />
fi <br />
if [ -f "$CHROOT_DIR/.MTREE" ]<br />
then <br />
rm "$CHROOT_DIR/.MTREE" <br />
fi <br />
if [ -f "$CHROOT_DIR/.INSTALL" ]<br />
then <br />
rm "$CHROOT_DIR/.INSTALL" <br />
fi <br />
done<br />
# Create mount points<br />
mkdir -p "$CHROOT_DIR/dev" "$CHROOT_DIR/proc" "$CHROOT_DIR/sys" "$CHROOT_DIR/mnt"<br />
mount -t proc proc "$CHROOT_DIR/proc/"<br />
mount -t sysfs sys "$CHROOT_DIR/sys/"<br />
mount -o bind /dev "$CHROOT_DIR/dev/"<br />
mkdir -p "$CHROOT_DIR/dev/pts"<br />
mount -t devpts pts "$CHROOT_DIR/dev/pts/"<br />
<br />
# Hash for empty password Created by doing: openssl passwd -1 -salt ihlrowCo and entering an empty password (just press enter)<br />
echo 'root:$1$ihlrowCo$sF0HjA9E8up9DYs258uDQ0:10063:0:99999:7:::' > "$CHROOT_DIR/etc/shadow"<br />
echo "root:x:0:0:root:/root:/bin/bash" > "$CHROOT_DIR/etc/passwd" <br />
touch "$CHROOT_DIR/etc/group"<br />
echo "myhost" > "$CHROOT_DIR/etc/hostname"<br />
test -e "$CHROOT_DIR/etc/mtab" || echo "rootfs / rootfs rw 0 0" > "$CHROOT_DIR/etc/mtab"<br />
[ -f "/etc/resolv.conf" ] && cp "/etc/resolv.conf" "$CHROOT_DIR/etc/"<br />
<br />
# Do you really want to switch the tests off?<br />
#sed -ni '/^[ \t]*CheckSpace/ !p' "$CHROOT_DIR/etc/pacman.conf"<br />
#sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$CHROOT_DIR/etc/pacman.conf"<br />
<br />
echo "Server = $MIRROR/\$repo/os/$ARCH" >> "$CHROOT_DIR/etc/pacman.d/mirrorlist"<br />
<br />
chroot $CHROOT_DIR /usr/bin/pacman -Sy <br />
chroot $CHROOT_DIR /bin/bash<br />
</nowiki>}}<br />
<br />
===Using the chroot Environment===<br />
<br />
====Initializing pacman keyring====<br />
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:<br />
{{bc|<br />
# pacman-key --init<br />
# pacman-key --populate archlinux<br />
}}<br />
<br />
====Installation====<br />
Follow the [[Installation guide#Mount the partitions|Mount the partitions]] and [[Installation guide#Install the base system|Install the base system]] sections of the [[Installation guide]].<br />
<br />
=====Debian-based host=====<br />
On Debian-based host systems, {{ic|pacstrap}} produces the following error:<br />
# pacstrap /mnt base<br />
# ==> Creating install root at /mnt<br />
# mount: mount point /mnt/dev/shm is a symbolic link to nowhere<br />
# ==> ERROR: failed to setup API filesystems in new root<br />
<br />
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:<br />
# mkdir /run/shm<br />
<br />
====Configure the system====<br />
<br />
From that point, simply follow the [[Installation guide#Mount the partitions|Mount the partitions]] section of the [[Installation guide]] and following sections.<br />
<br />
==Replacing the Existing System without a LiveCD==<br />
Find ~500MB of free space somewhere on the disk, e.g. by partitioning a swap partition.<br />
Install the new Arch Linux system there, reboot into the newly created system, and [[Full_System_Backup_with_rsync#With_a_single_command|rsync the entire system]] to the primary partition.<br />
Fix the bootloader configuration before rebooting.</div>Collinmanderson