I ran across the static e2fsck binary, and thought "that would be great to put in the initrd to fix that sort of problem".
Helpful sources of information are as follows:
initramfs-tools (8)
mkinitramfs (8)
/usr/share/initramfs-tools/, especially hooks/* and hook-functions
Most steps must be done as root.
Method:
1. Install the package providing the binary you want:
apt-get install e2fsck-static
2. Determine the name and location:
dpkg -L e2fsck-static|grep 'bin/.'
3. Create a new hook; copy the template from initramfs-tools(8)
Code: Select all
gvim /usr/share/initramfs-tools/hooks/e2fsck
Code: Select all
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
Code: Select all
# e2fsck
. /usr/share/initramfs-tools/hook-functions #provides copy_exec
rm -f ${DESTDIR}/bin/e2fsck #copy_exec won't overwrite an existing file
copy_exec /sbin/e2fsck.static /bin/e2fsck #Takes location in filesystem and location in initramfs as arguments
4. Make executable:
Code: Select all
chmod +x /usr/share/initramfs-tools/hooks/e2fsck
6. Test it:
Code: Select all
update-initramfs -k 3.0.4-tp-5 -u
-k can take `uname -r` as a parameter
-u updates an existing initramfs
7. When you need to use the binary, boot with the
Code: Select all
break
Note: If you want to add a module, look in /usr/share/initramfs-tools/modules for information