Offline installation

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 repo with all the required files, and manually copying the files from the archiso. The first version is highly recommended.

Local Repo Method (Recommended)

Prepare local repo

Follow Pacman/Tips and tricks#Installing packages from a CD/DVD or USB stick for instructions on preparing a local repo with the neccesary 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

Mount and configure

Once the repo 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 repos.

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 repos 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 repos 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 repo, 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://github.com/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[dead link 2021-07-05 ⓘ] 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 the services and remove the file as they are unnecessary for the new system:

# systemctl disable pacman-init.service choose-mirror.service
# rm -r /etc/systemd/system/{choose-mirror.service,pacman-init.service,etc-pacman.d-gnupg.mount,getty@tty1.service.d}
# 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/getty@tty1.service.d/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 archlinux
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.