Booting without initramfs
Overview
Booting without initramfs can be useful in some situations such as:
- Boot image doesn't fit boot partition even if initramfs is split
- Loading ramdisk results in kernel panic
- Other ramdisk issues preventing device to boot
However, this method has some disadvantages and cannot be used in some cases.
Disadvantages
- Modules cannot be loaded before mounting rootfs, so this method cannot be used if kernel modules have to be loaded to mount rootfs.
- Other functions provided by or depending on pmOS initramfs will not be accessible, such as FDE, debug shell and initramfs hooks execution. USB is initialized by initramfs as well.
Implementation
Modifying cmdline
Kernel's cmdline has to contain information on how to mount rootfs and which init binary to execute.
- The easiest way to change kernel cmdline is to add parameters in
deviceinfo_cmdline
and rebuild device package. This method sets cmdline in boot.img generated by mkbootimg. It won't work if bootloader ignores cmdline supplied in this way. - The other method to define cmdline is to add it in
bootargs
property in dts. This property is defined insidechosen
subnode of root node.
/ {
chosen {
bootargs = "...";
};
};
- Another option is to define it in
CONFIG_CMDLINE
of kernel config.
Parameters used to boot without initramfs:
root=
: pointing to block device where rootfs is located, e.g.root=/dev/mmcblk0p10
rw
: tell kernel to mount rootfs as read-write
rootwait
,rootwait=
: parameters used to wait for rootfs block device availability before mounting. Add one of these parameters to avoid kernel panic if block device is not recognized by kernel in time.
init=
: is pointing to init binary.init=/sbin/init
by default, so you don't have to define it unless you use non-standard init binary.
Full list of possible cmdline parameters can be found at https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
Loading kernel modules
Use modprobe.conf or modules-load.conf. Create file in device package and add it to sources=
in APKBUILD. No other actions required as devicepkg-dev
takes care of installing these files. modules-load.conf
is installed to /etc/modules-load.d/00-$devicepkgname.conf
, therefore it has highest priority compared to other configuration files there.
Replacing initramfs hooks
Hooks can be replaced with services.
Simple example for OpenRC:
#!/sbin/openrc-run
command="/path/to/command"
commandargs=""
pidfile="/run/${RC_SVCNAME}.pid"
See also: OpenRC Service Script Writing Guide
Additional tips
- Disable
kill-pbsplash
service as it's not needed without initramfs
Installation
Given that initramfs is not used, there is no need to split rootfs in boot and root partitions. Use pmbootstrap install --single-partition
.