Power Log Collector: Difference between revisions

From OLPC
Jump to navigation Jump to search
(added link to file)
No edit summary
Line 1: Line 1:
This Power Log Collector boots an XO-1 or XO-1.5 and copies the power logs to itself before shutting the laptop down.
This Power Log Collector boots an XO-1 or XO-1.5 and copies the power logs to itself before shutting the laptop down.

Note: will not work on secured laptops without signing.


= Use =
= Use =
* Download [[media:Power-log-collector.tar.bz2|Power-log-collector.tar.bz2]] and unpack onto a USB flash drive
* Download [[media:Power-log-collector.tar.bz2|Power-log-collector.tar.bz2]] and unpack onto a USB flash drive,
* Shut down the XO
* Shut down the XO,
* Insert the USB drive and turn on the XO
* Insert the USB drive, and
* Turn on the XO.
* The XO will collect the power logs, print a message saying has done so and then shut down

The XO will collect the power logs, print a message saying has done so and then shut down


= Theory of Operation =
= Theory of Operation =
* Based on [[Tiny Core Linux]]
* Based on [[Tiny Core Linux]],
* An [[Custom_bootloader#A_single_bootloader_for_both_XO-1_and_XO-1.5|Open Firmware Boot Script]] selects the XO-1 or XO-1.5 kernel.
* An [[Custom_bootloader#A_single_bootloader_for_both_XO-1_and_XO-1.5|Open Firmware Boot Script]] selects the XO-1 or XO-1.5 kernel,
* The initial ramdisk mounts /dev/sda (which should be the first USB drive) and..
* The initial ramdisk mounts /dev/sda (which should be the first USB drive), and
* executes rc.local on that drive
* executes rc.local on that drive, which does the collection.
* rc.local does the collection


= Modifying Tiny Core Linux =
= Modifying Tiny Core Linux =
Line 20: Line 23:
# find | sudo cpio -o -H newc --quiet | gzip -2 > ../initrd.gz
# find | sudo cpio -o -H newc --quiet | gzip -2 > ../initrd.gz


= rc.local =
Note: will not work on secured laptops without signing.

The script that does the collection:

#!/bin/sh
uname -a | grep _xo1-
if [ $? -eq 0 ]
then
echo detected xo-1.0
XO_ROOT=mtdblock0
XO_FS=jffs2
else
echo detected xo-1.5
XO_ROOT=mmcblk0p2
XO_FS=ext3
fi
mkdir -p /mnt/$XO_ROOT
mount -t $XO_FS -o ro /dev/$XO_ROOT /mnt/$XO_ROOT
mkdir -p /mnt/sda1/power-logs
cp /mnt/$XO_ROOT/home/olpc/power-logs/* /mnt/sda1/power-logs
umount /mnt/$XO_ROOT
mount /dev/sda1 /mnt/sda1 -o remount,ro
sync
echo Power Logs Recovered
echo Shutting down in 10 seconds
echo You may remove the USB now
sleep 10
poweroff

Revision as of 03:39, 10 February 2011

This Power Log Collector boots an XO-1 or XO-1.5 and copies the power logs to itself before shutting the laptop down.

Note: will not work on secured laptops without signing.

Use

The XO will collect the power logs, print a message saying has done so and then shut down

Theory of Operation

  • Based on Tiny Core Linux,
  • An Open Firmware Boot Script selects the XO-1 or XO-1.5 kernel,
  • The initial ramdisk mounts /dev/sda (which should be the first USB drive), and
  • executes rc.local on that drive, which does the collection.

Modifying Tiny Core Linux

This will unpack the initial ramdisk to the current directory.

  1. gunzip <../initrd.gz | cpio -i
  2. Modify as needed
  3. find | sudo cpio -o -H newc --quiet | gzip -2 > ../initrd.gz

rc.local

The script that does the collection:

#!/bin/sh

uname -a | grep _xo1-
if [ $? -eq 0 ]
then
       echo detected xo-1.0
       XO_ROOT=mtdblock0
       XO_FS=jffs2
else
       echo detected xo-1.5
       XO_ROOT=mmcblk0p2
       XO_FS=ext3
fi

mkdir -p /mnt/$XO_ROOT

mount -t $XO_FS -o ro /dev/$XO_ROOT /mnt/$XO_ROOT
mkdir -p /mnt/sda1/power-logs
cp /mnt/$XO_ROOT/home/olpc/power-logs/* /mnt/sda1/power-logs
umount /mnt/$XO_ROOT
mount /dev/sda1 /mnt/sda1 -o remount,ro
sync
echo Power Logs Recovered
echo Shutting down in 10 seconds
echo You may remove the USB now
sleep 10
poweroff