Offline installation: Difference between revisions

From ArchWiki
m (→‎See also: spelling)
m (→‎See also: avoid redirect)
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
[[cs:Offline installation]]
[[cs:Offline installation]]
[[ja:オフラインインストール]]
[[ja:オフラインインストール]]
[[pt:Offline installation]]
[[ru:Offline installation]]
[[ru:Offline installation]]
[[zh-hans:Offline installation]]
[[zh-hans:Offline installation]]
Line 19: Line 20:
  # pacman -Syw --cachedir . --dbpath /tmp/blankdb base base-devel linux linux-firmware mkinitcpio vim
  # pacman -Syw --cachedir . --dbpath /tmp/blankdb base base-devel linux linux-firmware mkinitcpio vim


Create your custom offline repository
Create your custom offline repository:


  # repo-add ./custom.db.tar.gz ./*[^sig]
  # repo-add ./custom.db.tar.gz ./*[^sig]
Line 39: Line 40:
}}
}}


Comment out {{ic|[core]}} and {{ic|[extra]}} so that pacman does not fail on the default repositories.
Comment out {{ic|[core]}} and {{ic|[extra]}} so that ''pacman'' does not fail on the default repositories.


== Pacstrap ==
== Pacstrap ==


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


  # pacstrap -K /mnt base base-devel linux linux-firmware mkinitcpio vim
  # pacstrap -K /mnt base base-devel linux linux-firmware mkinitcpio vim
Line 53: Line 54:
In case the offline installation process was only temporary, but requires manual installation of some packages before being able to access a network, see [[pacman#Additional commands]] to learn how to install local packages.  
In case the offline installation process was only temporary, but requires manual installation of some packages before being able to access a network, see [[pacman#Additional commands]] to learn how to install local packages.  


[[Shell]] [[Wikipedia:Glob_(programming)|globbing]] can be used to install many packages at once:  
[[Shell]] [[Wikipedia:Glob (programming)|globbing]] can be used to install many packages at once:  


  # pacman -U /package/folder/*.tar.zst
  # pacman -U ''/package/folder/''*.tar.zst


=== Offline cache ===
=== Offline cache ===
Line 67: Line 68:
# generating the list of packages required from the offline computer to update it,  
# generating the list of packages required from the offline computer to update it,  
# downloading them with their signature on a computer with internet access,  
# downloading them with their signature on a computer with internet access,  
# transferring them to the pacman cache of the offline computer,  
# transferring them to the ''pacman'' cache of the offline computer,  
# installing the updates.
# installing the updates.


Line 74: Line 75:
The following script will download the updated package databases. If needed, change {{ic|MIRROR}} to any mirror from the [https://archlinux.org/mirrors/status/ mirror status list].
The following script will download the updated package databases. If needed, change {{ic|MIRROR}} to any mirror from the [https://archlinux.org/mirrors/status/ mirror status list].


{{hc|download_databases.sh|2=
{{hc|download_databases.sh|2=<nowiki>
#!/bin/sh
#!/bin/sh


Line 90: Line 91:
#wget "${MIRROR}/multilib-testing/os/${ARCH}/multilib-testing.db"
#wget "${MIRROR}/multilib-testing/os/${ARCH}/multilib-testing.db"


# and -additionaly- debug and staging packages.
# and -additionally- debug and staging packages.</nowiki>
}}
}}


Line 100: Line 101:
  # pacman -Sup --noconfirm > pkglist
  # pacman -Sup --noconfirm > pkglist


{{Note|Make sure that you have enabled at least one of the servers defined in the {{ic|/etc/pacman.d/mirrorlist}} file. Otherwise, all what you get is a misleading error message: {{ic|error: no database for package: package-name}}.}}
{{Note|Make sure that you have enabled at least one of the servers defined in the {{ic|/etc/pacman.d/mirrorlist}} file. Otherwise, all what you get is a misleading error message: {{ic|error: no database for package: ''package-name''}}.}}


You will also need to download the corresponding package signatures, so prepare the list of signatures to download:
You will also need to download the corresponding package signatures, so prepare the list of signatures to download:
Line 113: Line 114:
{{Tip|When using [https://www.cygwin.com cygwin] or some other kind of Windows environment to download the packages, the filenames will get mangled since default Windows file naming requires to escape e.g. colons. To avoid this (under cygwin, since it does not follow such restrictions), use {{ic|1=wget --restrict-file-names=unix}}.}}
{{Tip|When using [https://www.cygwin.com cygwin] or some other kind of Windows environment to download the packages, the filenames will get mangled since default Windows file naming requires to escape e.g. colons. To avoid this (under cygwin, since it does not follow such restrictions), use {{ic|1=wget --restrict-file-names=unix}}.}}


Take all the {{ic|*.pkg.tar.zst}} and {{ic|*.pkg.tar.zst.sig}} files back home, put them in {{ic|/var/cache/pacman/pkg}} and finally run
Take all the {{ic|*.pkg.tar.zst}} and {{ic|*.pkg.tar.zst.sig}} files back home, put them in {{ic|/var/cache/pacman/pkg}} and finally run:


  # pacman -Su
  # pacman -Su
Line 133: Line 134:
Comment out all other repositories and save. Continue configuring the new system as usual.
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 {{ic|/repo}} and running pacman commands 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 {{ic|/repo}} and running ''pacman'' commands as usual.


== See also ==
== See also ==


* [[Offline reading]]: for browsing ArchWiki offline.
* [[Help:Browsing#Offline viewing]]: for browsing ArchWiki offline.

Latest revision as of 10:28, 17 March 2024

This article provides instructions on installing Arch Linux on a system without an Internet connection. To do this, another system with a working Internet connection is required.

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

Warning: Extracting the root file system image (airootfs.sfs) from the ISO or copying the live environment's root file system is not a supported installation method.

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 mkinitcpio vim

Create your custom offline repository:

# repo-add ./custom.db.tar.gz ./*[^sig]

Mount and configure

This article or section needs expansion.

Reason: Add optional instructions on placing the custom repo in the ISO. (Discuss in Talk:Offline installation)

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

# mount --mkdir /dev/sdxy /mnt/repo

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

/etc/pacman.conf
[custom]
SigLevel = Optional
Server = file:///mnt/repo/

Comment out [core] and [extra] 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 -K /mnt base base-devel linux linux-firmware mkinitcpio vim

Offline installation of packages

Install from file

In case the offline installation process was only temporary, but requires manual installation of some packages before being able to access a network, see pacman#Additional commands to learn how to install local packages.

Shell globbing can be used to install many packages at once:

# pacman -U /package/folder/*.tar.zst

Offline cache

You can put the required files into /var/lib/pacman/sync and /var/cache/pacman/pkg, so as to make pacman think it has everything it needs to do searches, updates, and installs. The following method is based on two forum threads: [1][2].

The steps are:

  1. downloading the up to date package databases on a computer with internet access,
  2. transferring them to the offline computer,
  3. generating the list of packages required from the offline computer to update it,
  4. downloading them with their signature on a computer with internet access,
  5. transferring them to the pacman cache of the offline computer,
  6. installing the updates.
Tip: If you changed your default repositories from the defaults (core, extra and multilib), you should review your /etc/pacman.conf file.

The following script will download the updated package databases. If needed, change MIRROR to any mirror from the mirror status list.

download_databases.sh
#!/bin/sh

ARCH="x86_64"
MIRROR="https://mirrors.kernel.org/archlinux/"

wget "${MIRROR}/core/os/${ARCH}/core.db"
wget "${MIRROR}/extra/os/${ARCH}/extra.db"
wget "${MIRROR}/multilib/os/${ARCH}/multilib.db"

# and possibly -uncomment- (if customized in /etc/pacman.conf or pacman.conf.d):

#wget "${MIRROR}/core-testing/os/${ARCH}/core-testing.db"
#wget "${MIRROR}/extra-testing/os/${ARCH}/extra-testing.db"
#wget "${MIRROR}/multilib-testing/os/${ARCH}/multilib-testing.db"

# and -additionally- debug and staging packages.

Make the script executable and run it. You will obtain multiple .db files.

The following steps will be transferring the .db files to the offline PC, making it so you are working with up-to-date package lists (as if you ran pacman -Sy), then generating a list of package required for the update:

# cp *.db /var/lib/pacman/sync/
# pacman -Sup --noconfirm > pkglist
Note: Make sure that you have enabled at least one of the servers defined in the /etc/pacman.d/mirrorlist file. Otherwise, all what you get is a misleading error message: error: no database for package: package-name.

You will also need to download the corresponding package signatures, so prepare the list of signatures to download:

# sed -e 's/\.zst$/.zst.sig/' ../pkglist > ../siglist

Next, bring the two lists with you to a place where you have internet and download the listed packages in an empty directory:

# wget -nv -i ../pkglist
# wget -nv -i ../siglist
Tip: When using cygwin or some other kind of Windows environment to download the packages, the filenames will get mangled since default Windows file naming requires to escape e.g. colons. To avoid this (under cygwin, since it does not follow such restrictions), use wget --restrict-file-names=unix.

Take all the *.pkg.tar.zst and *.pkg.tar.zst.sig files back home, put them in /var/cache/pacman/pkg and finally run:

# pacman -Su

Local repository

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

Complete repository

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

/etc/pacman.conf
[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.

See also