Initramfs: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
(Created page with "=Adding binaries to the initial ram disk in ubuntu= == Adding vi to initramfs == <SyntaxHighlight lang=bash> $ sudo cat >/etc/initramfs-tools/hooks/vi <<EOH #!/bin/sh 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 update-initramfs -k $(uname -r) -u </SyntaxHighlight>")
 
Line 2: Line 2:
== Adding vi to initramfs ==
== Adding vi to initramfs ==
<SyntaxHighlight lang=bash>
<SyntaxHighlight lang=bash>
$ sudo apt --yes install vim
$ sudo cat >/etc/initramfs-tools/hooks/vi <<EOH
$ sudo cat >/etc/initramfs-tools/hooks/vi <<EOH
#!/bin/sh
#!/bin/sh -e


PREREQ=""
PREREQ=""
prereqs()
prereqs()
{
{
     echo "$PREREQ"
     echo "\$PREREQ"
}
}


case $1 in
case \$1 in
prereqs)
prereqs)
     prereqs
     prereqs
Line 25: Line 26:
exit 0
exit 0
EOH
EOH
$ sudo update-initramfs -k $(uname -r) -u
$ 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
...
</SyntaxHighlight>
</SyntaxHighlight>
As you can see all needed libraries for the binary are added automatically.

Revision as of 09:42, 6 October 2022

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.