Difference between revisions of "Alpine Linux:Overview"

From Alpine Linux
Jump to: navigation, search
(add note about "run-from-RAM")
(wording for clarity)
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
When I discovered Alpine, I had a hard time figuring out what did what. Part of the trouble is that, as the [http://alpinelinux.org/about About] page says:
+
Alpine uses [http://musl-libc.org/ muslc] as libc, and [https://en.wikipedia.org/wiki/BusyBox BusyBox] as core utilities. These choices tend to make Alpine especially minimalist and secure.
  
<blockquote>
+
== General overview ==
* In some cases, there is not a lot of documentation available, and what is available can be scattered about the wiki and/or mailing lists. We're working on it, but could use some help. Please see the [[Contribute]] page if you would like to help out.
 
</blockquote>
 
  
Another part of the trouble is that up-to-date information in the wiki was mixed together with information that only concerned older versions of Alpine (and sometimes it wasn't clear when that was true). I've tried to clean up such things when I've encountered them.
+
Alpine Linux has one of the '''fastest boot times''' of any operating system.
  
A third part of the trouble is that there's too little by way of a global overview of the distro, or its development tools. This page is aimed at remedying that.
+
Famous because of its small size, it's '''heavily used in containers'''.
  
== Overview ==
+
Also well know for '''wide use in embedded devices''' and as a '''base system for many enterprise routers'''.
  
There are four areas that distinguish Linux distros from each other.
+
The postmarketOS project which is designed to run on mobile devices is based on Alpine Linux.
  
<ol>
+
=== Distinctive ===
<li>The initial design choices
+
 
 +
Alpine Linux follows the principles of '''the SSS distro: Simple+Small+Secure''': due to usage of [http://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 Position Independent Executables (PIE) with stack smashing protection.
 +
 
 +
=== Efficient ===
 +
 
 +
Some main reasons:
  
<p>What makes Alpine distinctive is summarized on the [http://alpinelinux.org/about About] page. This includes applying the [https://en.wikipedia.org/wiki/Grsecurity grsec]/PaX patches to the kernel (though you can also compile and use a custom kernel, configured as you like). It also includes the choice of [https://en.wikipedia.org/wiki/UClibc uClibc], and [https://en.wikipedia.org/wiki/BusyBox BusyBox] for the core utilities. These choices tend to make Alpine especially minimalist and secure: as the About page says, it's "designed for x86 Routers, Firewalls, VPNs, VoIP and servers." (Alpine is a perfectly workable desktop system, too. The shortcomings just have to do with the small community, and that sometimes you may need to get your hands dirty modifying scripts written with more mainstream desktop distros in mind. So you probably won't want to use Alpine if you're a newcomer to Linux. If you're already comfortable with another distro, though, especially a power-user, less-hand-holding distro like [https://www.archlinux.org/ ArchLinux] or [http://www.gentoo.org/ Gentoo], you should do fine.)
+
# Usage of [http://musl-libc.org/ muslc] as the minimalist libc
 +
# Its own package manager called {{Pkg|apk}},  
 +
# the {{Pkg|openrc}} init system, script driven set-ups and that’s it!
 +
# {{Pkg|busybox}} simple coreutils (with possibilities to alternate on inflated original packages of each coreutils tools also)
  
</p><p>Another distinctive part of Alpine is its variety of "installation modes." It can be installed to a hard disk/SSD/other storage medium like any other distro; this is called the '''sys''' mode. The storage medium in question can be removable, if you like, so long as you can configure your machine to boot from it. However, if you're working with removable media, there are two other installation modes you might consider. In each of these modes, you will boot your machine from a static ISO image (either a CD or a USB partition configured like the CD). You will also need a writable medium to save updates to the system. In the '''diskless''' mode, this writable medium is typically a small USB key (or a second USB partition) 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''' mode is for cases where 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.
+
This provides you with a simple, '''crystal-clear Linux environment without all the noise''', nothing else will get in the way.
  
</p><p>The second and third modes are sometimes referred to, collectively, as "run-from-RAM" installations.
+
=== Secure ===
  
</p><p>Key to the second and third 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).
+
All userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection.
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 [http://www.rsnapshot.org/ rsnapshot], which is a perl wrapper around {{Pkg|rsync}}.)
 
  
</p><p>The lbu utility is part of the {{Pkg|alpine-conf}} package, which is required by {{Pkg|alpine-base}}.
+
== Technical overview ==
  
</p><p>Another distinctive part of a Linux distro is its default bootloader. In Alpine's case this is {{Pkg|syslinux}}, or its companions <code>isolinux</code> or <code>extlinux</code>.
+
<ol>
</p>
+
</li><li>'''The OS design'''
  
</li><li>The installer scripts
+
<p>Alpine uses '''Linux''' as OS kernel, and their focus are '''SSS distribution, Simple Small and Secure'''</p>
  
<p>In Alpine's case, the installer consists of the {{Path|/sbin/setup-*}} scripts, which are also part of the {{Pkg|alpine-conf}} package.
+
<p>A variety of architectures are officially supports:
 +
* '''x86_64''': The popular AMD64 compatible 64-bit x86 based machines, i386 are not recommended for newer/lasted hardware.
 +
* '''x86''': (i386 pc 32bit) and x86_64 (i686 pc 64bit and amd64)
 +
* '''armhf''': The newer ARM hard-float for newer, more powerful 32-bit devices alongside 64-bit
 +
* '''armv7''': The 32-bit ARM only execution state of the ARMv7 devices machines.
 +
* '''aarch64''': The 64-bit ARM only execution state of the ARMv8 device machines.
 +
* '''ppc64le''': For 64-bit PowerPC devices with pure little-endian mode, mostly for POWER8 and POWER9.
 +
* '''s390x''': For IBM Z mainframes, especially IBM Z and IBM LinuxONE.
 +
* '''mips64''': The MIPS 64-bit ISA.
  
</p><p>A base Alpine install will include only these packages and their dependencies:
+
<p>It [[Alpine newbie install manual|can be installed]] to a hard disk/SSD/other storage medium like any other distro; (sys mode). The storage medium in question can be any block device (USB, Flash, SDD, HDD). Always in start, the base Alpine system and all your changes will be unpacked into a memory-based filesystem. If run some install script process (data mode) will keep your setup 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.
 +
</p>
  
* {{Pkg|alpine-base}}
+
</li><li>'''The installation'''
* {{Pkg|syslinux}}
 
* {{Pkg|linux-grsec}} or another kernel package
 
  
</p><p>Depending on your installation choices, you may also have:
+
<p>In Alpine's case, '''the installer consists of the {{Path|/sbin/setup-*}} scripts''', which are also part of the {{Pkg|alpine-conf}} package.
  
* {{Pkg|openssh}}
+
</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 of purpose some like {{Pkg|openssh}}/{{Pkg|chrony}}.
* {{Pkg|chrony}}
 
  
</p><p>or other such packages. <!-- e2fsprogs? --> Everything else is up to you to install.
+
</p><p>Alpine's boot loader case this is {{Pkg|syslinux}}, or its companions <code>isolinux</code> or <code>extlinux</code>. Lasted releases has Grub and [[Alpine and UEFI|UEFI support]].</p>
</p>
 
  
</li><li>The init system
+
</li><li>'''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 these 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>An "init system" includes several different components. First, there is the initramfs loaded by the bootloader. Alpine's tool for generating these 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.
Line 55: Line 65:
 
</p>
 
</p>
  
</li><li>The packaging and development systems
+
</li><li>'''The packaging and development system'''
  
 
<p>The last important distinguishing feature of a Linux distro is its packaging and development systems.
 
<p>The last important distinguishing feature of a Linux distro is its packaging and development systems.
Line 72: Line 82:
  
 
</li></ol>
 
</li></ol>
 +
 +
= See Also =
 +
 +
* [[Comparison with other distros]]
 +
* [[Alpine newbie|Alpine for new users (how to start)]]

Latest revision as of 03:55, 4 May 2021

Alpine uses muslc as 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.

Famous because of its small size, it's heavily used in containers.

Also well know 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 is based on Alpine Linux.

Distinctive

Alpine Linux follows the principles of the SSS distro: Simple+Small+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:

  1. Usage of muslc as the minimalist libc
  2. Its own package manager called apk,
  3. the openrc init system, script driven set-ups and that’s it!
  4. busybox simple coreutils (with possibilities to alternate on inflated original packages of each coreutils tools also)

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

  1. The OS design

    Alpine uses Linux as OS kernel, and their focus are SSS distribution, Simple Small and Secure

    A variety of architectures are officially supports:

    • x86_64: The popular AMD64 compatible 64-bit x86 based machines, i386 are not recommended for newer/lasted hardware.
    • x86: (i386 pc 32bit) and x86_64 (i686 pc 64bit and amd64)
    • armhf: The newer ARM hard-float for newer, more powerful 32-bit devices alongside 64-bit
    • armv7: The 32-bit ARM only execution state of the ARMv7 devices machines.
    • aarch64: The 64-bit ARM only execution state of the ARMv8 device machines.
    • ppc64le: For 64-bit PowerPC devices with pure little-endian mode, mostly for POWER8 and POWER9.
    • s390x: For IBM Z mainframes, especially IBM Z and IBM LinuxONE.
    • mips64: The MIPS 64-bit ISA.

    It can be installed to a hard disk/SSD/other storage medium like any other distro; (sys mode). The storage medium in question can be any block device (USB, Flash, SDD, HDD). Always in start, the base Alpine system and all your changes will be unpacked into a memory-based filesystem. If run some install script process (data mode) will keep your setup 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.

  2. The installation

    In Alpine's case, the 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 of purpose some like openssh/chrony.

    Alpine's boot loader case this is syslinux, or its companions isolinux or extlinux. Lasted releases has Grub and UEFI support.

  3. The init system

    An "init system" includes several different components. First, there is the initramfs loaded by the bootloader. Alpine's tool for generating these 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.

  4. 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:

    What Alpine borrows from Gentoo and FreeBSD is a tree of all the package-building scripts. We call this our Aports tree, and we keep it as a git repository. (Compare Gentoo's "Portage" and FreeBSD's "ports". You can setup something similar 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.

See Also