Configure initramfs-tools para agregar curl a initramfs y ejecute curl en un script al arrancar mientras está en intitrd en Ubuntu 10.04 Server

Configure initramfs-tools para agregar curl a initramfs y ejecute curl en un script al arrancar mientras está en intitrd en Ubuntu 10.04 Server

Estoy tratando de aprender cómo funciona initramfs y cómo se puede configurar. Me gustaría agregar curl a los paquetes disponibles en initramfs y ejecutar un script que use curl durante el arranque (lo que significa que la red debe configurarse antes).

¿Cómo debería hacerlo? (También necesito que funcione cuando actualizo mi kernel).

Respuesta1

Necesitas editar tus ganchos initramfs. Crea tu propio archivo así:

$ cat /usr/share/initramfs-tools/hooks/curl
#!/bin/sh -e
PREREQS=""
case $1 in
        prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /usr/bin/curl /bin

Reconstruya sus initramfs:

$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.8.0-4-generic

Comprueba que realmente aterrizó allí:

$ lsinitramfs -l /boot/initrd.img-3.8.0-4-generic | grep curl
-rw-r--r--   1 root     root       385704 Nov 28 18:32 usr/lib/x86_64-linux-gnu/libcurl.so.4
-rwxr-xr-x   1 root     root       150344 Nov 28 18:32 bin/curl

Respuesta2

Lo primero que debes saber es que Ubuntu está usando un sistema llamado Upstart en lugar del tradicional init. El disco ram inicial todavía se usa, pero deberás reconfigurar advenedizo en lugar de init.

En segundo lugar, ¿quieres hacer esto completamente dentro del contexto de un initrd? De ser así, esto sería mucho más complicado.

información relacionada