I did some more investigation, and after reading /sbin/bootchartd came
up with a simpler hook that's 90% right:

    #!/bin/sh
    # Absolute barebones setup for rdinit=/sbin/bootchartd.
    # Does not support /etc/bootchartd.conf magic,
    # which in the ramdisk is only the sample rate (default 50Hz).
    set -e
    case $1 in (prereqs) echo busybox; exit;; esac
    . /usr/share/initramfs-tools/hook-functions
    copy_exec /lib/bootchart/bootchart-collector
    printf '#!/bin/sh\n/lib/bootchart/bootchart-collector -c &\nexec /init 
"$@"\n' >"$DESTDIR"/sbin/bootchartd
    chmod +x "$DESTDIR"/sbin/bootchartd
    # bootchart-collector mounts a tmpfs here.
    mkdir -p "$DESTDIR"/lib/bootchart/tmpfs

Now when I boot with "break rdinit=/sbin/bootchartd", I get

    /sbin/bootchartd: line 2: can't open '/dev/null'
    Loading, please wait...
    Begin: Loading essential drivers ... done.
    [...]

and if I run "ps | grep [b]ootchart" from the break (ramdisk shell),
I can see bootchart-collector isn't running.

If I then run "/lib/bootchart/bootchart-collector -c &" it falsely claims

    bootchart-collector run outside initrd

It's whinging about /dev/null because sh implicitly redirects stdin of
backgrounded children there.  Explicitly closing stdin first didn't work:

    printf '#!/bin/sh\n/lib/bootchart/bootchart-collector -c <&- & exec /init 
"$@"\n' >"$DESTDIR"/sbin/bootchartd

But creating /dev/null does!

    printf '#!/bin/sh\nmknod /dev/null c 1 3; ls -ld /dev/null; 
/lib/bootchart/bootchart-collector -c & exec /init "$@"\n' 
>"$DESTDIR"/sbin/bootchartd

That successfully starts a bootchart-collector which is still running
when I get to the "break" shell, though it is also complaining about
"run outside initrd".

OK, so after I confirmed bootchart-collector is running there,
I let boot proceed.  But when I let that proceed to the desktop,
there's no /var/log/bootchart*.

I'll have to leave it here for now.

Attachment: signature.asc
Description: Digital signature

Reply via email to