You have to use the entries in /usr/share/initramfs-tools/hooks
. These files are executed when you type update-initramfs
. Create your own hook script or remove scripts.
Another folder is /etc/initramfs-tools/hook
From man initramfs-tools
Hooks can be found in two places: /usr/share/initramfs-tools/hooks and
/etc/initramfs-tools/hooks. They are executed during generation of the
initramfs-image and are responsible for including all the necessary
components in the image itself. No guarantees are made as to the order
in which the different scripts are executed unless the prereqs are
setup in the script.
Note, the hook-scripts are part of the packages, e.g. kmod
. The package creates the file kmod
in /usr/share/initramfs-tools/hooks
.
Sample script
#!/bin/sh -e
# Copy the compatibility symlinks until initramfs-tools will be converted
# to use the kmod program.
if [ "$1" = "prereqs" ]; then exit 0; fi
. /usr/share/initramfs-tools/hook-functions
copy_exec /bin/kmod
cp -a /sbin/modprobe /sbin/rmmod $DESTDIR/sbin/
mkdir -p $DESTDIR/lib/modprobe.d/
if [ "$(echo /lib/modprobe.d/*)" != "/lib/modprobe.d/*" ]; then
cp -a /lib/modprobe.d/* $DESTDIR/lib/modprobe.d/
fi
As you can see, the hook-script copies all files in /lib/modprobe.d/
into initramfs/lib/modprobe.d/
cp -a /lib/modprobe.d/* $DESTDIR/lib/modprobe.d/
and modprobe
into initramfs/sbin
cp -a /sbin/modprobe /sbin/rmmod $DESTDIR/sbin/
Your own initrd.img
with one file foo
cd
mkdir initrd
cd initrd
touch foo # an example file
find . | cpio -o -H newc > ../initrd.img
cd ..
gzip initrd.img
cp initrd.img.gz initrd.img
Check the content of your initrd.img
cd
mkdir initrd_out
cd initrd_out
cpio -i < ../initrd.img
And with ls
you should see one file
% ls
foo