Alpine Linux:Overview: Difference between revisions
(22 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
Alpine uses [ | Alpine Linux is an independent, non-commercial, general purpose Linux distribution designed for power users who appreciate security, simplicity and resource efficiency. Alpine uses [https://musl.libc.org/ musl] as its libc, and [[BusyBox]] as core utilities. These choices tend to make Alpine especially minimalist and secure. | ||
== | == General overview == | ||
Alpine | Alpine Linux has '''[https://everybytecounts.org/ one of the fastest boot times]''' of any operating system. | ||
It's famous because of its small size and it's '''[https://www.infoworld.com/article/2254081/review-alpine-linux-is-made-for-docker.html heavily used in containers''']. | |||
It's also well known for '''wide use in embedded devices''' and as a '''base system for many enterprise routers'''. | |||
The [https://postmarketos.org/ postmarketOS] project, which is designed to run on mobile devices and other consumer electronics, is based on Alpine Linux. | |||
=== Distinctive === | |||
Alpine Linux follows the principles of '''the SSS distro: [https://alpinelinux.org/about/ Small+Simple+Secure]''': due to usage of [https://musl.libc.org/ muslc] as the minimalist libc, BusyBox simple coreutils (with possibilities to alternate on inflated original packages of each coreutils tools also) and userland binaries compiled as [https://en.wikipedia.org/wiki/Position-independent_code Position Independent Executables (PIE)] with stack smashing protection. | |||
=== Efficient === | |||
# Usage of [ | Some main reasons: | ||
# Its own package manager called | |||
# | # Usage of [[Musl]] as the minimalist libc | ||
# | # Its own package manager called [[Alpine Package Keeper|apk]] | ||
# The [[Openrc]] init system, script driven set-ups and that’s it! | |||
# [[BusyBox]]: simple coreutils (with possibilities to [[How_to_get_regular_stuff_working|alternate on inflated original]] packages) | |||
This provides you with a simple, '''crystal-clear Linux environment without all the noise''', nothing else will get in the way. | This provides you with a simple, '''crystal-clear Linux environment without all the noise''', nothing else will get in the way. | ||
=== | === Secure === | ||
All userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection. | All userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection. | ||
Line 30: | Line 32: | ||
== Technical overview == | == Technical overview == | ||
< | === Architectures === | ||
</ | |||
Alpine uses '''Linux''' as [https://www.kernel.org/ OS kernel], and has a focus on '''SSS distribution, Small Simple and Secure'''. | |||
The table below represents architectures supported by Alpine Linux: | |||
{{:Include:Architecture support matrix}} | |||
=== Installation === | |||
<p>Alpine can be installed to a hard disk/SSD/other storage medium like any other distro (this is called '''sys mode'''). The storage medium in question can be any block device (USB, Flash, SDD, HDD). It can be removable, so long as you can configure your machine to boot from it. But if you're working with removable media, you might prefer one of the other installation modes.</p> | |||
<p>In each of these modes, you boot your machine from a static image. You will also need a writable medium to save updates to the system. In '''[[Diskless Mode|Diskless]]''' mode, that medium is usually a small USB key (or a partition on one) that holds the changes you want to persist. Both the base Alpine system and all your changes will be unpacked into a memory-based filesystem.</p> | |||
<p> | <p>The other, '''[[Data Disk Mode|data disk]]''' mode is for when you're dealing with a large amount of persisting data, that you want to keep on a hard disk/SSD/other storage medium, rather than unpacking into memory. The default setup here is to store your {{Path|/var}} partition directly on the hard storage medium. But as in the '''diskless''' mode, your root system still comes from a static ISO image.</p> | ||
<p> | <p>These second and third installation modes are sometimes referred to, collectively, as "run-from-RAM" installations.</p> | ||
<p> | <p>Key to these installation modes is Alpine's [[Alpine local backup|lbu]] utility. This tracks which files you've modified from their static ISO version, and want the changes to persist. The lbu utility saves those changes in {{Path|.apkovl}} "overlay" files. (These are essentially tar-gzip archives, though they can also be encrypted. You can use the lbu utility with the '''sys''' mode, too, if you like: as a form of backup, or to configure overlay files for other systems. But for a robust incremental backup system, you'll probably want a more specialized tool, such as {{Pkg|rsnapshot}}.)</p> | ||
</p> | |||
< | <p>The lbu utility is part of the {{Pkg|alpine-conf}} package, which is required by {{Pkg|alpine-base}}.</p> | ||
<p> | <p>'''Alpine's installer''' consists of '''the {{Path|/sbin/setup-*}} scripts''', which are also part of the {{Pkg|alpine-conf}} package. | ||
</p><p>'''A base Alpine install will include only needed packages''' such like {{Pkg|alpine-base}}, {{Pkg|syslinux}}, {{Pkg|linux- | </p><p>'''A base Alpine install will include only needed packages''' such like {{Pkg|alpine-base}}, {{Pkg|syslinux}}, {{Pkg|linux-lts}} (or another kernel package), and depending on your purposes packages like {{Pkg|openssh}} and/or {{Pkg|chrony}}. | ||
</p><p>Alpine's boot loader case | </p><p>Alpine's boot loader in that case is {{Pkg|syslinux}}, or its companions <code>isolinux</code> or <code>extlinux</code>. The latest releases also have Grub and [[Alpine and UEFI|UEFI support]].</p> | ||
=== The init system === | |||
<p>An "init system" includes several different components. First, there is the initramfs loaded by the bootloader. Alpine's tool for generating | <p>An "init system" includes several different components. First, there is the initramfs, which is loaded by the bootloader. Alpine's tool for generating the initramfs is {{Path|/sbin/mkinitfs}}, part of the {{Pkg|mkinitfs}} package, which is required by Alpine's kernel packages and by its {{Pkg|syslinux}} package. This tool's settings are read from {{Path|/etc/mkinitfs/*}}, and it installs the initscript {{Path|/usr/share/mkinitfs/initramfs-init}} into the initramfs. | ||
</p><p>Second, Alpine uses [[Alpine Linux Init System|OpenRC]] to handle the rest of its initscripts. The base framework of this is in the {{Pkg|openrc}} package, which is required by {{Pkg|alpine-conf}}. | </p><p>Second, Alpine uses [[Alpine Linux Init System|OpenRC]] to handle the rest of its initscripts. The base framework of this is in the {{Pkg|openrc}} package, which is required by {{Pkg|alpine-conf}}. | ||
</p> | </p> | ||
=== The packaging and development system === | |||
The last important distinguishing feature of a Linux distro is its packaging and development systems. | |||
</p><p>In Alpine's case, these are something a hybrid between [https://www.archlinux.org/ ArchLinux]'s, on the one hand, and [ | </p><p>In Alpine's case, these are something a hybrid between [https://www.archlinux.org/ ArchLinux]'s, on the one hand, and [https://www.gentoo.org/ Gentoo] and [https://www.freebsd.org/ FreeBSD]'s, on the other. Our package-management and build utilities work much like Arch's: | ||
* {{Pkg|mkinitfs}}, mentioned above, rebuilds Alpine's initramfs, like Arch's "mkinitcpio" | * {{Pkg|mkinitfs}}, mentioned above, rebuilds Alpine's initramfs, like Arch's "mkinitcpio" | ||
Line 74: | Line 76: | ||
* Alpine's package-building scripts are named APKBUILD, like Arch's "PKGBUILD" | * Alpine's package-building scripts are named APKBUILD, like Arch's "PKGBUILD" | ||
</p><p>What Alpine borrows from Gentoo and FreeBSD is a tree of all the package-building scripts. | </p><p>What Alpine borrows from Gentoo and FreeBSD is a tree of all the package-building scripts. It is called the [[Aports tree]], and is kept as a single git repository. (Compare Gentoo's "Portage" and FreeBSD's "ports". Something similar can be set up with Arch's "abs", but it's not as tightly integrated with their package manager and build utilities.) | ||
</p><p>If you're only planning to install packages on a given system, and not do any development there, then the only pieces of this you'll need are {{Pkg|mkinitfs}} and {{Pkg|apk-tools}}, both included in a base Alpine install. If you do plan to do development, install {{Pkg|alpine-sdk}}, which includes gcc, git, abuild, and the like, and see [[Developer Documentation]]. | </p><p>If you're only planning to install packages on a given system, and not do any development there, then the only pieces of this you'll need are {{Pkg|mkinitfs}} and {{Pkg|apk-tools}}, both included in a base Alpine install. If you do plan to do development, install {{Pkg|alpine-sdk}}, which includes gcc, git, abuild, and the like, and see [[Developer Documentation]]. | ||
</p> | </p> | ||
== See also == | |||
* [[Comparison with other distros]] | |||
* [[Tutorials and Howtos]] | |||
[[Category:Installation]] | |||
Latest revision as of 21:35, 20 July 2025
Alpine Linux is an independent, non-commercial, general purpose Linux distribution designed for power users who appreciate security, simplicity and resource efficiency. Alpine uses musl as its libc, and BusyBox as core utilities. These choices tend to make Alpine especially minimalist and secure.
General overview
Alpine Linux has one of the fastest boot times of any operating system.
It's famous because of its small size and it's heavily used in containers.
It's also well known for wide use in embedded devices and as a base system for many enterprise routers.
The postmarketOS project, which is designed to run on mobile devices and other consumer electronics, is based on Alpine Linux.
Distinctive
Alpine Linux follows the principles of the SSS distro: Small+Simple+Secure: due to usage of muslc as the minimalist libc, BusyBox simple coreutils (with possibilities to alternate on inflated original packages of each coreutils tools also) and userland binaries compiled as Position Independent Executables (PIE) with stack smashing protection.
Efficient
Some main reasons:
- Usage of Musl as the minimalist libc
- Its own package manager called apk
- The Openrc init system, script driven set-ups and that’s it!
- BusyBox: simple coreutils (with possibilities to alternate on inflated original packages)
This provides you with a simple, crystal-clear Linux environment without all the noise, nothing else will get in the way.
Secure
All userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection.
Technical overview
Architectures
Alpine uses Linux as OS kernel, and has a focus on SSS distribution, Small Simple and Secure. The table below represents architectures supported by Alpine Linux:
Alpine Linux Hardware Support Matrix | |||
Architecture | Port | Description | Since |
---|---|---|---|
x86 | x86 | 32 bit i686 compatible (or later) CPUs with at least CMOV and SSE2 | All |
x86_64 | AMD64 compatible 64-bit x86 instruction set | All | |
ARM | armhf | 32 bit ARM with hard-float ABI - for ARMv6 devices- Raspberry Pi 1, Zero, ZeroW, cm1 (defconfig bcmrpi) | v3.0 |
armv7 | 32 bit ARM - for ARMv7 devices - Raspberry Pi 2, 3, 3+, Zero2W, cm3, cm3+ (defconfig bcm2709) | v3.9 | |
aarch64 | 64 bit ARM - for ARMv8+ devices - Raspberry Pi 3, 3+, 4, 400, Zero2W, cm3, cm3+, cm4, 5, 500, cm5 (defconfig bcm2711) | v3.5 | |
PowerPC | ppc64le | 64 bit PowerPC (little-endian) mostly for POWER8 and POWER9 | v3.6 |
IBM System Z | s390x | IBM Z mainframes, especially IBM Z and IBM LinuxONE (z196 minimum) | v3.6 |
RISC V | riscv64 | 64 bit RISC V | v3.20 |
LoongArch | loongarch64 | 64 bit LoongArch | v3.21 |
Installation
Alpine can be installed to a hard disk/SSD/other storage medium like any other distro (this is called sys mode). The storage medium in question can be any block device (USB, Flash, SDD, HDD). It can be removable, so long as you can configure your machine to boot from it. But if you're working with removable media, you might prefer one of the other installation modes.
In each of these modes, you boot your machine from a static image. You will also need a writable medium to save updates to the system. In Diskless mode, that medium is usually a small USB key (or a partition on one) that holds the changes you want to persist. Both the base Alpine system and all your changes will be unpacked into a memory-based filesystem.
The other, data disk mode is for when you're dealing with a large amount of persisting data, that you want to keep on a hard disk/SSD/other storage medium, rather than unpacking into memory. The default setup here is to store your /var partition directly on the hard storage medium. But as in the diskless mode, your root system still comes from a static ISO image.
These second and third installation modes are sometimes referred to, collectively, as "run-from-RAM" installations.
Key to these installation modes is Alpine's lbu utility. This tracks which files you've modified from their static ISO version, and want the changes to persist. The lbu utility saves those changes in .apkovl "overlay" files. (These are essentially tar-gzip archives, though they can also be encrypted. You can use the lbu utility with the sys mode, too, if you like: as a form of backup, or to configure overlay files for other systems. But for a robust incremental backup system, you'll probably want a more specialized tool, such as rsnapshot.)
The lbu utility is part of the alpine-conf package, which is required by alpine-base.
Alpine's installer consists of the /sbin/setup-* scripts, which are also part of the alpine-conf package.
A base Alpine install will include only needed packages such like alpine-base, syslinux, linux-lts (or another kernel package), and depending on your purposes packages like openssh and/or chrony.
Alpine's boot loader in that case is syslinux, or its companions isolinux
or extlinux
. The latest releases also have Grub and UEFI support.
The init system
An "init system" includes several different components. First, there is the initramfs, which is loaded by the bootloader. Alpine's tool for generating the initramfs is /sbin/mkinitfs, part of the mkinitfs package, which is required by Alpine's kernel packages and by its syslinux package. This tool's settings are read from /etc/mkinitfs/*, and it installs the initscript /usr/share/mkinitfs/initramfs-init into the initramfs.
Second, Alpine uses OpenRC to handle the rest of its initscripts. The base framework of this is in the openrc package, which is required by alpine-conf.
The packaging and development system
The last important distinguishing feature of a Linux distro is its packaging and development systems.
In Alpine's case, these are something a hybrid between ArchLinux's, on the one hand, and Gentoo and FreeBSD's, on the other. Our package-management and build utilities work much like Arch's:
- mkinitfs, mentioned above, rebuilds Alpine's initramfs, like Arch's "mkinitcpio"
- apk from apk-tools is Alpine's package manager, like Arch's "pacman"; see Alpine Linux package management
- abuild is Alpine's build utility, like Arch's "makepkg"; see Abuild and Helpers
- Alpine's package-building scripts are named APKBUILD, like Arch's "PKGBUILD"
What Alpine borrows from Gentoo and FreeBSD is a tree of all the package-building scripts. It is called the Aports tree, and is kept as a single git repository. (Compare Gentoo's "Portage" and FreeBSD's "ports". Something similar can be set up with Arch's "abs", but it's not as tightly integrated with their package manager and build utilities.)
If you're only planning to install packages on a given system, and not do any development there, then the only pieces of this you'll need are mkinitfs and apk-tools, both included in a base Alpine install. If you do plan to do development, install alpine-sdk, which includes gcc, git, abuild, and the like, and see Developer Documentation.