Base Filesystem Layout
Alpine Linux's Base Filesystem Layout organizes core system files for minimal footprint and efficient operation in containers and embedded systems.
Base Filesystem Layout defines the standardized organization and hierarchy of directories and files that form the fundamental structure of an Alpine Linux installation. It provides a minimal and efficient arrangement designed to support system booting, administration, and runtime operations while maintaining simplicity and security consistent with Alpine Linux's lightweight philosophy.
The base filesystem layout includes essential directories, each serving specific purposes related to system configuration, user data, device files, temporary storage, and executable binaries. This layout adheres to the Filesystem Hierarchy Standard (FHS) where applicable but is tailored to Alpine's musl libc and busybox environment to minimize footprint and maximize performance.
Core Directories and Their Roles
-
/ (Root directory)
The top-level directory that contains all other files and directories. It is the starting point of the filesystem hierarchy. -
/bin
Contains essential user command binaries needed during boot and for single-user mode, such assh,ls,cp, and other fundamental utilities. In Alpine, these are typically symlinked or provided by busybox for minimal size. -
/sbin
Holds essential system binaries used primarily by the system administrator for maintenance and system repair tasks, for example,fsckandifconfig. -
/etc
Contains system-wide configuration files. This directory is critical for system initialization and service configuration. Alpine stores network setup, package manager configuration, and system initialization scripts here. -
/lib
Contains essential shared libraries required by binaries in/binand/sbin. Because Alpine uses musl libc instead of glibc, this directory contains musl libraries and kernel modules. -
/libexec
Used for internal binaries and helper executables that are not intended to be executed directly by users or administrators. -
/usr
Contains read-only user utilities and applications. It is further subdivided into:/usr/binfor non-essential user commands./usr/sbinfor non-essential system binaries./usr/libfor libraries supporting/usr/binand/usr/sbin./usr/sharefor architecture-independent data like documentation and icons.
-
/var
Contains variable data files such as logs, spool files, caches, and transient runtime data. Examples include/var/log,/var/run, and/var/cache. -
/tmp
A directory for temporary files that can be deleted upon reboot. It is typically mounted as a tmpfs (in-memory filesystem) for performance and security. -
/root
The home directory for the root user, separate from normal users’ home directories in/home. -
/home
Contains user home directories for non-root users. -
/dev
Contains device files representing hardware and virtual devices. Alpine often uses devtmpfs to dynamically manage this directory. -
/proc
A virtual filesystem that exposes kernel and process information, used for monitoring and interacting with running processes and kernel parameters. -
/sys
Another virtual filesystem exposing kernel information, hardware devices, and drivers, providing interfaces to kernel subsystems. -
/mnt and /media
Standard mount points for temporarily mounting filesystems and removable media, respectively.
Special Considerations in Alpine Linux
- Alpine emphasizes a minimal base system, so many directories may initially be empty or contain only essential files.
- BusyBox provides many standard Unix utilities in a single binary, reducing the number of files under
/binand/sbin. - Musl libc replaces glibc, so
/libcontains musl-specific libraries, often with a smaller footprint. - Configuration management and package handling are simplified;
/etccontains Alpine-specific files such as/etc/apk/repositoriesfor package sources. - Alpine uses OpenRC for initialization, so relevant scripts and service files are located under
/etc/init.dand/etc/conf.d.
Directory Summary Table
| Directory | Purpose | Notes |
|---|---|---|
/ | Root of the filesystem | Contains all other directories |
/bin | Essential user commands | BusyBox utilities often reside here |
/sbin | Essential system binaries for admin | System repair and boot utilities |
/etc | Host-specific configuration files | Alpine-specific configs included |
/lib | Shared libraries and kernel modules | Contains musl libc libraries |
/libexec | Internal helper binaries | Not intended for user execution |
/usr | Secondary hierarchy for user programs and data | Read-only, large software stored |
/var | Variable data files like logs, spools, caches | Persistent runtime data |
/tmp | Temporary files | Typically tmpfs mounted |
/root | Root user’s home directory | Separate from regular users |
/home | User home directories | User data and personal files |
/dev | Device nodes | Managed dynamically by devtmpfs |
/proc | Kernel and process information | Virtual filesystem |
/sys | Kernel subsystem interface | Virtual filesystem |
/mnt | Mount point for temporary mounts | For manual mounting |
/media | Mount point for removable media | Removable devices like USB drives |
Filesystem Mount Points and Initialization
The base filesystem layout is supported by mounting virtual filesystems at boot time:
/procis mounted as a procfs providing process and kernel info./sysis mounted as sysfs exposing device and kernel interfaces./devis mounted as devtmpfs for dynamic device nodes./tmpis optionally mounted as tmpfs for volatile temporary storage.
These mounts are essential for system functionality and are configured via initialization scripts and /etc/fstab.
Security and Permissions
The base filesystem layout enforces strict permissions on critical directories:
/etcand/rootare typically restricted to root user only./tmpand/var/tmpallow broader write access but have sticky bits set to prevent unauthorized deletion of other users’ files.- Device files in
/devhave permissions managed dynamically to reflect hardware security needs.
Summary
The Base Filesystem Layout in Alpine Linux is a carefully constructed hierarchy that balances minimalism, clarity, and functionality. It provides a solid foundation for the operating system by organizing executables, libraries, configuration files, user data, and system information in a way that supports Alpine's design goals of simplicity, security, and resource efficiency. Understanding this layout is essential for system administrators and developers working with Alpine Linux to manage, customize, and troubleshoot the system effectively.