Posts: 22
wean_irdeh
Joined: 02 Sep 2015
#1
Hi. I'd like to add program to initrd.img so it could run before the root filesystem mounted. How is this possible?

EDIT: I'd like to add qemu-utils which is installed by apt-get and it's dependencies to initrd.img
Last edited by wean_irdeh on 01 Aug 2016, 15:47, edited 2 times in total.
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#2
For live-init, I've used /usr/local/bin/ps_initrd.sh (Usage: ps_initrd.sh INITRD open|close|cancel)
but it's been more than a year since I messed with it. To confirm the workflow, I would need to dig through my old notes.
(something like: create a dir to work in, copy the current init..gz file into workdir, cd workdir, run"ps_initrd.sh init..gz open" to extract contents...)
In the meantime, examining ps_initrd.sh in a text editor might be enlightening for you.
IIRC, it's primarily a wrapper script which employs tools (commands) which are provided by the debian package"initramfs-tools" (preinstalled in antiX)

manpages:
man initramfs-tools
man mkinitramfs
man update-initramfs

You can also skim the docs-n-examples here:
/etc/initramfs-tools/*
/usr/share/doc/initramfs-tools/*
/usr/share/initramfs-tools/*
before the root filesystem mounted
Bear in mind that your injected"program" probably has only busybox command interpreter available at that point during init.
Posts: 22
wean_irdeh
Joined: 02 Sep 2015
#3
skidoo wrote:
before the root filesystem mounted
Bear in mind that your injected"program" probably has only busybox command interpreter available at that point during init.
How could one determine if a program would run in busybox or not?

EDIT:
skidoo wrote: manpages:
man initramfs-tools
man mkinitramfs
man update-initramfs
Does this means all antiX distro use initramfs instead of initrd? There's different instruction regarding unpack either
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#4
antiX distro use initramfs instead of initrd?
The fact that you're asking, rather than determining for yourself, via
sudo locate initrd
sudo locate initramfs

doesn't bode well for the prospect of your success.

How could one determine if a program would run in busybox or not?
A google search would have pointed you straightaway to busybox.net
I not familiar enough with busybox to discuss what is or isn't possible. I'm not even certain the init for an installed (not live-boot) antiX uses busybox.