Alpine Linux has gained significant popularity in recent years, especially among developers and system administrators looking for a lightweight, secure, and resource-efficient operating system. Its small footprint makes it an excellent choice for containers, embedded systems, and even as a minimalist desktop.
If you’re ready to dive into the world of Alpine, this guide will walk you through the installation process step-by-step.
Why Alpine Linux?
Before we begin, let’s quickly highlight some of Alpine’s key advantages:
- Extremely Small: The base installation is incredibly tiny, typically under 100MB.
- Security-Focused: Alpine uses
musl libc
andPaX
patches in the kernel, enhancing security. - Simplicity: It follows a “KISS” (Keep It Simple, Stupid) philosophy, making it easy to understand and manage.
- Performance: Its lightweight nature translates to faster boot times and lower resource consumption.
What You’ll Need
- Alpine Linux ISO: Download the appropriate ISO image from the official Alpine Linux website. Choose the “Standard” or “Extended” version depending on your needs.
- USB Drive (or DVD): A 1GB or larger USB drive to create a bootable installer.
- USB Creator Tool: Etcher, Rufus (Windows), or
dd
(Linux/macOS) to write the ISO to the USB drive. - Target System: A computer or virtual machine where you want to install Alpine.
- Internet Connection: Recommended for downloading packages during installation.
Step-by-Step Installation
1. Create a Bootable USB Drive
For Windows (using Rufus):
- Download and run Rufus.
- Select your USB drive.
- Click “SELECT” and choose the Alpine Linux ISO.
- Click “START” to create the bootable drive.
For Linux/macOS (using dd
):
- Identify your USB drive’s device name (e.g.,
/dev/sdX
or/dev/diskX
). Be extremely careful with this step, as an incorrect device will wipe your data. - Open a terminal and run:
sudo dd if=/path/to/alpine-standard-x.x.x-x86_64.iso of=/dev/sdX bs=4M status=progress
- Replace
/path/to/alpine-standard-x.x.x-x86_64.iso
with the actual path to your ISO and/dev/sdX
with your USB drive’s device name.
2. Boot from the USB Drive
- Insert the bootable USB drive into your target system.
- Restart your computer and enter your system’s BIOS/UEFI settings (usually by pressing F2, F10, F12, or Del during boot).
- Change the boot order to prioritize the USB drive.
- Save the changes and exit. Your system should now boot into the Alpine Linux installer.
3. Initial Configuration (Live Environment)
Once Alpine boots, you’ll be greeted with a login:
prompt.
- Log in as
root
(no password by default). - Start the installation script:
setup-alpine
The setup-alpine
script will guide you through the initial configuration:
- Keyboard Layout: Choose your keyboard layout (e.g.,
us
,dk
). - Hostname: Enter a hostname for your system (e.g.,
alpinebox
). - Network Configuration:
ip method
: Choosedhcp
for automatic IP configuration orstatic
for manual setup. If you choosedhcp
, it will try to configure automatically.- If you need to configure Wi-Fi, select the wireless interface. You’ll be prompted for an SSID and password.
- Root Password: Set a strong password for the
root
user. - Timezone: Select your continent and city (e.g.,
Europe
,Copenhagen
). - NTP Client: Press Enter to use the default
chrony
. - Proxy: Leave blank unless you use a proxy.
- Mirror: Choose a mirror for packages. Press Enter to select the default fastest mirror.
- SSH Server: Choose
openssh
if you want to enable SSH access. - Disk Setup: This is the most crucial step.
- You’ll see a list of available disks (e.g.,
sda
,vda
). Select the disk you want to install Alpine on. - WARNING: This will erase all data on the selected disk.
- Choose the installation mode:
sys
: Full disk installation (recommended for persistent installs).data
: Install to a data partition, keeping existing partitions.lvm
: For Logical Volume Management setup.
- Confirm your choice by typing
y
and pressing Enter. The installer will partition and format the disk.
- You’ll see a list of available disks (e.g.,
4. Finalizing the Installation
Once the disk setup is complete, the setup-alpine
script will copy the necessary files to your hard drive. This process is usually very quick due to Alpine’s small size.
After the script finishes, you’ll be returned to the root
prompt.
5. Reboot Your System
- Remove the USB installation media.
- Reboot your system:
reboot
Your system should now boot directly into your newly installed Alpine Linux.
6. Post-Installation Steps (Optional but Recommended)
- Log in as root: Use the password you set during installation.
- Update Packages:
apk update
apk upgrade
This ensures all your installed packages are up to date. - Install Essential Tools: Alpine uses
apk
as its package manager. You might want to install some basic tools:apk add nano htop bash bash-completion
(Note:bash
is not the default shell in Alpine;ash
is. If you preferbash
, you can install it.) - Create a Regular User (Highly Recommended): Running as
root
for daily tasks is a security risk.adduser yourusername
passwd yourusername
Follow the prompts to set a password. Add the user to thewheel
group forsudo
privileges:apk add sudo
adduser yourusername wheel
Then, edit the sudoers file:visudo
Uncomment the line# %wheel ALL=(ALL) ALL
to enable sudo for thewheel
group. Save and exit (Ctrl+X
,Y
, Enter if usingnano
). - Install a Desktop Environment (Optional): If you’re using Alpine as a desktop, you’ll need to install a desktop environment like Xfce, LXQt, or MATE. This will significantly increase the system’s size.
apk add xorg-server xfce4 xfce4-terminal lightdm lightdm-gtk-greeter
rc-update add lightdm default
reboot
(This is just an example for Xfce; refer to the Alpine Wiki for other DEs.)
More steps
After the installation, I recommend completing a few other tasks.
- Create a server birth certificate.
- Enabling a secure firewall.
- Disable root SSH login.
- Create a SSH key-pair.
Conclusion
Congratulations! You have successfully installed Alpine Linux. You now have a lean, fast, and secure base system to build upon. Explore the Alpine Linux Wiki and apk
package manager to further customize your installation to suit your specific needs. Enjoy the simplicity and efficiency of Alpine!