Skip to content
saphiralinux

Bootstrap release

Saphira Linux v0 Bootstrap

A hands-on guide to installing Saphira onto a target disk, written for someone who has never bootstrapped a Linux distribution before. You download the Bootstrap release on a computer that already runs Linux, copy Saphira's files onto a spare disk, make that disk bootable, and reboot into Saphira. Every command below is a normal Linux command, explained as you go — nothing is hidden.

A Saphira Linux dragon holding hands with a Linux user

Before you begin

You need two things: an existing Linux system that is already running, and a spare target disk that you are willing to erase. The existing system is the host. It is where you download and unpack the Bootstrap release, identify the disk, partition it, mount it and start the installation.

TipBootstrapping means assembling a bootable system onto a blank disk, using a computer that already works. Your existing machine (the host) does all the work and is left untouched — only the spare target disk you choose gets erased.
sudo -i
mkdir -p /root/saphira-bootstrap
cd /root/saphira-bootstrap
tar -xJf saphira-linux-v0.bootstrap.tar.xz
ls -la

After extraction you should see README-INSTALL.md, README-KERNEL.md and saphira.rootfs.x86-64-v3/. Read the disk steps once before running them. The examples use /dev/sdX as a deliberately fake disk name; never type it literally.

WarningThe device name /dev/sdX in every example is a placeholder, not a real disk. Substitute the actual device you identified in the next step. Typing an example name verbatim is the most common way to erase the wrong disk.

Commands marked as host commands run on the existing Linux system. Commands after saphira-chroot /mnt/saphira run inside the new Saphira filesystem. The chroot is not a virtual machine and does not boot a new kernel.

Stop and check the disk before erasing it

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL
findmnt
blkid

Find the spare disk by its size, model and current mount points. The installation below formats a partition and installs GRUB to the disk. A mistake here can destroy the host operating system or somebody else's data. If you are unsure which device is the spare disk, stop and identify it before continuing.

  • Do not use the host's mounted root disk as /dev/sdX.
  • Do not run mkfs or grub-install until the device has been checked twice.
  • Back up anything on the target disk that matters; this process is destructive.
WarningTake the disk check seriously. The commands that follow will format the target and install the boot loader to it. A wrong device can wipe your host or someone else's data. Identify the disk, then check it twice.

What this release contains

The Bootstrap archive contains the Saphira x86-64-v3 root filesystem, installation and kernel documentation, the rootfs archive, checksums, and a bundled Linux 7.2 source archive with its SHA-256 checksum and PGP signature.

This is not a pre-built installer image. You prepare the target disk from another Linux system, copy the root filesystem onto it, generate its filesystem table, install GRUB, and create a fresh target-specific GRUB configuration.

Requirements and CPU check

Saphira userspace requires x86-64-v3. The requirement comes from musl and the compiled userspace binaries, not from the kernel alone.

  • AVX2, BMI1, BMI2, FMA, F16C, LZCNT and MOVBE, plus the x86-64-v2 baseline.
  • Intel Haswell (2013) or newer is a useful rough guide.
  • AMD Excavator or Zen (2015) or newer is a useful rough guide.
  • Older CPUs may boot the kernel but userspace will stop with Illegal instruction.
lscpu | grep -o -e avx2 -e bmi1 -e bmi2 -e fma -e f16c -e movbe

All six names must be present before installing. Check the target machine, or the host when the target is a virtual machine.

WarningIf any of the six names is missing, stop now. Saphira's userspace is compiled for x86-64-v3 and will crash with Illegal instruction the moment it starts, even though the kernel itself may have booted. There is no software workaround — you need x86-64-v3 hardware.

Prepare and mount the target

Use an already-running Linux system with root access and a target disk you are prepared to wipe. Identify the target carefully; the example device name is deliberately not a real disk.

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL
fdisk /dev/sdX
mkfs.ext4 /dev/sdX1
e2label /dev/sdX1 saphira
mkdir -p /mnt/saphira
mount /dev/sdX1 /mnt/saphira
findmnt /mnt/saphira

For UEFI, create a GPT table, a FAT32 EFI system partition mounted at /boot/efi, and a root partition. BIOS installation uses GRUB on the whole disk and is the simple KVM/QEMU path.

TipDecide BIOS vs UEFI before you partition. Most virtual machines and older boards use BIOS, which is the simpler path; modern physical hardware usually uses UEFI. The chroot and GRUB steps later differ slightly depending on which you chose.

Copy the root filesystem

From the directory containing the extracted Bootstrap release, copy the contents of the root filesystem into the mounted target. The trailing /. is important: it avoids creating an extra rootfs directory on the target.

cp -a saphira.rootfs.x86-64-v3/. /mnt/saphira/
ls /mnt/saphira

The target should now contain directories such as bin, boot, dev, etc, lib, root, run, sbin, usr and var. The files are present, but the disk is not bootable until fstab and GRUB are configured.

Generate fstab and enter the chroot

saphira-genfstab /mnt/saphira > /mnt/saphira/etc/fstab
cat /mnt/saphira/etc/fstab
saphira-chroot /mnt/saphira

Read the generated fstab before continuing. saphira-genfstab prefers UUID and PARTUUID entries. saphira-chroot binds the required /dev, /dev/pts, /proc, /sys, /run and resolver paths in a private mount namespace, then enters the copied filesystem.

TipA chroot changes which directory the shell treats as the top of the filesystem (/). After saphira-chroot, commands run as if inside the target Saphira disk, even though the running kernel is still the host's. saphira-chroot is a small helper script that sets up the required paths for you — you can read it at /usr/bin/saphira-chroot.

Inside the chroot, paths refer to the target filesystem. The running kernel is still the host kernel; do not use uname in the chroot as evidence that the target kernel is running.

saphira-chroot /mnt/saphira apk info
saphira-chroot /mnt/saphira /bin/sh

APK and the repository

The copied root filesystem contains APK and its initial repository configuration. The Bootstrap guide keeps the local package cache available and allows the live Saphira repository to be added inside the chroot before refreshing the index.

NoteAPK is Saphira's package manager. apk update refreshes the list of available packages, apk add <name> installs one, and apk search <word> finds packages by name. The shipped configuration only points at a local cache, so the commands below first add the live Saphira repository address before updating.
grep -q 'packages.akadata.ltd/saphira/main' /etc/apk/repositories || \
  echo 'https://packages.akadata.ltd/saphira/main/' >> /etc/apk/repositories
apk update
apk add <package>

This step can be done before rebooting in the chroot or after the first boot. The chroot needs working network and DNS through the host.

Kernel choices

The root filesystem retains a usable reference kernel, configuration and modules so the freshly bootstrapped system has a fallback path while you work on your own kernel.

WarningThe 7.1.5-akadata reference kernel only boots on a KVM x86-64-v3 virtual machine. On physical hardware or a different hypervisor it will not boot, so it is not a safety net there — build your own Linux 7.2 kernel for those targets before the first reboot.
  • /boot/vmlinuz-7.1.5-akadata
  • /boot/config-7.1.5-akadata
  • /lib/modules/7.1.5

The preferred development path is to build Linux 7.2 from the bundled verified source. The source lives in /usr/src with four files: README.md, linux-7.2.tar.xz (the compressed source), linux-7.2.tar.xz.sha256 (its checksum) and linux-7.2.tar.sign (its PGP signature).

NoteBuilding your own kernel is optional and is explained step by step on the Kernel build page. The commands below give the short version; open that page when you are ready to compile.
cd /usr/src
sha256sum -c linux-7.2.tar.xz.sha256
gpg --verify linux-7.2.tar.sign linux-7.2.tar.xz
tar -xJf linux-7.2.tar.xz
cd linux-7.2
cp /boot/config-7.1.5-akadata .config
make olddefconfig
make -j$(nproc)
make modules_install
make install

The PGP signature is for the uncompressed tar archive represented by the signed source release. Import and trust the kernel.org signing key separately before relying on that verification.

Install GRUB and create the boot menu

The target needs a new filesystem-specific GRUB configuration. Do not copy or rely on an old boot/grub/grub.cfg from another installation.

TipGRUB is the boot menu you see before the operating system starts. grub-install writes the boot loader to the disk; grub-mkconfig scans /boot for kernels and writes the menu. Because every disk is different, always regenerate grub.cfg for this target rather than reusing another machine's file.
# BIOS / legacy boot
grub-install /dev/sdX
grub-mkconfig -o /boot/grub/grub.cfg
cat /boot/grub/grub.cfg

For UEFI, use the target's mounted EFI system partition and the Saphira bootloader ID, then regenerate the same target-specific grub.cfg.

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Saphira
grub-mkconfig -o /boot/grub/grub.cfg

First boot and helper tools

Leave the chroot, unmount the target cleanly, detach it from the host as appropriate, and boot the target disk. Saphira's first-boot setup then asks for the root password, normal user, networking, DNS and APK repository configuration.

exit
umount -R /mnt/saphira
reboot

The installed helper tools are ordinary shell scripts. Read them when you need to understand or adapt the process:

  • /usr/bin/saphira-bootstrap
  • /usr/bin/saphira-chroot
  • /usr/bin/saphira-genfstab

After first boot

The first boot runs akadata-firstboot. It asks for the root password, creates the normal user, configures IPv4 and IPv6, selects DNS, and confirms the Saphira APK repository. It then leaves you at a normal shell.

apk update
apk search node
apk add node

If the machine does not boot, use the troubleshooting section below and change one thing at a time rather than several at once.

WarningThe 7.1.5-akadata fallback only boots on a KVM x86-64-v3 virtual machine. On a physical machine or a different hypervisor, do not expect it to rescue a failed boot — fix and rebuild your own 7.2 kernel instead. Keep /lib/modules/7.1.5 until your built kernel is proven.

Troubleshooting without guessing

  • Illegal instruction early in boot: confirm all x86-64-v3 CPU features are present.
  • GRUB reports no Linux image: check ls /boot/vmlinuz-* inside the target and regenerate grub.cfg.
  • GRUB stops at a prompt: repeat grub-install for the correct whole disk, then run grub-mkconfig again.
  • No DNS in the chroot: saphira-chroot binds the host resolver; repair host DNS first.
  • apk update fails: check /etc/apk/repositories, DNS, routing and access to the Saphira repository.

If a new kernel fails on a KVM x86-64-v3 guest, select the original 7.1.5-akadata kernel from GRUB's Advanced options. On a physical machine or a different hypervisor, that fallback will not boot either, so fix and rebuild your own 7.2 kernel instead. Either way, do not delete /lib/modules/7.1.5 until the new kernel has booted and its hardware support has been checked.

Build your own kernel

The bundled 7.1.5-akadata kernel is enough to boot. If you want to compile Linux 7.2, use the separate, step-by-step kernel guide.

Open the kernel build guide →