LinuxCommandLibrary

archdetect

Detect machine's architecture

SYNOPSIS

archdetect

DESCRIPTION

archdetect is a lightweight shell script utility integral to the Debian installer (debian-installer). It automatically detects the system's CPU architecture by parsing /proc/cpuinfo, CPUID instructions (where available), and other hardware probes. The output determines the Debian package architecture (e.g., i386, amd64, arm64, mips64el) and OS family, enabling correct kernel loading, package selection, and bootloader configuration during installation.

Execution yields two lines: the first is the concise Debian arch identifier used for dpkg and APT (e.g., amd64), the second the OS type (e.g., Linux, GNU, or kFreeBSD). This mapping relies on heuristics matching CPU vendor (Intel, AMD, ARM), family, model, and feature flags to Debian's supported arches, covering x86 variants, PowerPC, SPARC, MIPS, ARM, and others.

Though installer-specific, it runs on standard Debian systems but assumes a complete /proc and may misdetect in containers, VMs, or partial chroots lacking full CPU info. It's non-interactive, fast, and architecture-portable within supported platforms, aiding automated installs and rescue modes.

CAVEATS

Installer-focused; unreliable outside full Debian env (e.g., containers, minimal chroots). No subarch details (e.g., distinguishes i686 but maps to i386). Static heuristics may lag new CPUs.

OUTPUT EXAMPLE

On x86-64:
amd64
Linux

On 32-bit x86:
i386
Linux

LOCATION

Installed as /usr/lib/debian-installer/archdetect; sourced from busybox/ash in installer ramdisk.

HISTORY

Originated in Debian Installer (d-i) for Debian 3.0 Woody (2002), initially x86-focused. Expanded in sarge/etch for multiarch (PowerPC, Sparc), lenny for ARM/MIPS, and modern releases for arm64/RISC-V. Maintained in debian-installer package source at salsa.debian.org/installer-team.

SEE ALSO

uname(1), lscpu(1), dpkg-architecture(1), getconf(3)

Copied to clipboard