LinuxCommandLibrary

pacstrap

Install base Arch Linux packages to a directory

TLDR

Install the base package, the Linux kernel and firmware for common hardware

$ pacstrap [path/to/new/root] [base] [linux] [linux-firmware]
copy

Install the base package, the Linux LTS kernel and base-devel build tools
$ pacstrap [path/to/new/root] [base] [base-devel] [linux-lts]
copy

Install packages and copy the host's Pacman config to the target
$ pacstrap -P [path/to/new/root] [packages]
copy

Install packages without copying the host's mirrorlist to the target
$ pacstrap -M [path/to/new/root] [packages]
copy

Use an alternate configuration file for Pacman
$ pacstrap -C [path/to/pacman.conf] [path/to/new/root] [packages]
copy

Install packages using the package cache on the host instead of on the target
$ pacstrap -c [path/to/new/root] [packages]
copy

Initialize an empty pacman keyring in the target without copying it from the host
$ pacstrap -K [path/to/new/root] [packages]
copy

Install packages in interactive mode (prompts for confirmation)
$ pacstrap -i [path/to/new/root] [packages]
copy

SYNOPSIS

pacstrap [options] <mountpoint> [packages...]

PARAMETERS

-c, --config
    Specify an alternate pacman configuration file.

-C, --cachedir


    Specify an alternate package cache directory.

-d, --nodeps
    Skip dependency checks.

-G, --gpgdir
    Specify an alternate GPG directory.

-i, --ignore
    Ignore a package upgrade.

-M, --move-to-cache
    Move downloaded packages to the cache directory instead of copying.

-n, --noconfirm
    Apply answers automatically; do not ask for confirmation.

-p, --pacman
    Specify an alternate pacman command.

-r, --root
    Specify an alternate installation root.

-y, --sysroot
    Use the directory specified as the root for all file system operations.

-k, --keyring
    Specify an alternate keyring.


    The target directory (mountpoint) where the packages will be installed.

[packages...]
    A space-separated list of packages to install. If omitted, the 'base' package group will be installed.

DESCRIPTION

The pacstrap script is a crucial component of the Arch Linux installation process. It's designed to quickly and easily bootstrap a new Arch Linux environment by downloading and installing packages directly onto a target directory, typically a newly formatted partition. It uses pacman, the Arch Linux package manager, to install base packages and any other specified packages. This provides the core utilities and configurations necessary for a functioning Arch Linux system.

pacstrap is particularly useful for performing fresh installations, creating chroot environments, or setting up virtual machines. It simplifies the process by handling the package downloading and installation automatically. The script handles dependency resolution, minimizing manual intervention during the critical initial setup phase.

By default, pacstrap downloads and installs the base package group. Further packages can be added as additional arguments in the command.

CAVEATS

The target directory (mountpoint) must be properly prepared (e.g., formatted and mounted) before running pacstrap. Ensure that the mirrorlist in the target's /etc/pacman.d/mirrorlist is configured or pacstrap will download packages from the default mirrors, which might be slow or unreliable.

Also, ensure that you have sufficient disk space in the target partition before starting the installation.

EXAMPLE USAGE

pacstrap /mnt base base-devel vim will install the base package group, the base-devel group and vim into the /mnt directory.
pacstrap -i /mnt firefox will install firefox interactively to /mnt.

POST INSTALLATION

After running pacstrap, you still need to configure the system. That involves setting up the bootloader (like GRUB or systemd-boot), configuring the file systems table (fstab), creating a user, setting the hostname, and configuring the network. Consult the Arch Linux Wiki for comprehensive post-installation guides.

HISTORY

pacstrap was developed as part of the Arch Linux project to streamline the installation process. It provides a convenient way to populate a new system root with essential packages. Prior to pacstrap, users often had to manually download and install packages, which was a more complex and error-prone process. It has undergone several revisions, improvements, and updates to optimize performance, add new features, and address bug fixes. The main goal remained the same, simplify the bootstrapping of a new Arch Linux installation.

SEE ALSO

Copied to clipboard