I'm trying to learn how the initramfs works and how it may be configured. I would like curl to be added to the packages available in the initramfs, and run a script which uses curl during boot (which means the network has to be set up, before it).
How should I do it? (I need it to work when upgrading my kernel too.)
You need to edit your initramfs hooks. Create your own file like so:
Rebuild your initramfs:
Check that it actually landed in there:
First thing you wanna know is that Ubuntu is using a system called Upstart instead of the traditional init. The initial ramdisk is still used, but you'll be reconfiguring upstart instead of init.
Second, are you wanting to do this entirely within the context of an initrd? If so, this would be much more complicated.