Alpine Source Map by boot sequence: Difference between revisions
(Created page with "= Alpine Source Map by boot sequence = {{Draft|Alternate message.}} There are many different running mode/environment for Alpine. Here I try to describe what I've learned by...") |
(find the initramfs source) |
||
(One intermediate revision by the same user not shown) | |||
Line 24: | Line 24: | ||
For docker: | For docker: | ||
# Shell | # Shell (docker image https://hub.docker.com/_/alpine/) | ||
=== syslinux === | === syslinux === | ||
The 'syslinux.cfg' of {{Pkg|syslinux}} in put in https://github.com/alpinelinux/alpine-iso/blob/master/Makefile | The 'syslinux.cfg' of {{Pkg|syslinux}} in put in https://github.com/alpinelinux/alpine-iso/blob/master/Makefile | ||
=== initramfs === | |||
You can extract it by <code>gzip -dc initramfs-grsec|cpio -vid</code> | |||
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 <code>apk info -W /usr/share/mkinitfs/initramfs-init</code> https://github.com/alpinelinux/mkinitfs | |||
=== linux-grsec === | === linux-grsec === | ||
Line 33: | Line 38: | ||
The source of kernel in {{Pkg|linux-grsec}} | The source of kernel in {{Pkg|linux-grsec}} | ||
=== openrc === | |||
The Alpine customized scripts are in https://github.com/alpinelinux/aports/tree/master/main/openrc | |||
# /etc/inittab https://github.com/alpinelinux/aports/blob/master/main/alpine-baselayout/inittab | |||
# /etc/runlevels/boot/bootmisc https://github.com/OpenRC/openrc/blob/master/init.d/bootmisc.in | |||
=== shell === | |||
By 'apk info -W /etc/profile', we know the default profile is customized in {{Pkg|alpine-baselayout}} https://github.com/alpinelinux/aports/tree/master/main/alpine-baselayout | |||
== Developer Environment == | == Developer Environment == |
Latest revision as of 07:07, 29 November 2016
Alpine Source Map by boot sequence
This material is work-in-progress ... Alternate message. |
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:
- Hardware BIOS
- Boot Loader (syslinux's isolinux)
- Initramfs (linux-grsec)
- Kernel (linux-grsec)
- Init System(openrc)
- Shell(busybox's ash)
For Embedded System:
- Boot Loader(UBOOT)
- Kernel
- Init System
- Shell
For docker:
- Shell (docker image https://hub.docker.com/_/alpine/)
syslinux
The 'syslinux.cfg' of syslinux in put in https://github.com/alpinelinux/alpine-iso/blob/master/Makefile
initramfs
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
https://github.com/alpinelinux/mkinitfs
linux-grsec
The package kernel into ISO file method in https://github.com/alpinelinux/alpine-iso/blob/master/Makefile.
The source of kernel in linux-grsec
openrc
The Alpine customized scripts are in https://github.com/alpinelinux/aports/tree/master/main/openrc
- /etc/inittab https://github.com/alpinelinux/aports/blob/master/main/alpine-baselayout/inittab
- /etc/runlevels/boot/bootmisc https://github.com/OpenRC/openrc/blob/master/init.d/bootmisc.in
shell
By 'apk info -W /etc/profile', we know the default profile is customized in alpine-baselayout https://github.com/alpinelinux/aports/tree/master/main/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 https://github.com/alpinelinux/aports 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
- 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