Initramfs

From Lolly's Wiki
Revision as of 09:43, 6 October 2022 by Lollypop (talk | contribs)
Jump to navigationJump to search

Adding binaries to the initial ram disk in ubuntu

Adding vi to initramfs

$ sudo apt --yes install vim
$ sudo cat >/etc/initramfs-tools/hooks/vi <<EOH
#!/bin/sh -e

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/vim.basic /bin

exit 0
EOH
$ sudo chmod 0755 /etc/initramfs-tools/hooks/vi
$ sudo update-initramfs -k $(uname -r) -u -v
...
Calling hook vi
Adding binary /usr/bin/vim.basic
Adding binary-link /usr/lib/x86_64-linux-gnu/libtinfo.so.6
Adding binary /usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
Adding binary-link /usr/lib/x86_64-linux-gnu/libsodium.so.23
Adding binary /usr/lib/x86_64-linux-gnu/libsodium.so.23.3.0
Adding binary /lib/x86_64-linux-gnu/libgpm.so.2
Adding binary /lib/x86_64-linux-gnu/libpython3.10.so.1.0
Adding binary-link /usr/lib/x86_64-linux-gnu/libexpat.so.1
Adding binary /usr/lib/x86_64-linux-gnu/libexpat.so.1.8.7
...

As you can see all needed libraries for the binary are added automatically.