- Asus ROG zephyrus G14
- Ryzen 9
- RTX 2060 Max Q
- 1 x 1TB NVME
- 16GB RAM
DISCLAIMER : This is just a reference of my installation. Therefore proceed at your own risk. Since the default installer does not allow for dual booting when there is only one disk present in the device, we will have to install it to the required partition through chroot. The default installer erases the entire disk and partitions it and no other way is mentioned in the alpine wiki as the article on dual booting states it is outdated.
- Windows is installed
- Familiarity with the command line
- Create live disk with alpine Image
- Partition disk with space for alpine
- Boot with live disk
- Setup the live disk environment
- Setup mounts
- Create Chroot environment and install base system
- Entering Chroot amd configuration
- Installing the kernel
- Installing rEFInd and configuration
- Additional steps (required in certain cases)
- Download ISO from https://alpinelinux.org/downloads/ (downloaded standard - x86_64)
- Burn ISO to pendrive
- Partition the drive to contain a ext4 partition which will be the root(/) of the installed Alpine system.
- Create an additional ext4 partition if required for seperate home partition (/home)
- Change boot order in bios and boot into the live disk
- Login as root (passwordless)
localhost login: root
- Setup the network interface
#Set the required interface up
ip link set <interface> up
#Get DHCP lease on interface
udhcpc -i <interface>
- Setup Environment Variables
export chroot_dir=/mnt
# Choose mirror as appropriate from mirror list(https://mirrors.alpinelinux.org/)
export mirror=http://dl-cdn.alpinelinux.org/alpine/
# Choose according to device architecture
export arch=x86_64
# The version of the apk-tools-static package
export version=2.12.0-r3
# Choose the required branch the installed system should use
export branch=v3.12
- Mount the required partitions. It is assumed that the EFI partition of the system is sda1 and the windows partition is sda2. The root partition of the alpine system is sda3 and if seperate home partition is present it is sda4.
mount -t ext4 /dev/sda3 /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot
# in case of a seperate home partition
mkdir -p /mnt/home
mount -t ext4 /dev/sda4 /mnt/home
- Untar the apk-tools-static package after fetching it and install the apline-base with root as
$chroot_dir
wget $mirror/latest-stable/main/x86_64/apk-tools-static-$version.apk
tar -xzf apk-tools-static-*.apk
./sbin/apk.static -X $mirror/latest-stable/main -U --allow-untrusted --root $chroot_dir --initdb add alpine-base
- Mount the virtual filesystems of the kernel
mount -t proc none ${chroot_dir}/proc
mount -o bind /sys ${chroot_dir}/sys
mount -o bind /dev ${chroot_dir}/dev
- Populate repo and dns configs in the chroot environment
echo "${mirror}/${branch}/main" > ${chroot_dir}/etc/apk/repositories
cp /etc/resolv.conf ${chroot_dir}/etc/
- Enter the chroot
chroot /mnt /bin/sh -l
- Setup the system using alpine setup scripts and answer accordingly
apk update
setup-apkrepos
setup-hostname
setup-keymap
setup-timezone
setup-sshd
setup-ntp
- Set a new root password
passwd
- Enabling openrc services
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 shutdown
rc-update add networking boot
rc-update add urandom boot
rc-update add acpid default
rc-update add hwdrivers sysinit
rc-update add crond default
- Create the required fstab file in /etc/fstab
-
Now the system requires a kernel, the official doc for chroot does not include the installation of the kernel
-
Choose the required kernel (https://wiki.alpinelinux.org/wiki/Kernels) and create initramgs with fstab
apk add linux-lts
mkinitfs -f /etc/fstab
- Install bash, lsblk and efibootmgr
apk add bash lsblk efibootmgr
- Download the rEFInd Binary and transfer to the chrooted system
- Run ./refind-install to install it to the boot partition
- Edit the /boot/refind_linux/conf to change the boot parameters as during install it will be populated with the parameters of the live kernel.
"Boot with standard options" "root=/dev/sda3 ro modules=sd-mod.usb-storage,ext4 nomodeset quiet rootfstype=ext4"
"Boot to single-user mode" "root=/dev/sda3 ro modules=sd-mod.usb-storage,ext4 nomodeset quiet rootfstype=ext4 single"
"Boot with minimal options" "ro root=/dev/sda3"
- Make rEFInd search files including ones that don't end with .efi in /boot/EFI/refind/refind.conf
scan_all_linux_kernels true
- Now on reboot you should be preseneted with the refind screen with an option to choose the required OS
In my case since, alpine linux did not boot properly since the nvme driver was not packed into the initramfs causing the system to be unable to mount the rootfs.
mount: mounting /dev/vg0/alpine_root on /sysroot failed: No such file or directory
Mouting root failed
initramfs emergency recovery shell launched.
Solution:
- Using a live disk mount the root and boot directory
mount -t ext4 /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
- Modify the configuration of mkinitfs
cd /mnt/etc/mkinitfs/features.d/
# tells mkinitfs where to find the required drivers
echo "kernel/drivers/nvme/host/*" > nvme.modules
# add nvme as a feature so it is included in initramfs
vi /mnt/etc/mkinitfs/mkinitfs.conf
- Now run mkinitfs on the installed OS
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
chroot /mnt /bin/sh -l
mkinitfs -f /etc/fstab
exit
-
Now the system will boot
-
As a check we can look at the initramfs to look for the nvme module
# create folder in tmp of the live disk
mkdir /tmp/blowup
cp /mnt/boot/initramfs-lts /tmp/blowup/initramfs-lts.gz
cd /tmp/blowup
gunzip initramfs-lts.gz
# expand the initramfs
cpio -ivF initramfs-lts
# look for the nvme.ko driver
cd ./lib/modules/5.4.84-lts/kernel/drives/nvme/host