LinuxCommandLibrary

arch-chroot

Enter a chroot environment for package management

TLDR

Start an interactive shell (Bash, by default) in a new root directory

$ arch-chroot [path/to/new_root]
copy

Specify the user (other than the current user) to run the shell as
$ arch-chroot -u [user] [path/to/new_root]
copy

Run a custom command (instead of the default Bash) in the new root directory
$ arch-chroot [path/to/new_root] [command] [command_arguments]
copy

Specify the shell, other than the default Bash (in this case, the zsh package should have been installed in the target system)
$ arch-chroot [path/to/new_root] [zsh]
copy

SYNOPSIS

arch-chroot [-h | --help] [--arch ARCH] [-r | --rlimit-nofile] <ROOT> [COMMAND [<ARGs...]]

PARAMETERS

-h, --help
    Display usage help message and exit.

--arch <ARCH>
    Set target architecture (x86_64, i686, aarch64, armv7h, riscv64).
Enables cross-chroot by adjusting personality, uname, and mounts.

-r, --rlimit-nofile
    Raise rlimit NOFILE to 524288 (requires systemd on host).

<ROOT>
    Required path to the mounted target root filesystem.

[COMMAND [<ARG>s...]]
    Optional command and arguments to run in chroot.
Defaults to /bin/bash.

DESCRIPTION

arch-chroot is a helper script from the arch-install-scripts package, designed to simplify chrooting into an Arch Linux root filesystem. It automatically performs bind mounts of essential host directories—including /dev, /proc, /sys, /run, /tmp, and /var/tmp—into the target environment, ensuring a functional chroot without manual setup. This is crucial during Arch Linux installation after mounting partitions with pacstrap.

Invoked as root, it changes the root directory and executes a command (defaulting to /bin/bash). The --arch option enables cross-architecture support by setting the appropriate uname(2) personality and mounting architecture-specific files. It also supports raising file descriptor limits for demanding operations.

Upon exit, all mounts are cleanly unmounted, preventing host contamination. Ideal for configuring fstab, installing bootloaders, setting locales, and network setup in the new system.

CAVEATS

Requires root privileges.
<ROOT> must be fully mounted (e.g., via pacstrap).
EFI/boot partitions not auto-mounted—handle manually.
Host architecture mismatch needs --arch.
Mounts auto-cleaned on exit; nested chroots unsupported.

TYPICAL INSTALL WORKFLOW

1. Partition/format disks.
2. mount <root-part> /mnt
3. pacstrap /mnt base linux linux-firmware
4. genfstab -U /mnt >> /mnt/etc/fstab
5. arch-chroot /mnt (then configure inside).

CROSS-ARCH EXAMPLE

arch-chroot --arch aarch64 /mnt-arm/
Boots x86_64 host into ARM chroot for emulation/QEMU setups.

HISTORY

Part of arch-install-scripts since ~2012 for Arch Linux install media.
Initially x86-focused; added multi-arch support (aarch64, ARM, RISC-V) in 2010s updates to match Arch ports. Evolved with systemd integration for rlimits.

SEE ALSO

Copied to clipboard