Manual Installation
Manual Installation of Alpine Linux involves step-by-step procedures to set up the minimal Linux distribution on bare metal or virtual environments.
Manual Installation is the process of installing Alpine Linux by manually configuring the system from a minimal boot environment without relying on automated scripts or graphical tools. It involves a step-by-step approach where the user explicitly performs partitioning, filesystem creation, package installation, and configuration to build a custom Alpine Linux system tailored to specific needs.
Preparation and Booting the Installation Environment
Begin by downloading the appropriate Alpine Linux ISO image from the official site. Use a USB drive or other bootable media to start the system in the Alpine Linux live environment. Boot into this environment to gain access to a minimal shell, which provides essential tools required for manual installation.
To verify boot mode, check if the system is booted in UEFI or BIOS mode, as this will influence the partitioning scheme and bootloader configuration.
Disk Partitioning and Filesystem Setup
Manual partitioning is performed using command-line utilities such as fdisk, cfdisk, or parted. The goal is to create partitions for:
- The EFI System Partition (ESP) if booting in UEFI mode, formatted as FAT32.
- The root filesystem partition, formatted as ext4, xfs, or another preferred type.
- Optionally, a swap partition or additional partitions for
/home,/var, or/tmp.
Example using fdisk for a BIOS system might entail:
- Creating a new DOS partition table or GPT depending on your system.
- Defining at least one primary partition for root.
- Writing changes and exiting.
After partitioning, format the partitions:
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
Mount the root partition to /mnt and enable swap:
mount /dev/sda1 /mnt
swapon /dev/sda2
If in UEFI mode, create and mount the EFI partition:
mkfs.vfat -F32 /dev/sda1
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
Installing Base System Packages
Alpine Linux uses apk as its package manager. Manual installation involves using the setup-alpine script or installing base packages manually.
To manually install the base system:
- Use the
setup-apkcacheto configure a cache directory for packages. - Use
apkwith the--rootoption to install to the mounted root:
apk add --root /mnt alpine-base alpine-keys
Alternatively, the setup-alpine script can be run to interactively configure the system, but in strict manual installation, package installation and configuration are done explicitly.
Configuring the Installed System
After package installation, chroot into the new system environment:
mount -t proc /proc /mnt/proc
mount -t sysfs /sys /mnt/sys
mount -o bind /dev /mnt/dev
chroot /mnt /bin/sh
Inside the chroot:
- Set the root password using
passwd. - Add necessary users and groups.
- Configure
/etc/network/interfacesor usesetup-interfacesto configure networking. - Set the hostname in
/etc/hostname. - Configure
/etc/apk/repositoriesto point to appropriate Alpine mirrors. - Set timezone and locale information.
- Configure
/etc/fstabwith UUIDs or device names for persistent mounting at boot. - Install and configure the bootloader.
Bootloader Installation and Configuration
The bootloader is responsible for loading the kernel and initial ramdisk during system startup.
- For BIOS systems, install GRUB:
apk add grub
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
- For UEFI systems, install
grub-efiorsystemd-boot:
apk add grub-efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=alpine --recheck
grub-mkconfig -o /boot/grub/grub.cfg
Ensure that the EFI partition is mounted at /boot/efi during installation.
Finalizing Installation and Reboot
Exit the chroot environment:
exit
Unmount all mounted filesystems:
umount -R /mnt
swapoff -a
Reboot the system:
reboot
Remove the installation media to boot into the newly installed Alpine Linux system.
Manual Installation provides full control over every aspect of system setup, enabling customization and understanding of the underlying mechanisms. It is ideal for users requiring minimal installs, custom configurations, or installations in environments where automated tools are unsuitable. Throughout this process, thorough knowledge of Linux system administration, partitioning, filesystems, and bootloaders is essential.