Bootstrapping Alpine Linux
1. Pre-install
- Boot from existing OS or LiveCD
- Configure the network (iwd or wpa_supplicant)
- Partition your disks and format the partitions (fdisk and mkfs)
- Mount the partitions to /mnt (root) and /mnt/boot (ESP or boot)
Example:
wpa_passphrase <SSID> <password> > /etc/wpa_supplicant/wpa_supplicant.conf
rc-service wpa_supplicant start
fdisk /dev/nvme0n1
mkfs.vfat -F 32 /dev/nvme0n1p1
mkfs.btrfs /dev/nvme0n1p2
mount /dev/nvme0n1p2 /mnt
mount --mkdir /dev/nvme0n1p1 /mnt/boot
2. Install base system
wget https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.4/x86_64/apk.static
chmod +x apk.static
./sbin/apk.static --arch $(arch) -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/ -U --allow-untrusted --root /mnt --initdb add alpine-base
3. Chroot
for i in dev sys; do mount --rbind /$i /mnt/$i; mount --make-rslave /mnt/$i; done
mount --bind /run /mnt/run
mount --make-slave /mnt/run
mount -t proc /proc /mnt/proc
cp -L /etc/resolv.conf /mnt/etc
chroot /mnt /bin/sh
4. Sync
/etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
apk update
5. Kernel and services
apk add linux-lts udev
rc-update add udev sysinit
rc-update add udev-trigger sysinit
rc-update add udev-settle sysinit
rc-update add udev-postmount
rc-update add hostname boot
rc-update add syslog boot
rc-update add acpid
5. Tools
5.1 Wi-Fi
apk add iwd openresolv
rc-update add iwd
/etc/iwd/main.conf
[General]
EnableNetworkConfiguration=True
[Network]
NameResolvingService=resolvconf
5.2 Btrfs
apk add btrfs-progs
If you use NVMe and/or Btrfs, add "nvme" and/or "btrfs" to feature list in /etc/mkinitfs/mkinitfs.conf and create new initramfs.
6. Add entry to bootloader
/boot/loader/entries/alpine.conf (example)
title Alpine Linux
linux /vmlinuz-lts
initrd /initramfs-lts
options rw root=/dev/nvme0n1p2 rootfstype=btrfs quiet