Difference between revisions of "Install from existing Linux"

From ArchWiki
Jump to: navigation, search
(Troubleshooting: empty sections are pretty useless)
(flagged broken section links (interactive))
(Tag: wiki-scripts)
 
(244 intermediate revisions by 77 users not shown)
Line 1: Line 1:
 
[[Category:Getting and installing Arch]]
 
[[Category:Getting and installing Arch]]
[[es:Install from Existing Linux]]
+
[[es:Install from existing Linux]]
 
[[fr:Install chroot]]
 
[[fr:Install chroot]]
[[it:Install from Existing Linux]]
+
[[it:Install from existing Linux]]
[[ru:Install from Existing Linux]]
+
[[ja:既存の Linux からインストール]]
[[uk:Install from Existing Linux]]
+
[[pt:Install from existing Linux]]
[[zh-CN:Install from Existing Linux]]
+
[[ru:Install from existing Linux]]
[[zh-TW:Install from Existing Linux]]
+
[[uk:Install from existing Linux]]
{{Out of date|Needs to be updated for pacman 4}}
+
[[zh-cn:Install from existing Linux]]
This guide is intended to combine and update the three previously existing and highly similar alternative install guides on this wiki.    This guide is intended for anybody who wants to install Arch Linux from any other running Linux -- be it off a LiveCD or a pre-existing install of a different distro.
+
[[zh-tw:Install from existing Linux]]
+
{{Related articles start}}
==Overview==
+
{{Related|Install from SSH}}
Arch Linux's [[pacman]] can be configured (-r) to perform operations in any directory you like, using that as the context of "root" while running.
+
{{Related articles end}}
+
This is useful for building up new Arch Linux systems from scratch from another distro's LiveCD or existing installation. It is also useful for creating new chroot environments on a "host" system, maintaining a "golden-master" for development & distribution, or other fun topics like [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]].
+
  
This guide requires that the existing host system be able to execute the new target Arch Linux architecture programs. In the case of an x86_64 host, it is possible to use i686-pacman to build a 32-bit chroot environment.  See [[Arch64 Install bundled 32bit system]].  However it is not so easy to build a 64-bit environment when the host only supports running 32-bit programs.
+
This document describes the bootstrapping process required to install Arch Linux from a running Linux host system.
 +
After bootstrapping, the installation proceeds as described in the [[Installation guide]].
  
Throughout this guide, we will refer to partitions as /dev/sdxx.  This refers to whatever dev entry you have on your system for the partition in question.  The convention is:
+
Installing Arch Linux from a running Linux is useful for:
Drive 1, Partition 1:  /dev/sda1
+
Drive 1, Partition 2:  /dev/sda2
+
Drive 2, Partition 1: /dev/sdb1
+
etc...
+
  
We will refer to it as /dev/sdxx whenever possible.
+
* remotely installing Arch Linux, e.g. a (virtual) root server
 +
* replacing an existing Linux without a LiveCD (see [[#Replacing the existing system without a LiveCD]])
 +
* creating a new Linux distribution or LiveCD based on Arch Linux
 +
* creating an Arch Linux chroot environment, e.g. for a Docker base container
 +
* [[Diskless_network_boot_NFS_root|rootfs-over-NFS for diskless machines]]
  
In this article,
+
The goal of the bootstrapping procedure is to setup an environment from which the scripts from {{Pkg|arch-install-scripts}} (such as {{ic|pacstrap}} and {{ic|arch-chroot}}) can be run.
;host: refers to the computer which is used to perform the installation.
+
  
;target: refers to the computer where you want to install Arch.  
+
If the host system runs Arch Linux, this can be achieved by simply installing {{Pkg|arch-install-scripts}}. If the host system runs another Linux distribution, you will first need to set up an Arch Linux-based chroot.
  
These may be one and the same computer. The host does not need to be an Arch system -- it can be a Debian or Redhat system, for example. The section entitled "Setup the host system" explains how to install pacman on the host. The following section "Setup the target system" explains how to use pacman from the host system to install Arch on the target system. Therefore if the host system is already running Arch, you can skip to "Setup the target system".
+
{{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.}}
  
Alternatively, if you have an Arch Linux Live CD, you can directly mount and use the root image in the Live CD as the host system with pacman and required libraries already installed. See section [[#Use Arch Linux Live CD Root Image as Host System]]
+
{{Warning|Please make sure you understand each step before proceeding. It is easy to destroy your system or to lose critical data, and your service provider will likely charge a lot to help you recover. }}
  
==Setup the host system==
+
==Backup and Preparation==
 +
Backup all your data including mails, webservers, etc. Have all information at your fingertips. Preserve all your server configurations, hostnames, etc.
  
You need to install the Arch Linux package manager, pacman, on your host Linux environment. In addition you will need a list of pacman mirror sites which is used to download data on available packages as well as the packages themselves. If you are already using Arch, skip this step and go to [[Install from Existing Linux#Setup the target system]].
+
Here is a list of data you will likely need:
 +
* IP address
 +
* hostname(s), (note: rootserver are mostly also part of the providers domain, check or save your {{ic|/etc/hosts}} before you delete)
 +
* DNS server (check {{ic|/etc/resolv.conf}})
 +
* SSH keys (if other people work on your server, they will have to accept new keys otherwise. This includes keys from your Apache, your mail servers, your SSH server and others.)
 +
* Hardware info (network card, etc. Refer to your pre-installed {{ic|/etc/modules.conf}} )
 +
* Grub configuration files.
  
===Get the required packages===
+
In general, it is a good idea to have a local copy of your original {{ic|/etc}} directory on your local hard drive.
  
====Introduction====
+
== From a host running Arch Linux ==
  
You need to get the required packages for your host Linux environment. The examples given here assume you are using an i686 environment. '''If you are running on a 64-bit Linux instead you should replace each occurrence of "i686" with "x86_64".'''
+
Install the {{Pkg|arch-install-scripts}} package.
  
All version numbers given here may change. Please check the version numbers the packages are at first and note them down. The version numbers can be found at:
+
Follow [[Installation guide#Mount the partitions]]. If you already use the {{ic|/mnt}} directory for something else, just create another directory such as {{ic|/mnt/install}}, and use that instead.
* {{pkg|pacman}}
+
* {{pkg|pacman-mirrorlist}}
+
  
Once you are sure of the version numbers, download the required packages (change the value of ARCH to either x86_64 or i686, see above):
+
Then follow [[Installation guide#Installation]]. You can skip [[Installation guide#Select the mirrors]], since the host should already have a correct mirrorlist.
  
ARCH=i686
+
{{Tip|In order to avoid redownloading all the packages, consider following [[Pacman/Tips and tricks#Network shared pacman cache]] or using ''pacstrap'''s {{ic|-c}} option.}}
base_chroot=/tmp
+
mkdir ${base_chroot}/archlinux
+
cd ${base_chroot}/archlinux
+
  
====Download pacman's binaries and shared libraries====
+
{{Merge|Moving_an_existing_install_into_(or_out_of)_a_virtual_machine#Moving_into_a_VM|Same approach.}}
  
You want to install pacman in order to be able to install software in your new base directory. We first download the binaries for [[pacman]], the Arch package manager.
+
{{Note|If you only want to create an exact copy of an existing Arch installation, it is also possible to just copy the filesystem to the new partition. With this method, you will still need to
* pacman: https://www.archlinux.org/packages/core/$ARCH/pacman/download/ . Change $ARCH according to your system.
+
* pacman-mirrorlist: https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/
+
  
==== Using wget to download ====
+
* Create [[Beginners'_guide#Generate_an_fstab|{{ic|/etc/fstab}}]]{{Broken section link}} and edit {{ic|/etc/hostname}}
wget  https://www.archlinux.org/packages/core/$ARCH/pacman/download/ --no-check-certificate --trust-server-names
+
* Delete {{ic|/etc/machine-id}} so that a new, unique, one will be regenerated on boot
wget https://www.archlinux.org/packages/core/any/pacman-mirrorlist/download/ --no-check-certificate --trust-server-names
+
* Make any other changes appropriate to the installation medium
 +
* Install the bootloader
  
or this direct way (give attention to the date string in the file name, as it may need changing) :
+
When copying the filesystem root, use something like {{ic|cp -ax}} or {{ic|rsync -axX}}. This avoids copying contents of mountpoints ({{ic|-x}}), and preserves the [[capabilities]] attributes of some system binaries ({{ic|rsync -X}}).
{{bc|wget http://mirrors.kernel.org/archlinux/core/os/i686/pacman-mirrorlist-20120626-1-any.pkg.tar.xz}}
+
}}
  
See [http://pwet.fr/man/linux/commandes/wget the man page] and the [http://www.gnu.org/software/wget/manual/wget.html official manual] of wget for further details.
+
== From a host running another Linux distribution ==
  
==== Using lftp to download ====
+
There are multiple tools which automate a large part of the steps described in the following subsections. See their respective homepages for detailed instructions.
If you have issues with downloading '''pacman-mirrorlist''' use this direct way with lftp :
+
{{bc|1=link_name=http://mirrors.kernel.org/archlinux/core/os/i686/
+
lftp -e "mget pacman-mirrorlist-*.tar.xz" "${link_name}"}}
+
  
==== Additional libraries====
+
* [https://github.com/tokland/arch-bootstrap arch-bootstrap] (Bash)
You may need additional libraries to make pacman work, for newer distributions:
+
* [https://github.com/hartwork/image-bootstrap image-bootstrap] (Python)
 +
* [https://github.com/drizzt/vps2arch vps2arch] (Bash)
 +
* [https://github.com/m4rienf/ArchCX archcx] (Bash, from Hetzner CX Rescue System)
  
for software_name in libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --no-check-certificate --trust-server-names ; done
+
The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.
  
When using an older distribution to bootstrap, a few more libraries may be needed for it to work, for example :
+
=== Creating the chroot ===
{{bc|for software_name in glibc gcc-libs binutils libssh2 curl gcc libarchive openssl xz expat ; do wget https://www.archlinux.org/packages/core/$ARCH/${software_name}/download/ --no-check-certificate --trust-server-names ; done}}
+
Also note that below when you set LD_LIBRARY_PATH you have to add /lib and /lib64:
+
{{bc|1=export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:${base_chroot}/archlinux/lib:${base_chroot}/archlinux/usr/lib64:$LD_LIBRARY_PATH}}
+
  
Unpack all needed packages:
+
Two methods to setup and enter the chroot are presented below, from the easiest to the most complicated. Select only one of the two methods. Then, continue at [[#Using the chroot environment]].
for f in *.pkg.tar*; do tar xvf $f; done
+
  
To prepare for using pacman, do not forget to edit {{Ic|/tmp/archlinux/etc/pacman.conf}} to point to {{Ic|/tmp/archlinux/etc/pacman.d/mirrorlist}} and select your favorite mirror. For easier use (assuming you are using {{Ic|bash}} or {{Ic|zsh}}), you may set up an environment:
+
==== Method A: Using the bootstrap image (recommended) ====
export PATH=${base_chroot}/archlinux/usr/bin:$PATH
+
export LD_LIBRARY_PATH=${base_chroot}/archlinux/usr/lib:$LD_LIBRARY_PATH
+
alias pacman="pacman --config ${base_chroot}/archlinux/etc/pacman.conf"
+
  
====Install pacman on the host system====
+
Download the bootstrap image from a [https://www.archlinux.org/download mirror]:
{{Note|('''Issues while running pacman on 64-bit host''') If while running pacman you end up with {{ic|/tmp/archlinux/usr/bin/pacman: No such file or directory}} please symlink ld-linux-x86-64.so.2: {{ic|ln -s /lib64/ld-linux-x86-64.so.2 /lib/}}}}
+
# cd /tmp
 +
# curl -O https://mirrors.kernel.org/archlinux/iso/2016.08.01/archlinux-bootstrap-2016.08.01-x86_64.tar.gz
  
 +
You can also download the signature (same URL with {{ic|.sig}} added) and [[GnuPG#Verify_a_signature|verify it with GnuPG]].
  
If you do not mind littering your install host, you can extract all the downloaded tar balls into your root directory by running as root:
+
Extract the tarball:
{{Note|However, keep in mind that this operation could erase some of your files, and break your system.}}
+
  # tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2016.08.01-x86_64.tar.gz
  cd /
+
for f in /tmp/archlinux/pacman-*pkg.tar.gz ; do
+
  tar xzf $f
+
done
+
  
<ol>
+
Select a repository server by editing {{ic|/tmp/root.x86_64/etc/pacman.d/mirrorlist}}.
<li><div>If installing from Ubuntu 9.10's LiveCD (perhaps other versions), you will need more than just the pacman files (shared libs) to use pacman at all.  Use Lucky's script described in [[https://bbs.archlinux.org/viewtopic.php?pid=759166 this thread]] to get/install them for you!
+
  
</div></li>
+
{{Note|If bootstrapping an i686 image from an x86_64 host system, also edit {{Ic|/tmp/root.i686/etc/pacman.conf}} and explicitly define {{Ic|1=Architecture = i686}} in order for pacman to pull the proper i686 packages.}}
<li><div>Alternatively, you can instead turn these tarballs into packages for your distribution with the [http://kitenet.net/~joey/code/alien/ alien] tool. See the man page of the tool for instructions. The packages created that way may be installed into your host distribution using the usual package management tools available there. This approach offers the best integration into the host Linux environment. For a Debian package based system this is done with the following commands:
+
cd /tmp/archlinux
+
alien -d pacman-*-i686.pkg.tar.xz
+
alien -d pacman-mirrorlist-20120626-1-any.pkg.tar.xz
+
  
RPM based systems will need to replace the parameter "-d" with "-r".
+
Enter the chroot
  
These distribution packages can then get installed using the normal package management tools of the host Linux environment.
+
* If bash 4 or later is installed, and unshare supports the --fork and --pid options:
</div></li>
+
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/
<li><div>
+
* Otherwise, run the following commands:
Under Fedora 12, I was not able to install pacman with any of the other methods, but with the nice script at https://bbs.archlinux.org/viewtopic.php?pid=734336#p734336 it will download and install it for you. Worked wonderfully for me.
+
# mount --bind /tmp/root.x86_64 /tmp/root.x86_64
</div></li>
+
# cd /tmp/root.x86_64
<li><div>On [http://gentoo.org/ Gentoo]: Just unmask pacman by adding {{Ic|sys-apps/pacman}} to {{Ic|/etc/portage/package.keywords}}. Now just run {{Ic|emerge -av pacman}}.
+
# cp /etc/resolv.conf etc
There is also a [http://ohnopub.net/~ohnobinki/gentoo/arch/ more detailed tutorial].
+
# mount -t proc /proc proc
</div></li>
+
# mount --rbind /sys sys
</ol>
+
# mount --rbind /dev dev
 +
# mount --rbind /run run    # (assuming /run exists on the system)
 +
# chroot /tmp/root.x86_64 /bin/bash
  
===Use Arch Linux Live CD Root Image as Host System===
+
==== Method B: Using the LiveCD image ====
  
Alternatively, instead of installing pacman on your host system, you can mount the root image of an Arch Linux Live CD 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.
+
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 a working Arch Linux installation right within the host system without the need to prepare it by installing specific packages.
  
====Unsquash the root image====
+
{{Note|Before proceeding, make sure the latest version of [http://squashfs.sourceforge.net/ squashfs] is installed on the host system. Otherwise, errors like the following are to be expected: {{ic|FATAL ERROR aborting: uncompress_inode_table: failed to read block}}.}}
  
The root image exists in squashfs format on the Live CD. The squashfs format is not editable as such. Hence, we unsquash the root image and then mount it.
+
* 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 mount it.
  
To unsquash the root image, run
+
*To unsquash the root image, run
unsquashfs -d /squashfs-root root-image.sqfs
+
{{bc|# unsquashfs airootfs.sfs}}
  
====Mount root file system====
+
* Before [[Change root|chrooting]] to it, we need to set up some mount points and copy the resolv.conf for networking.
 +
{{bc|
 +
# mount --bind squashfs-root squashfs-root
 +
# mount -t proc none squashfs-root/proc
 +
# mount -t sysfs none squashfs-root/sys
 +
# mount -o bind /dev squashfs-root/dev
 +
# mount -o bind /dev/pts squashfs-root/dev/pts  ## important for pacman (for signature check)
 +
# cp -L /etc/resolv.conf squashfs-root/etc  ## this is needed to use networking within the chroot
 +
}}
  
Then, mount the unsquashed root file system to a suitable mount point. We shall mount it to /arch. You can mount it wherever you want.
+
* Now, everything is prepared to chroot into the newly installed Arch environment
livecd_arch=/arch
+
{{bc|# chroot squashfs-root bash}}
mount -B /squashfs-root ${livecd_arch}
+
  
====Chroot into the Live CD root file system====
+
=== Using the chroot environment ===
  
Mount various file systems into the Live CD root file system:
+
The bootstrap environment is really barebones (no {{ic|nano}}, no {{ic|ping}}, no {{ic|cryptsetup}}, no {{ic|lvm}}). Therefore, we need to set up [[pacman]] in order to download the rest of the {{ic|base}} and, if needed, {{ic|base-devel}}.
mount -t proc /proc ${livecd_arch}/proc
+
mount -t sysfs /sys ${livecd_arch}/sys
+
mount -B /dev ${livecd_arch}/dev
+
mount -t devpts /dev/pts ${livecd_arch}/dev/pts
+
  
Then, chroot into the Live CD root file system:
+
==== Initializing pacman keyring ====
chroot ${livecd_arch} /bin/bash
+
  
===Configure the host system===
+
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:
 +
{{bc|
 +
# pacman-key --init
 +
# pacman-key --populate archlinux
 +
}}
  
The main goal of this operation is to make a proper configuration to pacman.
+
{{Tip|Installing and running {{Pkg|haveged}} must be done on the host system, since it is not possible to install packages before initializing pacman keyring and because ''systemd'' will detect it is running in a chroot and [https://superuser.com/questions/688733/start-a-systemd-service-inside-chroot ignore activation request].
  
Configure your /etc/pacman.conf to your liking, and remove unnecessary mirrors from /etc/pacman.d/mirrorlist. Also, enabling at least a few mirrors might become necessary, as you may experience errors during syncing if you have no mirror set. You may want to manually resolve DNS in the /etc/pacman.d/mirrorlist, because pacman for i686 may not be able to get address information on x86_64 systems.
+
If you go with doing {{ic|ls -Ra /}} in another console (TTY, terminal, SSH session...), do not be afraid of running it in a loop a few times: five or six runs from the host proved sufficient to generate enough entropy on a remote headless server.}}
+
If you are installing from a LiveCD, and you have a system with a low amount of combined RAM and swap (< 1 GB), be sure to set the cachedir in /etc/pacman.conf to be in the new Arch partition (e.g. {{ic|/newarch/var/cache/pacman/pkg}}).  Otherwise you could exhaust memory between the overhead of the existing distro and downloading necessary packages to install.
+
  
==Setup the target system==
+
==== Selecting a mirror and downloading basic tools ====
  
===Prepare a partition for Arch===
+
After [[Mirrors#Enabling_a_specific_mirror|selecting a mirror]], [[Mirrors#Force_pacman_to_refresh_the_package_lists|refresh the package lists]] and [[install]] what you need: {{Grp|base}}, {{Grp|base-devel}}, {{Pkg|parted}} etc.
  
You do not ''have to'' install Arch on a separate partition. You could instead build up a root filesystem in a normal directory, and then create a master tarball from it, or transfer it across the network.
+
=== Installation tips ===
  
However, most users will want to be installing Arch onto its own partition.
+
You can now proceed to [[Beginners' guide#Prepare the storage devices|preparing the storage devices]] and follow the rest of the [[Installation guide#Installation|installation procedure]].
  
Prepare any partitions and filesystems you need for your installation. If your host system has any GUI tools for this, such as gparted, cfdisk, or Mandrake's diskdrake, feel free to use them.  
+
Some host systems or configurations may require certain extra steps. See the sections below for tips.
+
To format a partition as ext4, you run (where /dev/sdxx is the partition you want to setup):
+
mkfs.ext4 /dev/sdxx
+
To format it as ext3 with journaling and dir_index:
+
mkfs.ext4 -j -O dir_index /dev/sdxx
+
To format it as reiserfs:
+
mkreiserfs /dev/sdxx
+
To format a partition as swap, and to start using it:
+
mkswap /dev/sdxx
+
swapon /dev/sdxx
+
  
Most other filesystems can be setup with their own mkfs variant, take a look using tab completion. Available filesystems depend entirely on your host system.
+
===== Debian-based host =====
+
Once you have your filesystems setup, mount them. Throughout this guide, we will refer to the new Arch root directory as /newarch, however you can put it wherever you like.
+
new_arch=/newarch
+
mkdir ${new_arch}
+
mount /dev/sdxx ${new_arch}
+
  
===Install the core===
+
====== /dev/shm ======
  
Update pacman. You may have to create the {{ic|/newarch/var/lib/pacman}} folder for it to work (see "Setup the host system" above):
+
On some Debian-based host systems, {{ic|pacstrap}} may produce the following error:
mkdir -p ${new_arch}/var/lib/pacman
+
pacman -Sy -r ${new_arch}
+
  
Install the 'base' group of packages and the Archlinux keyring:
+
{{hc|# pacstrap /mnt base|
mkdir -p ${new_arch}/var/cache/pacman/pkg
+
==> Creating install root at /mnt
pacman  -S base archlinux-keyring --cachedir ${new_arch}/var/cache/pacman/pkg -r ${new_arch}
+
mount: mount point /mnt/dev/shm is a symbolic link to nowhere
 +
==> ERROR: failed to setup API filesystems in new root
 +
}}
  
===Prepare /dev nodes===
+
This is because in some versions of Debian, {{ic|/dev/shm}} points to {{ic|/run/shm}} while in the Arch-based chroot, {{ic|/run/shm}} does not exist and the link is broken. To correct this error, create a directory {{ic|/run/shm}}:
 +
# mkdir /run/shm
  
First, ensure the correct {{ic|/dev}} nodes have been made for [[udev]]:
+
====== /dev/pts ======
ls -alF ${new_arch}/dev
+
  
This result in a list containing lines similar to the following (the dates will differ for you):
+
While installing {{ic|archlinux-2015.07.01-x86_64}} from a Debian 7 host, the following error prevented both [https://projects.archlinux.org/arch-install-scripts.git/tree/pacstrap.in pacstrap] and [[Change_root#Using_arch-chroot|arch-chroot]] from working:
crw-------  1 root root 5, 1 2008-12-27 21:40 console
+
crw-rw-rw-  1 root root 1, 3 2008-12-27 21:42 null
+
crw-rw-rw-  1 root root 1, 5 2008-12-27 21:40 zero
+
  
Delete and recreate any device which has a different set of permissions (the crw-... stuff plus the two root entries) and major/minor numbers (the two before the date).
+
{{hc|# pacstrap -i /mnt|
 +
mount: mount point /mnt/dev/pts does not exist
 +
==> ERROR: failed to setup chroot /mnt
 +
}}
  
cd ${new_arch}/dev
+
Apparently, this is because these two scripts use a common function. {{ic|chroot_setup()}}[https://projects.archlinux.org/arch-install-scripts.git/tree/common#n76] relies on newer features of {{Pkg|util-linux}}, which are incompatible with Debian 7 userland (see {{Bug|45737}}).
rm -f console ; mknod -m 600 console c 5 1
+
rm -f null ; mknod -m 666 null c 1 3
+
rm -f zero ; mknod -m 666 zero c 1 5
+
  
All device nodes should have been created for you already with the right permissions and you should not need to recreate any of them.
+
The solution for ''pacstrap'' is to manually execute its [https://projects.archlinux.org/arch-install-scripts.git/tree/pacstrap.in#n77 various tasks], but use the [[Change_root#Using_chroot|regular procedure]] to mount the kernel filesystems on the target directory ({{ic|"$newroot"}}):
  
===Chroot===
+
{{bc|1=
Now we will [[Change Root|chroot into the new Arch system]].
+
# newroot=/mnt
 +
# mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc}
 +
# mkdir -m 1777 -p "$newroot"/tmp
 +
# mkdir -m 0555 -p "$newroot"/{sys,proc}
 +
# mount --bind "$newroot" "$newroot"
 +
# mount -t proc /proc "$newroot/proc"
 +
# mount --rbind /sys "$newroot/sys"
 +
# mount --rbind /run "$newroot/run"
 +
# mount --rbind /dev "$newroot/dev"
 +
# pacman -r "$newroot" --cachedir="$newroot/var/cache/pacman/pkg" -Sy base base-devel ... ## add the packages you want
 +
# cp -a /etc/pacman.d/gnupg "$newroot/etc/pacman.d/"      ## copy keyring
 +
# cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/"  ## copy mirrorlist
 +
}}
  
In order for DNS to work properly you need to edit {{ic|${new_arch}/etc/resolv.conf}} or replace it with the resolv.conf from your running distribution
+
Instead of using {{ic|arch-chroot}} for [[Beginners' guide#Chroot and configure the base system|configuring the base system]]{{Broken section link}}, simply use {{ic|chroot "$newroot"}}.
cp /etc/resolv.conf ${new_arch}/etc/
+
  
Also, you need to copy a correctly setup mirrorlist into the new system:
+
====== lvmetad ======
cp /etc/pacman.d/mirrorlist ${new_arch}/etc/pacman.d
+
  
Finally edit the pacman configuration file {{ic|${new_arch}/etc/pacman.conf}} setting "Architecture" so that it matches the one of the target system.
+
Trying to create [[LVM]] [[LVM#Logical_volumes|logical volumes]] from an {{ic|archlinux-bootstrap-2015.07.01-x86_64}} environment on a Debian 7 host resulted in the following error:
The default of "auto" might fail if it is different from the host system.
+
  
Architecture = i686 or x86_64
+
{{hc|# lvcreate -L 20G lvm -n root|
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
  /dev/lvm/root: not found: device not cleared
 +
  Aborting. Failed to wipe start of new LV.}}
  
Mount various filesystems into the new Arch system:
+
(Physical volume and volume group creation worked despite {{ic|/run/lvm/lvmetad.socket: connect failed: No such file or directory}} being displayed.)
mount -t proc proc ${new_arch}/proc
+
mount -t sysfs sys ${new_arch}/sys
+
mount -o bind /dev ${new_arch}/dev
+
mount -t devpts pts ${new_arch}/dev/pts
+
  
If you have a separate {{ic|/boot}} partition, you will probably need to mount that too. See [[Change Root]] for more details.
+
This could be easily worked around by creating the logical volumes outside the chroot (from the Debian host). They are then available once chrooted again.
  
{{Warning|If you have a separate {{ic|/boot}} partition and plan on using grub2, make sure to mount {{ic|/boot}} after chrooting. If you mount the {{ic|/boot}} partition before the chroot, grub2 will assume that {{ic|/boot}} and root are on the same partition and will not update correctly. }}
+
{{Accuracy|This problem did not arise when installing from a Debian 7 host without lvmetad enabled. The recommended messaround with {{ic|/etc/lvm/lvm.conf}} looks rather error prone (2015-07-26).}}
 +
{{Style|Language and formatting are lacking, links to relevant articles in the wiki as well.}}
  
When everything is prepared, chroot into the new filesystem:  
+
Also, if the system you are using has lvm, you might have the following output:
  
chroot ${new_arch} /bin/bash
+
{{hc|1=# grub-install --target=i386-pc --recheck /dev/mapper/main-archroot|2=
 +
Installing for i386-pc platform.
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
 +
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
 +
}}
  
Then setup [[pacman-key]] and verify the Master keys:
+
This is because debian does not use lvmetad by default. You need to edit {{ic|/etc/lvm/lvm.conf}} and set {{ic|use_lvmetad}} to {{ic|0}}:
pacman-key --init ; pacman-key --populate archlinux
+
  
===Install the rest===
+
use_lvmetad = 0
Install your preferred kernel, and any other packages you may wish to install.
+
For the default kernel (which is already installed!):
+
pacman -S --needed linux
+
  
If you wish to install extra packages now, you may do so with:  
+
This will trigger later an error on boot in the initrd stage. Therefore, you have to change it back after the grub generation. In a software RAID + LVM, steps would be the following:
pacman -S packagename
+
  
===Configure the target system===
+
* After installing all the system, when you have to do all the initramfs (mkinitcpio) and grub thing.
Edit your {{ic|/etc/fstab}}, remembering to add /, swap and any other partitions you may wish to use.
+
* Change /etc/mdadm.conf to reflect your RAID config (if any)
+
* Change HOOKS and MODULES according to lvm and raid requirements: {{ic|1=MODULES="dm_mod" HOOKS="base udev '''mdadm_udev''' ... block '''lvm2''' filesystems ..."}}
Edit your {{ic|/etc/rc.conf}}, {{ic|/etc/hosts}} and {{ic|/etc/mkinitcpio.conf}} to your needs. If you are installing Arch Linux to a USB flash drive, don't forget to add the {{ic|usb}} hook to {{ic|/etc/mkinitcpio.conf}}. Then, rebuild the initcpio image:
+
* Generate initrd images with mkinitcpio
mkinitcpio -p linux
+
* Change /etc/lvm/lvm.conf to put use_lvmetad = 0
 +
* Generate grub config (grub-mkconfig)
 +
* Change /etc/lvm/lvm.conf to put use_lvmetad = 1
  
Edit {{ic|/etc/locale.gen}}, uncommenting any locales you wish to have available, and build the locales:
+
===== Fedora-based host =====
locale-gen
+
  
===Setup Grub===
+
On Fedora based hosts and live USBs you may encounter problems when using {{ic|genfstab}} to generate your [[fstab]]. Remove duplicate entries and the "seclabel" option where it appears, as this is Fedora-specific and will keep your system from booting normally.
To use [[GRUB]] when chrooted, you need to ensure that {{ic|/etc/mtab}} is up-to-date:
+
diff /etc/mtab /proc/mounts
+
If you get any output from the previous command, run:
+
grep -v rootfs /proc/mounts > /etc/mtab 
+
  
You can now run:
+
== Things to check before you reboot==
grub-install /dev/sdx
+
  
If grub-install fails, you can manually install:
+
Before rebooting, chroot into the newly-installed system.
grub
+
grub> find /boot/grub/stage1    (You should see some results here if you have done everything right so far.  If not, back up and retrace your steps.)
+
grub> root (hd0,X)    (Note that Grub 1 and Grub 2 differ in how they each handle partition numbering. See the GRUB articles for info.)
+
grub> setup (hd0)
+
grub> quit
+
  
Double-check your {{ic|/boot/grub/menu.lst}}. Depending on the host, it could need correcting from hda to sda, and a prefix of /boot as well in the paths.
+
Set a root password so that you can log in with ssh later:
 +
# passwd
  
====Manual recovery of GRUB libs ====
+
Install [[ssh]] and [[enable]] it to start automatically at boot.
  
The {{ic|*stage*}} files are expected to be in {{ic|/boot/grub}}, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc.
+
Configure the [[network]] connection to start automatically at boot.
  
Manually copy the grub libs like so:
+
Set up a [[boot loader]] and configure it to use the swap partition you appropriated earlier as the root partition. You might want to configure your bootloader to be able to boot into your old system; it is helpful to re-use the server's existing /boot partition in the new system for this purpose.
# cp -a /usr/lib/grub/i386-pc/* /boot/grub
+
  
{{Note|Do not forget to mount the system's boot partition if your setup uses a separate one!  The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!}}
+
== Replacing the existing system without a LiveCD ==
  
Detailed instructions for [[GRUB]], [[GRUB2]], [[LILO]], [[Burg]] and [[Syslinux]] are available; see also [[:Category:Boot loaders]].
+
Find ~700MB of free space somewhere on the disk, e.g. by partitioning a swap partition. You can disable the swap partition and set up your system there.  
  
===Finishing touches===
+
===Set old swap partition as new root partition===
See [[Beginners_Guide#Configure_the_system|Beginners Guide:Configure the system]]. You can ignore 2.11, but the rest of that guide should be of use to you in post-installation configuration of your system.
+
+
[[Change_Root#Cleaning_up|Exit your chroot]]:
+
exit
+
umount ${new_arch}/boot  # if you mounted this or any other separate partitions
+
umount ${new_arch}/{proc,sys,dev}
+
umount ${new_arch}
+
  
Reboot to your new Arch system!
+
Check {{ic|cfdisk}}, {{ic|/proc/swaps}} or {{ic|/etc/fstab}} to find your swap partition. Assuming your hard drive is located on sdaX (X will be a number).
  
== An alternate, simpler installation method ==
+
Do the following:
  
This method is verified to be working as of 1-4-12.
+
Disable the swap space:
This works best if you are in a LiveCD environment (or, in the case of servers, a GNU/Linux-based rescue environment). Firstly, you need to mount the disk you want to use for the Archlinux installation at /mnt. In this example, /dev/sda1 is used.
+
  # swapoff /dev/sdaX
  mnt /dev/sda1 /mnt
+
cd ~
+
wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh && chmod +x arch-bootstrap.sh
+
  
If you are wanting to install a 32-bit system:
+
Create a filesystem on it
  ./arch-bootstrap.sh -a i686 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
+
  # fdisk /dev/sda
Or a 64-bit system:
+
(set /dev/sdaX ID field to "Linux" - Hex 83)
  ./arch-bootstrap.sh -a x86_64 -r "ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org" /mnt/
+
  # mke2fs -j /dev/sdaX
  
The bootstrapping will take 2-5 minutes depending on the speed of your system.
+
Create a directory to mount it in
 +
# mkdir /mnt/newsys
  
mount -t proc none /mnt/proc
+
Finally, mount the new directory for installing the intermediate system.
  mount -t sysfs none /mnt/sys
+
  # mount -t ext4 /dev/sdaX /mnt/newsys
mount -o bind /dev /mnt/dev
+
  
Mounting these is essential for the installation of a bootloader later on.
+
=== Installation ===
 +
If less than 700MB are available, examine the packages in the group base, and select only those required to get a system with internet connection up and running in the temporary partition. This will mean explicitly specifying individual packages to pacstrap, as well as passing it the -c option, to get packages downloaded to the host system to avoid filling up valuable space.
  
If you have switched between architectures, ''pacman'' auto-detection might not work, in this case you need to edit /etc/pacman.conf to:
+
Once the new Arch Linux system is installed, reboot into the newly created system, and [[Full system backup with rsync#With_a_single_command|rsync the entire system]] to the primary partition.
 
+
Fix the bootloader configuration before rebooting.
From 64-bit to a 32-bit system:
+
Architecture = i686
+
Or from 32-bit to a 64-bit system:
+
Architecture = x86_64
+
 
+
Now for the fun part, chroot into your newly installed Arch installation:
+
chroot /mnt bash
+
pacman -Sy base
+
mkinitcpio -p linux
+
 
+
Choose a bootloader. You can find the installation instructions on their own dedicated pages. ([[Syslinux]], [[Grub]], [[Grub2]], etc.).
+
 
+
'''Remember:''' You will still need to do any final configuration touches as you would in a normal Arch install.
+
 
+
''Credits to the Turkish site [http://raptiye.org/blog/2011/3/27/hetznerde-arch-linux-kurulumu/ Raptiye] for the original guide.''
+

Latest revision as of 10:36, 7 August 2016

Related articles

This document describes the bootstrapping process required to install Arch Linux from a running Linux host system. After bootstrapping, the installation proceeds as described in the Installation guide.

Installing Arch Linux from a running Linux is useful for:

The goal of the bootstrapping procedure is to setup an environment from which the scripts from arch-install-scripts (such as pacstrap and arch-chroot) can be run.

If the host system runs Arch Linux, this can be achieved by simply installing arch-install-scripts. If the host system runs another Linux distribution, you will first need to set up an Arch Linux-based chroot.

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.
Warning: Please make sure you understand each step before proceeding. It is easy to destroy your system or to lose critical data, and your service provider will likely charge a lot to help you recover.

Backup and Preparation

Backup all your data including mails, webservers, etc. Have all information at your fingertips. Preserve all your server configurations, hostnames, etc.

Here is a list of data you will likely need:

  • IP address
  • hostname(s), (note: rootserver are mostly also part of the providers domain, check or save your /etc/hosts before you delete)
  • DNS server (check /etc/resolv.conf)
  • SSH keys (if other people work on your server, they will have to accept new keys otherwise. This includes keys from your Apache, your mail servers, your SSH server and others.)
  • Hardware info (network card, etc. Refer to your pre-installed /etc/modules.conf )
  • Grub configuration files.

In general, it is a good idea to have a local copy of your original /etc directory on your local hard drive.

From a host running Arch Linux

Install the arch-install-scripts package.

Follow Installation guide#Mount the partitions. If you already use the /mnt directory for something else, just create another directory such as /mnt/install, and use that instead.

Then follow Installation guide#Installation. You can skip Installation guide#Select the mirrors, since the host should already have a correct mirrorlist.

Tip: In order to avoid redownloading all the packages, consider following Pacman/Tips and tricks#Network shared pacman cache or using pacstrap's -c option.

Merge-arrows-2.pngThis article or section is a candidate for merging with Moving_an_existing_install_into_(or_out_of)_a_virtual_machine#Moving_into_a_VM.Merge-arrows-2.png

Notes: Same approach. (Discuss in Talk:Install from existing Linux#)
Note: If you only want to create an exact copy of an existing Arch installation, it is also possible to just copy the filesystem to the new partition. With this method, you will still need to
  • Create /etc/fstab[broken link: invalid section] and edit /etc/hostname
  • Delete /etc/machine-id so that a new, unique, one will be regenerated on boot
  • Make any other changes appropriate to the installation medium
  • Install the bootloader

When copying the filesystem root, use something like cp -ax or rsync -axX. This avoids copying contents of mountpoints (-x), and preserves the capabilities attributes of some system binaries (rsync -X).

From a host running another Linux distribution

There are multiple tools which automate a large part of the steps described in the following subsections. See their respective homepages for detailed instructions.

The manual way is presented in the following subsections. The idea is to run an Arch system inside the host system, with the actual installation being executed from the Arch system. The nested system is contained inside a chroot.

Creating the chroot

Two methods to setup and enter the chroot are presented below, from the easiest to the most complicated. Select only one of the two methods. Then, continue at #Using the chroot environment.

Method A: Using the bootstrap image (recommended)

Download the bootstrap image from a mirror:

# cd /tmp
# curl -O https://mirrors.kernel.org/archlinux/iso/2016.08.01/archlinux-bootstrap-2016.08.01-x86_64.tar.gz

You can also download the signature (same URL with .sig added) and verify it with GnuPG.

Extract the tarball:

# tar xzf <path-to-bootstrap-image>/archlinux-bootstrap-2016.08.01-x86_64.tar.gz

Select a repository server by editing /tmp/root.x86_64/etc/pacman.d/mirrorlist.

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

Enter the chroot

  • If bash 4 or later is installed, and unshare supports the --fork and --pid options:
# /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/
  • Otherwise, run the following commands:
# mount --bind /tmp/root.x86_64 /tmp/root.x86_64
# cd /tmp/root.x86_64
# cp /etc/resolv.conf etc
# mount -t proc /proc proc
# mount --rbind /sys sys
# mount --rbind /dev dev
# mount --rbind /run run    # (assuming /run exists on the system)
# chroot /tmp/root.x86_64 /bin/bash

Method B: Using the LiveCD image

It is possible to mount the root image of the latest Arch Linux installation media and then chroot into it. This method has the advantage of providing a working Arch Linux installation right within the host system without the need to prepare it by installing specific packages.

Note: Before proceeding, make sure the latest version of squashfs is installed on the host system. Otherwise, errors like the following are to be expected: FATAL ERROR aborting: uncompress_inode_table: failed to read block.
  • The root image can be found on one of the mirrors under either arch/x86_64/ or arch/i686/, depending on the desired architecture. The squashfs format is not editable, so we unsquash the root image and mount it.
  • To unsquash the root image, run
# unsquashfs airootfs.sfs
  • Before chrooting to it, we need to set up some mount points and copy the resolv.conf for networking.
# mount --bind squashfs-root squashfs-root
# mount -t proc none squashfs-root/proc
# mount -t sysfs none squashfs-root/sys
# mount -o bind /dev squashfs-root/dev
# mount -o bind /dev/pts squashfs-root/dev/pts  ## important for pacman (for signature check)
# cp -L /etc/resolv.conf squashfs-root/etc  ## this is needed to use networking within the chroot
  • Now, everything is prepared to chroot into the newly installed Arch environment
# chroot squashfs-root bash

Using the chroot environment

The bootstrap environment is really barebones (no nano, no ping, no cryptsetup, no lvm). Therefore, we need to set up pacman in order to download the rest of the base and, if needed, base-devel.

Initializing pacman keyring

Before starting the installation, pacman keys need to be setup. Before running the following two commands, read pacman-key#Initializing the keyring to understand the entropy requirements:

# pacman-key --init
# pacman-key --populate archlinux
Tip: Installing and running haveged must be done on the host system, since it is not possible to install packages before initializing pacman keyring and because systemd will detect it is running in a chroot and ignore activation request. If you go with doing ls -Ra / in another console (TTY, terminal, SSH session...), do not be afraid of running it in a loop a few times: five or six runs from the host proved sufficient to generate enough entropy on a remote headless server.

Selecting a mirror and downloading basic tools

After selecting a mirror, refresh the package lists and install what you need: base, base-devel, parted etc.

Installation tips

You can now proceed to preparing the storage devices and follow the rest of the installation procedure.

Some host systems or configurations may require certain extra steps. See the sections below for tips.

Debian-based host
/dev/shm

On some Debian-based host systems, pacstrap may produce the following error:

# pacstrap /mnt base
==> Creating install root at /mnt
mount: mount point /mnt/dev/shm is a symbolic link to nowhere
==> ERROR: failed to setup API filesystems in new root

This is because in some versions of Debian, /dev/shm points to /run/shm while in the Arch-based chroot, /run/shm does not exist and the link is broken. To correct this error, create a directory /run/shm:

# mkdir /run/shm
/dev/pts

While installing archlinux-2015.07.01-x86_64 from a Debian 7 host, the following error prevented both pacstrap and arch-chroot from working:

# pacstrap -i /mnt
mount: mount point /mnt/dev/pts does not exist
==> ERROR: failed to setup chroot /mnt

Apparently, this is because these two scripts use a common function. chroot_setup()[1] relies on newer features of util-linux, which are incompatible with Debian 7 userland (see FS#45737).

The solution for pacstrap is to manually execute its various tasks, but use the regular procedure to mount the kernel filesystems on the target directory ("$newroot"):

# newroot=/mnt
# mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc}
# mkdir -m 1777 -p "$newroot"/tmp
# mkdir -m 0555 -p "$newroot"/{sys,proc}
# mount --bind "$newroot" "$newroot"
# mount -t proc /proc "$newroot/proc"
# mount --rbind /sys "$newroot/sys"
# mount --rbind /run "$newroot/run"
# mount --rbind /dev "$newroot/dev"
# pacman -r "$newroot" --cachedir="$newroot/var/cache/pacman/pkg" -Sy base base-devel ... ## add the packages you want
# cp -a /etc/pacman.d/gnupg "$newroot/etc/pacman.d/"       ## copy keyring
# cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/"  ## copy mirrorlist

Instead of using arch-chroot for configuring the base system[broken link: invalid section], simply use chroot "$newroot".

lvmetad

Trying to create LVM logical volumes from an archlinux-bootstrap-2015.07.01-x86_64 environment on a Debian 7 host resulted in the following error:

# lvcreate -L 20G lvm -n root
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /dev/lvm/root: not found: device not cleared
  Aborting. Failed to wipe start of new LV.

(Physical volume and volume group creation worked despite /run/lvm/lvmetad.socket: connect failed: No such file or directory being displayed.)

This could be easily worked around by creating the logical volumes outside the chroot (from the Debian host). They are then available once chrooted again.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This problem did not arise when installing from a Debian 7 host without lvmetad enabled. The recommended messaround with /etc/lvm/lvm.conf looks rather error prone (2015-07-26). (Discuss in Talk:Install from existing Linux#)

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Language and formatting are lacking, links to relevant articles in the wiki as well. (Discuss in Talk:Install from existing Linux#)

Also, if the system you are using has lvm, you might have the following output:

# grub-install --target=i386-pc --recheck /dev/mapper/main-archroot
Installing for i386-pc platform.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.

This is because debian does not use lvmetad by default. You need to edit /etc/lvm/lvm.conf and set use_lvmetad to 0:

use_lvmetad = 0

This will trigger later an error on boot in the initrd stage. Therefore, you have to change it back after the grub generation. In a software RAID + LVM, steps would be the following:

  • After installing all the system, when you have to do all the initramfs (mkinitcpio) and grub thing.
  • Change /etc/mdadm.conf to reflect your RAID config (if any)
  • Change HOOKS and MODULES according to lvm and raid requirements: MODULES="dm_mod" HOOKS="base udev mdadm_udev ... block lvm2 filesystems ..."
  • Generate initrd images with mkinitcpio
  • Change /etc/lvm/lvm.conf to put use_lvmetad = 0
  • Generate grub config (grub-mkconfig)
  • Change /etc/lvm/lvm.conf to put use_lvmetad = 1
Fedora-based host

On Fedora based hosts and live USBs you may encounter problems when using genfstab to generate your fstab. Remove duplicate entries and the "seclabel" option where it appears, as this is Fedora-specific and will keep your system from booting normally.

Things to check before you reboot

Before rebooting, chroot into the newly-installed system.

Set a root password so that you can log in with ssh later:

# passwd

Install ssh and enable it to start automatically at boot.

Configure the network connection to start automatically at boot.

Set up a boot loader and configure it to use the swap partition you appropriated earlier as the root partition. You might want to configure your bootloader to be able to boot into your old system; it is helpful to re-use the server's existing /boot partition in the new system for this purpose.

Replacing the existing system without a LiveCD

Find ~700MB of free space somewhere on the disk, e.g. by partitioning a swap partition. You can disable the swap partition and set up your system there.

Set old swap partition as new root partition

Check cfdisk, /proc/swaps or /etc/fstab to find your swap partition. Assuming your hard drive is located on sdaX (X will be a number).

Do the following:

Disable the swap space:

# swapoff /dev/sdaX

Create a filesystem on it

# fdisk /dev/sda
(set /dev/sdaX ID field to "Linux" - Hex 83)
# mke2fs -j /dev/sdaX

Create a directory to mount it in

# mkdir /mnt/newsys

Finally, mount the new directory for installing the intermediate system.

# mount -t ext4 /dev/sdaX /mnt/newsys

Installation

If less than 700MB are available, examine the packages in the group base, and select only those required to get a system with internet connection up and running in the temporary partition. This will mean explicitly specifying individual packages to pacstrap, as well as passing it the -c option, to get packages downloaded to the host system to avoid filling up valuable space.

Once the new Arch Linux system is installed, reboot into the newly created system, and rsync the entire system to the primary partition. Fix the bootloader configuration before rebooting.