Install using Chroot - nutthawit/alpine-dotfile GitHub Wiki
Define variables for use throughout this document.
DISK_DRIVE=/dev/nvme0n1
ESP_PART="${DISK_DRIVE}p1"
ROOT_PART="${DISK_DRIVE}p2"
CHROOT_DIR=/alpine
SYSLINUX_PART=${CHROOT_DIR}/EFI/syslinux
TIMEZONE=Asia/BangkokInstall alpine-chroot-install
dnf install -y make
mkdir ~/alpine-build && cd ~/alpine-build
git clone https://github.com/alpinelinux/alpine-chroot-install.git
make installCreate Btrfs partition
alias p="parted -sa optimal ${DISK_DRIVE}"
p mklabel gpt
p mkpart p 0G 1G
p mkpart p 1G 100%
p set 1 esp
mkfs.vfat -F32 ${ESP_PART}
mkfs.btrfs -L ALPINE -n 32k ${ROOT_PART}NOTE: The Btrfs default nodesize for metadata is 16 KiB, while the default sectorsize for data is equal to page size and autodetected. To use a larger nodesize for metadata (must be a multiple of sectorsize, up to 64 KiB is allowed), specify a value for the nodesize via the -n switch.
NOTE: According to mkfs.btrfs(8) § OPTIONS, "a smaller node size increases fragmentation but leads to taller b-trees which in turn leads to lower locking contention. Higher node sizes give better packing and less fragmentation at the cost of more expensive memory operations while updating the metadata blocks".
Create subvolumes
mkdir ${CHROOT_DIR}
mount ${ROOT_PART} ${CHROOT_DIR}
btrfs subvolume create ${CHROOT_DIR}/@
btrfs subvolume create ${CHROOT_DIR}/home
btrfs subvolume create ${CHROOT_DIR}/var
umount ${CHROOT_DIR}Mount
mount -o compress=zstd,subvol=@ ${ROOT_PART} ${CHROOT_DIR}
mkdir -p ${CHROOT_DIR}/home
mkdir -p ${CHROOT_DIR}/var
mkdir -p ${CHROOT_DIR}/boot
mount -o compress=zstd,subvol=home ${ROOT_PART} ${CHROOT_DIR}/home
mount -o compress=zstd,subvol=var ${ROOT_PART} ${CHROOT_DIR}/var
mkdir -p ${CHROOT_DIR}/boot/EFI/syslinux
mount ${ESP_PART} ${CHROOT_DIR}/boot/EFIInstall alpine base-system to chroot dir
sudo alpine-chroot-installEnter chroot
${CHROOT_DIR}/enter-chrootRe-define variables
DISK_DRIVE=/dev/nvme0n1
ESP_PART="${DISK_DRIVE}p1"
ROOT_PART="${DISK_DRIVE}p2"
CHROOT_DIR=/alpine
TIMEZONE=Asia/Bangkok
SYSLINUX_PART=${CHROOT_DIR}/EFI/syslinuxPreparing init services reference
apk add openrc
rc-update add devfs sysinit
rc-update add dmesg sysinit
rc-update add mdev sysinit
rc-update add hwclock boot
rc-update add modules boot
rc-update add sysctl boot
rc-update add hostname boot
rc-update add bootmisc boot
rc-update add syslog boot
rc-update add mount-ro shutdown
rc-update add killprocs shutdown
rc-update add savecache shutdownNOTE: If btrfs is used for root filesystem, ensure that the initramfs is generated with the btrfs module, otherwise the system may fail to boot.
Edit the /etc/mkinitfs/mkinitfs.conf and ensure that "btrfs" is in the list of features
features="ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio btrfs"Regenerate the initramfs
mkinitfsLoad the btrfs kernel module
modprobe btrfs
echo btrfs >> /etc/modules
rc-update add btrfs-scan bootReference: https://wiki.alpinelinux.org/wiki/Bootloaders#Syslinux
- Install the GPT MBR onto the drive that you want to install the bootloader on
Reference: https://wiki.archlinux.org/title/Syslinux#GUID_partition_table
apk add syslinux
dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=$DISK_DRIVE- Install required Syslinux binaries
extlinux --install $SYSLINUX_PART- Update content of
/mnt/EFI/syslinux/syslinux.cfg
# Contents of /mnt/EFI/syslinux/syslinux.cfg
...
DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU HIDDEN
MENU AUTOBOOT Alpine will be booted automatically in # seconds
TIMEOUT 10
LABEL lts
MENU DEFAULT
MENU LABEL Linux lts
LINUX /boot/vmlinuz-lts
INITRD /boot/initrd-lts
APPEND root=/dev/nvme0n1p2 modules=sd-load,usb-storage,btrfs quiet- Add
syslinuxto the EFI boot menu
apk add efibootmgr
efibootmgr -c -d $DISK_DRIVE -p 1 -l /EFI/syslinux/syslinux.efi -L "ALPINE-SYSLINUX" --unicode- Set root password
passwd