• Edit
  • Delete

initramfs-tools

http://manpages.ubuntu.com/manpages/bionic/man8/initramfs-tools.8.html

Available hooks:

  • /usr/share/initramfs-tools/hooks

Interesting examples: (probably needs apt install dropbear)

  • vi /usr/share/initramfs-tools/hooks/dropbear
  • vi /usr/share/initramfs-tools/hooks/cryptroot-unlock
    • adds message to /etc/motd (message of the day)

Create custom hook to include an executable in initramfs

  • vi /etc/initramfs-tools/hooks/dbclient
    • #!/bin/sh
      
      # add hookscripts which need to be executed before this script
      PREREQ="dropbear"
      
      prereqs() {
          echo "$PREREQ"
      }
      
      case "$1" in
          prereqs)
              prereqs
              exit 0
          ;;
      esac
      
      # Load helper functions
      . /usr/share/initramfs-tools/hook-functions
      
      # Helper function to copy an executable to be available in initramfs
      copy_exec /usr/bin/dbclient /bin
  • chmod 755 /etc/initramfs-tools/hooks/dbclient
  • update-initramfs -u

/bin/dbclient (dropbear ssh client) is now available in initramfs busybox