3

For debugging purposes, I want to add a text editor to my initramfs. How do I do that?

1 Answer 1

5

Debian-based distributions including Ubuntu and Mint use initramfs-tools to generate their initramfs'es. To add an executable such as nano, place the following script in /etc/initramfs-tools/hooks/nano.sh:

#!/bin/sh    
# See `man initramfs-tools` for details

PREREQ=""
prereqs()
{
        echo "$PREREQ"
}
case $1 in
prereqs)
        prereqs
        exit 0
        ;;
esac
. /usr/share/initramfs-tools/hook-functions

# Begin real processing below this line
copy_exec /usr/bin/nano /usr/bin/nano

Make the script executable:

sudo chmod +x /etc/initramfs-tools/hooks/nano.sh

And rebuild your initramfs:

sudo update-initramfs -u

To add any other executable to the initramfs, change the last line of the script to poinnt to it. The copy_exec helper function automatically includes any necessary libraries.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.