summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rw-r--r--README5
-rw-r--r--cpio_list.txt1
-rw-r--r--init2
-rwxr-xr-xmake5
-rw-r--r--modules1
7 files changed, 16 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 7226a25..b50d433 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/gen_init_cpio
/initramfs.d
/initramfs.img
+/modules.sh
diff --git a/Makefile b/Makefile
index e408200..f36ca69 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README b/README
index ddbb939..2f5b3e7 100644
--- a/README
+++ b/README
@@ -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
diff --git a/init b/init
index 7a63521..706de93 100644
--- a/init
+++ b/init
@@ -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
diff --git a/make b/make
index 5dc25f1..9ce479c 100755
--- a/make
+++ b/make
@@ -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
diff --git a/modules b/modules
new file mode 100644
index 0000000..1506af7
--- /dev/null
+++ b/modules
@@ -0,0 +1 @@
+vfat