diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-07-13 23:43:42 -0400 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-07-13 23:43:42 -0400 |
commit | 80d98ad93aaf8b02bce80dbbac81b2beed518d3a (patch) | |
tree | 830420eda23839518485ae6e58e83d2ec5ac4339 | |
parent | 3a00916f4eb86a96de7f8c94974d20e3ea91c474 (diff) | |
download | minitramfs-80d98ad93aaf8b02bce80dbbac81b2beed518d3a.tar.xz minitramfs-80d98ad93aaf8b02bce80dbbac81b2beed518d3a.zip |
add basic module support
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | cpio_list.txt | 1 | ||||
-rw-r--r-- | init | 2 | ||||
-rwxr-xr-x | make | 5 | ||||
-rw-r--r-- | modules | 1 |
7 files changed, 16 insertions, 5 deletions
@@ -3,3 +3,4 @@ /gen_init_cpio /initramfs.d /initramfs.img +/modules.sh @@ -1,6 +1,6 @@ all: initramfs.img -initramfs.img: gen_init_cpio dropbear_ed25519_host_key +initramfs.img: gen_init_cpio dropbear_ed25519_host_key modules.sh ./make gen_init_cpio: gen_init_cpio.c @@ -9,6 +9,10 @@ gen_init_cpio: gen_init_cpio.c dropbear_ed25519_host_key: dropbearkey -t ed25519 -f $@ +modules.sh: modules + printf '%s\n' '#!/bin/sh' 'set -e' > $@ + xargs -a $< -L1 -r modprobe --show-depends >> $@ + install: initramfs.img rm -f /boot/initramfs.img.old /boot/initramfs.img.new cp initramfs.img /boot/initramfs.img.new || rm -f /boot/initramfs.img.new @@ -13,6 +13,7 @@ Features: - firmware loading (trivial, done by kernel) - extremely fast initramfs creation: compression off: ~70ms cold cache, ~30ms warm; lz4 --best: 1.6s +- udev/mdev-free module loading - no temporary files during creation - extremely fast initramfs runtime: ~zero overhead compared to direct kernel loading @@ -23,10 +24,6 @@ Drawbacks: - uses existing system tools - pure POSIX shell + POSIX Makefile -- no modprobe support, custom kernel is required to use myinitramfs in useful - cases. if you want dynamic module loading (if you want modprobe, then you - probably also want mdev or udev), probably better to use mkinitcpio or - dracut. Usage: diff --git a/cpio_list.txt b/cpio_list.txt index ed02ceb..f0c7b7c 100644 --- a/cpio_list.txt +++ b/cpio_list.txt @@ -20,6 +20,7 @@ slink /etc/mtab /proc/self/mounts 0755 0 0 # executables file /bin/busybox /bin/busybox 0755 0 0 +file /etc/modules.sh ./modules.sh 0755 0 0 file /init ./init 0755 0 0 # firmware @@ -11,6 +11,8 @@ mkdir -p /dev/pts # /dev/pts for dropbear mount -t devpts devpts /dev/pts +/etc/modules.sh || exit + ( ip link set eth0 up udhcpc -i eth0 @@ -32,6 +32,11 @@ gen_cmd() { # generate the main file list gen_cpio_list() { sed -e '/^#/d' cpio_list.txt + while read insmod mod args; do + if [ "$insmod" = insmod ]; then + printf 'file %s %s 0644 0 0\n' "$mod" "$mod" + fi + done < modules.sh gen_cmd e2fsck gen_cmd dropbear # cryptsetup argon2 uses pthread_cancel, glibc dlopens libgcc_s.so.1 @@ -0,0 +1 @@ +vfat |