Offline installation

From ArchWiki

If you wish to install the Archiso (e.g. the official monthly release) as it is without an Internet connection, or, if you do not want to download the packages you want again:

First, follow the Installation guide, skipping the Installation guide#Connect to the internet section, until the Installation guide#Install essential packages step.

There are two main methods to enable bootstrapping the new installation: preparing a local pacman repository with all the required files, and manually copying the files from the archiso. The first version is highly recommended.

Local Repository Method (Recommended)

Prepare local repository

Follow Pacman/Tips and tricks#Installing packages from a CD/DVD or USB stick for instructions on preparing a local repository with the necessary files on a separate host installation.

At the very least, for a functioning system, the following packages are recommended:

# pacman -Syw --cachedir . --dbpath /tmp/blankdb base base-devel linux linux-firmware systemd mkinitcpio vim

Create your custom offline repository

# repo-add ./custom.db.tar.gz ./*

Mount and configure

Once the repository is prepared, connect the external media to the new installation, and mount it on the newly created root filesystem:

# mkdir /mnt/repo
# mount /dev/sdX /mnt/repo

Edit your archiso /etc/pacman.conf and add a new section:

[custom]
SigLevel = Optional
Server = file:///mnt/repo/

Comment out [core], [extra] and [community] so that pacman does not fail on the default repositories.

Pacstrap

You can now continue to pacstrap your locally-available packages to the new installation:

# pacstrap /mnt base base-devel linux linux-firmware mkinitcpio systemd vim

Chroot

In case the new system is expected to remain offline or airgapped, it should be configured to expect local repositories only.

After chrooting into your new installation, edit the new /etc/pacman.conf in the same way as previously (but without the /mnt prefix):

[custom]
SigLevel = Optional
Server = file:///repo/

Comment out all other repositories and save. Continue configuring the new system as usual.

From now on any updates to the offline system can be made by bringing an up to date copy of the local repository, mounting it to /repo and running pacman commands as usual.

File Copy Method

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

Reason: Instead of copying the files from the archiso, the "bootstrap" images available on the Arch mirrors can be extracted directly to the target disk. You will get a minimal system without the need to deal with the archiso modifications. (Discuss in Talk:Offline installation)

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: The names and locations of multiple files (the kernel, mkinitcpio hooks and configuration file, journald configuration, choose-mirror script, etc.) have changed. (Discuss in Talk:Offline installation)

Install the archiso to the new root

Instead of installing the packages with pacstrap (which would try to download from the remote repositories), copy everything in the live environment to the new root:

# cp -ax / /mnt
Note: The option (-x) excludes some special directories, as they should not be copied to the new root.

Then, copy the kernel image to the new root, in order to keep the integrity of the new system:

# cp -vaT /run/archiso/bootmnt/arch/boot/$(uname -m)/vmlinuz /mnt/boot/vmlinuz-linux

After that, generate a fstab as described in Installation guide#Fstab.

Chroot and configure the base system

Next, chroot into your newly installed system:

# arch-chroot /mnt /bin/bash
Note: Before performing the other Installation guide#Configure the system steps (e.g. locale, keymap, etc.), it is necessary to get rid of the trace of the Live environment (in other words, the customization of archiso which does not fit a non-Live environment).

Restore the configuration of journald

This customization of archiso will lead to storing the system journal in RAM, it means that the journal will not be available after reboot:

# sed -i 's/Storage=volatile/#Storage=auto/' /etc/systemd/journald.conf

Remove special udev rule

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Looking at https://gitlab.archlinux.org/archlinux/archiso/commit/0d67870667ee8c2084dea2bbdf1323288e2e7457 this paragraph needs to be reworked with the change to systemd-networkd and systemd-resolved (Discuss in Talk:Offline installation)

This rule of udev starts the dhcpcd automatically if there are any wired network interfaces.

# rm /etc/udev/rules.d/81-dhcpcd.rules

Disable and remove the services created by archiso

Some service files are created for the Live environment, please disable pacman-init.service, choose-mirror.service and remove the file as they are unnecessary for the new system:

# rm -r /etc/systemd/system/{choose-mirror.service,pacman-init.service,etc-pacman.d-gnupg.mount,[email protected]}
# rm /etc/systemd/scripts/choose-mirror

Remove special scripts of the Live environment

There are some scripts installed in the live system by archiso scripts, which are unnecessary for the new system:

# rm /etc/systemd/system/[email protected]/autologin.conf
# rm /root/{.automated_script.sh,.zlogin}
# rm /etc/mkinitcpio-archiso.conf
# rm -r /etc/initcpio
Note: mkinitcpio-archiso.conf file is no longer available, see #Configuring Initramfs for additional instructions

Importing archlinux keys

In order to use the official repositories, we need to import the archlinux master keys (pacman/Package signing#Initializing the keyring). This step is usually done by pacstrap but can be achieved with

# pacman-key --init
# pacman-key --populate
Note: Keyboard or mouse activity is needed to generate entropy and speed-up the first step.

Configuring Initramfs

Since you have copied the filesystem from the archiso, the mkinitcpio.conf needs to be edited in order for the proper initramfs to be installed. Open up /etc/mkinitcpio.conf in a text editor of your choice and comment/remove the only uncommented HOOKS and replace with:

# HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)

Configure the system

Now you can follow the skipped steps of the Installation guide#Configure the system section (setting a locale, timezone, hostname, etc.) and finish the installation by creating an initial ramdisk as described in Installation guide#Initramfs.