Monday, June 22, 2009

LiveUSB for Asus Eee PC

I've tried to prepare MilaX LiveUSB for Asus Eee PC a year ago. Today WiFi and Ethernet drivers work well for my 900.

Wednesday, June 10, 2009

Busybox on OpenSolaris ARM

After some steps I've got busybox running on OpenSolaris ARM under Qemu:



And here's the output I get from booting in debug mode (look how modstatic loads modules).

Tuesday, June 9, 2009

First OpenSolaris ARM release

Great news from OpenSolaris ARM Port project: first OS release for ARM platform is now available. This release support NEC Electronics's NaviEngine 1 (NE1) and has some interesting features: genunix, unix and required device drivers are statically linked at building time as vmunix to save the startup time, zfs is modified to save the runtime memory.


So I hope that after some time we'll see OpenSolaris powered PDA.

Sunday, June 7, 2009

Minimizing SunStudio

SunStudio Express uses ~900 mb on my Nevada. But for building usual C app I need only small part of SS. For example I used only these files for building imlib2 (I tried various flags):

# cd /opt/SUNWspro; find .
.
./lib
./lib/crt1x.o
./lib/crti.o
./lib/sys
./lib/sys/libyabe.so
./lib/sys/lib_I_quad.so
./lib/sys/libsunir.so
./lib/sys/liblni.so.1
./lib/libdwarf.so
./lib/crt1.o
./lib/libmopt.a
./lib/libdwarf.so.1
./lib/lib_I_dbg_gen.so.1
./lib/values-xa.o
./lib/libm.il
./lib/lib_I_dbg_gen.so
./lib/crtn.o
./bin
./bin/iropt
./bin/fbe
./bin/cc
./bin/ir2hf
./bin/ube
./bin/acomp

# du -hs
19M .

Of course you also need headers for successful compilation, but referring to cc if space is important factor for you - 19 is not 900, right?

Sunday, April 26, 2009

Minimal OpenSolaris network install script

While preparing new version of zfsinstall, I've written sample version for minimal OpenSolaris installation over network. This script also includes disk partitioning. If complete installation is needed just replace pkg list with:

entire
SUNWcsd
SUNWcs

Try it if you've problems with graphics on old laptops and you can't run GUI installer.
You can find osinstaller script in MilaX mercurial repository on OpenSolaris.org.

Tuesday, April 14, 2009

Busybox on OpenSolaris

I hacked busybox and now it's working on my Solaris machine. This is not very fresh version (1.2.0) because all last releases become more Linux-specific. I've removed some applets and added "df","init","mount","umount","ps" from Solaris. Network applets like "ifconfig" are currently not implemented. For embedded Solaris we need native "ifconfig" with "plumb" function.

~$ uname -a
SunOS sysadm 5.11 snv_110 i86pc i386 i86pc
~$ ./busybox
BusyBox v1.2.0 (2009.04.20-10:06+0000) multi-call binary

Usage: busybox [function] [arguments]...
or: [function] [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!

Currently defined functions:
[, [[, awk, bunzip2, busybox, bzcat, cat, chgrp, chmod, chown, chroot, clear, cp, cpio, cut, date, dd, df, du, echo, ed, egrep, env, false,
fgrep, find, grep, gunzip, gzip, halt, head, hostid, hostname, hush, id, init, kill, less, ls, md5sum, mkdir, mknod, mount, mv, nc, nslookup,
poweroff, printf, ps, pwd, reboot, rm, sed, sh, sleep, sort, tar, tee, telnet, test, touch, tr, true, tty, umount, uname, unzip, vi, wc, whoami,
xargs, yes, zcat

Thursday, February 5, 2009

Drawing CPU part of boot chart

I'm using kstat for drawing CPU part of boot chart (see my previous posts). I need cpu values for "user","nice","system","idle","iowait" in such order (sample output):
cpu 8 0 141 313 230 0 0 

I've written the small kstat utility and added its call in a bootchartd script (utility writes /var/log/bootchart/proc_stat.log):
#include <kstat.h>
#include <sys/sysinfo.h>
#include <stdio.h>
#include <string.h>

static kstat_ctl_t *kc;
static kstat_t *ksp;

static unsigned int cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_iowait;

int main(int argc, char **argv) {
cpu_stat_t *cpu_stat;

kc = kstat_open();

if (kc != NULL) {

ksp = kstat_lookup(kc, "cpu_stat", 0, "cpu_stat0");
if (ksp != NULL && ksp->ks_type == KSTAT_TYPE_RAW)
{
if (kstat_read(kc, ksp, NULL) != -1 &&  
ksp->ks_data_size == sizeof(cpu_stat_t))
{
  cpu_stat = (cpu_stat_t *)ksp->ks_data;
  cpu_user=cpu_stat->cpu_sysinfo.cpu[CPU_USER];
  cpu_nice=cpu_stat->cpu_sysinfo.cpu[CPU_WAIT];
  cpu_system = cpu_stat->cpu_sysinfo.cpu[CPU_KERNEL] ;
  cpu_iowait=cpu_stat->cpu_syswait.iowait;
  cpu_idle=cpu_stat->cpu_sysinfo.cpu[CPU_IDLE];

 printf("cpu  %d %d %d %d %d 0 0\n",
 cpu_user,cpu_nice,cpu_system,cpu_idle,cpu_iowait);
        }
    }
  }
}

Sample boot chart for MilaX:


Tuesday, February 3, 2009

Reducing Boot Time

In the last MilaX release (0.3.3) I've tried to reduce boot time from kernel startup to desktop environment up and running. I left only necessary SMF-services for LiveCD and changed startup sequence. The main idea - network services and compressed usr filesystem mounting can start after X server starting.
Here the services list after full booting:
STATE          STIME    FMRI
online         19:49:10 svc:/system/svc/restarter:default
online         19:49:13 svc:/network/datalink-management:default
online         19:49:14 svc:/system/filesystem/usr:default
online         19:49:14 svc:/system/filesystem/root:default
online         19:49:14 svc:/system/utmp:default
online         19:49:21 svc:/system/device/local:default
online         19:49:21 svc:/milestone/devices:default
online         19:49:22 svc:/system/filesystem/minimal:default
online         19:49:22 svc:/system/manifest-import:default
online         19:49:23 svc:/system/rmtmpfiles:default
online         19:49:23 svc:/system/filesystem/local:default
online         19:49:23 svc:/application/xserver:default
online         19:49:24 svc:/system/console-login:default
online         19:49:49 svc:/network/initial:default
online         19:49:57 svc:/network/loopback:default
online         19:49:58 svc:/system/system-log:default
online         19:50:01 svc:/system/cryptosvc:default
online         19:50:04 svc:/system/dbus:default
online         19:50:04 svc:/network/physical:default
online         19:50:06 svc:/system/identity:node
online         19:50:14 svc:/network/rpc/bind:default
online         19:50:18 svc:/system/hal:default
online         19:50:20 svc:/network/inetd:default
online         19:50:25 svc:/network/rpc/gss:default

Bootchart picture offers some details:





Certainly USB-booting yields the best results: for example on my DELL notebook I've booted MilaX from usb stick for 27 seconds. I've not included Moinak's code for compressed ramdisk support in this release, but I hope that I'll make it further.

Tuesday, January 20, 2009

Getting maximum info at booting

As I already written above, it's very useful to know all the current processes in boot time. You can get more interesting information. If we look at the contents of "live-devices-local" script in OpenSolaris LiveCD we'll see possibility to use iosnoop with output in logfile (iosnoop uses DTrace to monitor disk events in real time):

...
# Turn on I/O tracing if requested and possible
trace=`prtconf -v /devices|sed -n '/trace/{;n;p;}'|cut -f 2 -d\'`
if [ "$trace" = "on" ]; then
if [ -n "$mntpt" ]; then
outputfile="${mntpt}/traceout"
echo "Enabling I/O Tracing ..." > /dev/console
/opt/DTT/Bin/iosnoop -Deg > "$outputfile" 2> /dev/console &
# Wait for iosnoop to actually initialize
sleep 10
else
echo "Unable to enable I/O Tracing" > /dev/console
echo "Must have a mountable Solaris root slice on harddisk" > /dev/console
echo "to hold trace output" > /dev/console
fi
fi
...

Here's another fast way without using "live-devices-local" script: boot with "-m milestone=none" and next (I'm using opensnoop):

mount -F tmpfs -o size=32m swap /var/log
/opt/DTT/Bin/opensnoop -eg > /var/log/opensnoop.log &
svcadm milestone all

Except iosnoop a lot of helpful information can be gathered using other DTrace scripts (opensnoop,errinfo) with various arguments. For example, the opensnoop script considerably simplifies search of all files necessary for booting without errors.

Monday, January 12, 2009

Boot chart with help of DTrace and Python

Anonymous tracing allows to receive more interesting information about Solaris booting process. I use a simple D-script (boot.d):

#!/usr/sbin/dtrace -Cs
#pragma D option quiet
/* I need process pid, his forks and life time */
proc:::create
{
printf("<fork ppid=%d cpid=%d execname=%s time=%d />\n",
pid,args[0]->pr_pid,execname,`lbolt*10/ `hz);
}

proc:::exec-success
{
printf("<process pid=%d execname=%s time=%d />\n",
pid,execname,`lbolt*10/ `hz);
}

proc:::exit
{

printf("<end pid=%d execname=%s time=%d />\n",
pid, execname,`lbolt*10/ `hz);
}

Then I enable anonymous tracing:

dtrace -AFs /boot/boot.d
reboot

After reboot I write a logfile and disable anonymous tracing:

dtrace -ae -o bootlog
dtrace -A

Logfile looks like this:

CPU FUNCTION
0 | exec_common:exec-success <process pid=1 execname=init time=63 />
0 | cfork:create <fork ppid=1 cpid=4 execname=init time=66 />
0 | exec_common:exec-success <process pid=4 execname=ksh93 time=67 />
0 | exec_common:exec-success <process pid=4 execname=autopush time=87 />
0 | proc_exit:exit <end pid=4 execname=autopush time=92 />
0 | cfork:create <fork ppid=1 cpid=5 execname=init time=92 />
0 | exec_common:exec-success <process pid=5 execname=ksh93 time=92 />
0 | exec_common:exec-success <process pid=5 execname=soconfig time=94 />
...

Now by help of a python it's possible to parse logfile. I've written a small script bootchart.py for parsing and chart construction. It would be great to trace and draw the cpu part but this is not implemented yet.
To create boot chart you need run bootchart.py with logfile as an argument:

bootchart.py bootlog

This is a boot chart example for OpenSolaris 2008.11:


Wednesday, December 24, 2008

Boot charts for 2008.11 and snv101

Bootchart is a great tool for performance analysis and visualization of the Linux boot process. Eric Schrock and Dan Price worked on a Bootchart port using DTrace but I can't find any recipes on their blogs.
I've viewed bootchart source files for two days and by means of several hacks managed to receive boot charts for OpenSolaris. First of all I need to get uptime values in bootchart format (this is /proc/uptime content on linux). I've written the small utility (upt.c):

#include <sys/times.h>
#include <limits.h>
#include <dat/dat_platform_specific.h>

main {
struct tms ts;
clock_t t = times(&ts);

//we need jiffies from uptime value for bootchart
printf("%u\n",(unsigned long) ((DAT_UINT64) t*100 /CLK_TCK));
}

Now the main script for logging (/boot/bootchartd):

#!/usr/bin/bash

PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/gnu/bin:$PATH"

# mounting dir for logging
mount -F tmpfs -o size=32m swap /var/log/bootchart

# start time hack for java parser
echo "001" > /var/log/bootchart/ps.log
echo " PID PPID S %CPU COMMAND" >> /var/log/bootchart/ps.log
echo " 1 0 S 0.0 kernel" >> /var/log/bootchart/ps.log
echo >> /var/log/bootchart/ps.log

while true; do
# uptime jiffies
uptime=`/sbin/upt`
echo $uptime
# Log the command output and removing pid 0 for preventing "No processes found" error
eval "ps -e -o pid,ppid,s,pcpu,comm"|grep -v sched
echo
/usr/gnu/bin/sleep 0.2
done >> /var/log/bootchart/ps.log

Let’s create directory /var/log/bootchart:

mkdir /var/log/bootchart

Next I move /sbin/init to /bin:

mv /sbin/init /bin

and create a new init:

cat /sbin/init

#!/bin/sh

/boot/bootchartd &
exec /bin/init

Now it's possible to reboot. After booting I write a header file:

echo "title = Boot chart for $( hostname | sed q ) ($( date ))" > /var/log/bootchart/header
echo "system.uname = $( uname -srvm | sed q )" >> /var/log/bootchart/header
if [ -f /etc/release ]; then
echo "system.release = $( sed q /etc/release )" >> /var/log/bootchart/header
else
echo "system.release = $( sed 's/\\.//g;q' /etc/issue )" >> /var/log/bootchart/header
fi

and create boot chart:

java -jar bootchart.jar

Parsing /var/log/bootchart
Wrote image: ./bootchart.png

This was the first boot chart created for OpenSolaris 2008.11 (Intel CPU 2.26GHz 512mb RAM). No disk and cpu utilization information yet:


Boot chart for OpenSolaris 2008.11
Here the boot chart for snv101:


Boot chart for snv101

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" pro...