Alpine Source Map by boot sequence

From Alpine Linux
Revision as of 07:07, 29 November 2016 by Dlin (talk | contribs) (find the initramfs source)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Alpine Source Map by boot sequence

This material is work-in-progress ...

Alternate message.
(Last edited by Dlin on 29 Nov 2016.)

There are many different running mode/environment for Alpine. Here I try to describe what I've learned by tracing the source code.

Boot Sequence

A typical boot sequence of Alpine is:

  1. Hardware BIOS
  2. Boot Loader (syslinux's isolinux)
  3. Initramfs (linux-grsec)
  4. Kernel (linux-grsec)
  5. Init System(openrc)
  6. Shell(busybox's ash)

For Embedded System:

  1. Boot Loader(UBOOT)
  2. Kernel
  3. Init System
  4. Shell

For docker:

  1. Shell (docker image


The 'syslinux.cfg' of syslinux in put in


You can extract it by gzip -dc initramfs-grsec|cpio -vid You could remove 'quiet' and add 'debug' flag on kernel boot options to display more debug information. The source of init could be found by apk info -W /usr/share/mkinitfs/initramfs-init


The package kernel into ISO file method in

The source of kernel in linux-grsec


The Alpine customized scripts are in

  1. /etc/inittab
  2. /etc/runlevels/boot/bootmisc


By 'apk info -W /etc/profile', we know the default profile is customized in alpine-baselayout

Developer Environment

Trace code in docker

In any modern Linux distribution, run docker will let you get the same developer environment.

 docker run -it --name alpine alpine /bin/sh

Create the build/development inside docker

 apk update
 apk add tmux vim diffutils # my tools
 apk add alpine-sdk xorriso syslinux
 adduser YOUR_ID # There are some build scripts can't work under 'root' account.
 su - YOUR_ID
 abuild-keygen -i -a

Build one package sample(eg. openrc)

 git clone
 cd aports/main/openrc  # change this line to the package which you want to change
 abuild -r
 ls -l ~/packages/x86_64/openrc*

When you shut down your PC, you can recall the docker 'alpine' container by

 docker start alpine
 docker attach alpine


  • Test ISO file
 qemu-system-x86_64 -enable-kvm -localtime -m 512M -vga std  \
   -drive file=YOUR_ISO_FILE ,cache=none,if=virtio
  • Test Package in docker

To make sure you got the same environment of default package environment, just use docker.

 docker run --it --rm --name alpine-test alpine /bin/sh
 apk update
  # on other window copy your new apk into the 'alpine-test' container
 docker cp foo.apk alpine-test:/tmp
  # back to 'alpine-test' container
 apk fix /tmp/foo.apk