Commit 8fb3af8d authored by Timo Teräs's avatar Timo Teräs

initramfs: process accounting & misc fixes

enable bootchartd to use kernel process accounting for noticing
all processes.

also fix various little bits around the initramfs init.
parent cd5e0181
......@@ -149,14 +149,13 @@ $(INITFS_DIRSTAMP): $(INITFS_APKS)
tar -C $(INITFS_DIR) -xzf $$apk ; \
done
@rm -f "$(INITFS_DIR)/.PKGINFO"
# @mknod $(INITFS_DIR)/dev/null c 1 3
@mkdir -p "$(INITFS_DIR)/etc"
@echo floppy >> "$(INITFS_DIR)/etc/modules"
@touch $(INITFS_DIRSTAMP)
$(INITFS_BASEFILES): $(INITFS_DIRSTAMP) $(ALPINEBASELAYOUT_APK)
@echo "==> initramfs: $(notdir $(ALPINEBASELAYOUT_APK))"
@tar -C $(INITFS_DIR) -xzf $(ALPINEBASELAYOUT_APK) $(INITFS_RAWBASEFILES)
#@echo "floppy" >> "$(INITFS_DIR)/etc/modules"
#@echo "libata dma=0" >> "$(INITFS_DIR)/etc/modules"
@touch $(INITFS_BASEFILES)
$(INITFS_DIR)/init: initramfs-init $(INITFS_DIRSTAMP)
......@@ -197,6 +196,7 @@ $(INITFS_MODDIRSTAMP): $(INITFS_DIRSTAMP) $(INITFS_MODFILES) $(MODLOOP_DIRSTAMP)
$(INITFS): $(INITFS_DIRSTAMP) $(INITFS_DIR)/init $(INITFS_DIR)/sbin/bootchartd $(INITFS_DIR)/sbin/apk $(INITFS_MODDIRSTAMP) $(INITFS_BASEFILES)
@echo "==> initramfs: creating $(notdir $(INITFS))"
@mkdir -p $(dir $(INITFS))
@(cd $(INITFS_DIR) && find . | cpio -o -H newc | gzip -9) > $(INITFS)
#
......
......@@ -17,8 +17,8 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
# Configuration for bootchartd, the bootchart logger script.
TMPFS_SIZE=32m
SAMPLE_PERIOD=0.1
PROCESS_ACCOUNTING="no"
SAMPLE_PERIOD=0.2
PROCESS_ACCOUNTING="yes"
BOOTLOG_DEST=/var/log/bootchart.tgz
LOGDIR=/bootchart
EXIT_PROC="mingetty agetty rungetty getty fgetty"
......@@ -97,7 +97,7 @@ do_logging()
i=$(($i + 1))
done
[ -e kernel_pacct ] && accton off
[ -e kernel_pacct ] && accton
}
# Stop the boot logger. The lock file is removed to force the loggers in
......@@ -155,37 +155,43 @@ finalize()
}
case "$1" in
init)
# Started by the kernel or by the init script.
start-initfs)
NEWROOT="$2"
mkdir "$LOGDIR"
cd "$LOGDIR"
(
cleanup=true
trap "not_stop_logging=false" USR1
reexec=false
trap "reexec=true; not_stop_logging=false" USR2
trap "cleanup=false; not_stop_logging=false" USR2
mkdir "$LOGDIR"
cd "$LOGDIR"
do_logging
if $reexec; then
mkdir "$NEWROOT$LOGDIR"
mv * "$NEWROOT$LOGDIR"
cp /sbin/bootchartd $NEWROOT/sbin
exec chroot $NEWROOT /sbin/bootchartd continue_logging \
"$LOGDIR" </newroot/dev/null \
>$NEWROOT/dev/console 2>&1
else
sleep $SAMPLE_PERIOD
if $cleanup; then
sleep $SAMPLE_PERIOD
finalize
fi
) &
echo $! > $LOGDIR/bootchart.pid
;;
stop-initfs)
NEWROOT="$2"
cd "$LOGDIR"
mkdir "$NEWROOT$LOGDIR"
cp /sbin/bootchartd $NEWROOT/sbin
PID=`cat bootchart.pid`
kill -USR2 $PID
wait $PID
mv * "$NEWROOT$LOGDIR"
;;
continue_logging)
cd "$2"
trap "not_stop_logging=false" USR1
do_logging
finalize
start-rootfs)
(
trap "not_stop_logging=false" USR1
cd "$LOGDIR"
do_logging
finalize
) &
shift
exec "$@"
;;
esac
......
......@@ -9,7 +9,7 @@ SINGLEMODE=no
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# needed devs
mknod /dev/null c 1 3
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
# basic mounts
mount -t proc -o noexec,nosuid,nodev proc /proc
......@@ -73,7 +73,7 @@ done
# start bootcharting if wanted
if [ -n "$KOPT_chart" ]; then
ebegin "Starting bootchart logging"
/sbin/bootchartd init "$NEWROOT"
/sbin/bootchartd start-initfs "$NEWROOT"
eend 0
fi
......@@ -90,7 +90,6 @@ dmesg -n 1
# setup /dev
ebegin "Starting mdev"
mount -t tmpfs -o exec,nosuid,mode=0755 mdev /dev
mknod -m 666 /dev/null c 1 3
ln -s sr0 /dev/cdrom
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
mdev -s
......@@ -183,12 +182,15 @@ mkdir -p /etc/apk
for i in $ALPINE_MNT/packages/*; do
echo $i >> /etc/apk/repositories
done
if [ -n "$KOPT_chart" ]; then
pkgs="$pkgs acct"
fi
apk add --root /newroot --initdb --quiet --progress $pkgs >/dev/null
eend $?
# kill .apk-new files
if [ -z "$KOPT_keep_apk_new" ]; then
find /newroot/etc -name '*.apk-new' | xargs rm
find /newroot/etc -name '*.apk-new' | xargs rm -f
fi
# copy alpine release info
......@@ -200,10 +202,11 @@ if ! [ -f $NEWROOT/etc/apk/repositories ]; then
cp /etc/apk/repositories $NEWROOT/etc/apk/repositories
fi
# newroot is done, signal bootchartd to relocate there
# if bootcharting is done
# setup bootchart for switch_root
chart_init=""
if [ -n "$KOPT_chart" ]; then
killall -USR2 bootchartd
/sbin/bootchartd stop-initfs "$NEWROOT"
chart_init="/sbin/bootchartd start-rootfs"
fi
# switch over to new root
......@@ -218,7 +221,7 @@ sync
ln -sf /.modloop/modules $NEWROOT/lib/modules
echo ""
if [ -x $NEWROOT/sbin/init ]; then
exec /bin/busybox switch_root $NEWROOT /sbin/init $KOPT_init_args
exec /bin/busybox switch_root $NEWROOT $chart_init /sbin/init $KOPT_init_args
fi
echo "initramfs emergency recovery shell launched"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment