Showing posts with label OpenSolaris. Show all posts
Showing posts with label OpenSolaris. Show all posts

Tuesday, July 13, 2010

Sample client for istatd

IPhone owners can use a great app for servers monitoring - istat. On the server you must install the istatd daemon. More information can be read here: http://blogs.sun.com/karim/entry/monitoring_opensolaris_from_an_itouch.
Here an example of a console client for istatd, you can use this data for plotting, etc:
$ gcc -o istatd_client istatd_client.c -lsocket -lnsl
$ ./istatd_client
Usage: istatd_client <server_ip> <server_port> <server_code>
Example output from OpenSolaris server:

/istatd_client XX.XXX.XX.X 5109 12345
Connected to XX.XXX.XX.X on port 5109

<?xml version="1.0" encoding="UTF-8"?><isr ready="1"></isr>
<?xml version="1.0" encoding="UTF-8"?><isr pl="2" ath="0" ss="6" c="7788968" n="7788967"></isr>
<?xml version="1.0" encoding="UTF-8"?><isr ds="8" ts="8" fs="8" rid="1"><CPU><c id="-1" u="1" s="3" n="0"></c></CPU><NET if="1"><n id="-1" d="12545352948" u="276928235931" t="1279010768"></n></NET><MEM w="1568" a="326" i="0" f="190" t="2086" su="51" st="1043" pi="79363" po="17312"></MEM><LOAD one="0.230469" fv="0.238281" ff="0.234375"></LOAD><UPT u="7788967"></UPT><DISKS><d n="/" uuid="rpool/ROOT/opensolaris-1" f="43352" p="21.1999"></d><d n="/hosting" uuid="hosting" f="134024" p="4.63293"></d></DISKS></isr>
...

Looking through istatd code, you can easily recognize what's mean all these variables (for example "u" in <CPU> denotes cpu_user usage).

Wednesday, June 16, 2010

Osstat 0.3

Osstat Gnome applet now reaches version 0.3 - minor fixes, new graphs and some features.



Feel free to optimize code or change parts to use better ways.
Download here.

Thursday, April 15, 2010

Using ddu scripts

Have you ever looked in the "/usr/ddu" directory? Console-lovers can use some of these scripts and get the almost same output as from the "ddu" graphic utility. For example, I changed the probe.sh script a bit and now I can get ddu-like info from console:

(root@elvis)# ./ddu.sh
AUDIO
Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller : audio810
CPU
1 X Intel(R) Celeron(R) CPU 2.26GHz, 1-core : ---
CD_DVD
Intel Corporation 82801DB (ICH4) IDE Controller : pci-ide
Optiarc DVD RW AD-5200A : 0
MEMORY
1G (512M + 512M) ; 2G maximum : ---
NETWORK
Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ : rtls
STORAGE
Intel Corporation 82801DB (ICH4) IDE Controller : pci-ide
USB
Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 : uhci
Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 : uhci
Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 : uhci
Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller : ehci
VIDEO
Intel Corporation 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device : i915
OTHERS
PC standard floppy disk controller : fdc
16550A-compatible COM port : asy
ECP printer port : ecpp
PS/2 Port for PS/2-style Mice : mouse8042
System keyboard : kb8042
(root@elvis)#

Thursday, November 5, 2009

OpenSolaris Sparc snv125 LiveCD

Following numerous requests from users I've prepared Sparc LiveCD based on osol-1002-125-ai-sparc.iso (see my previous post). Please remember that this iso is UNOFFICIAL version, I've created it only for my tests. With this iso you can test OpenSolaris on your hardware, AI tools or you can install system from this LiveCD manually, using steps from my old posts (i.e. you need to create zpool, copy all LiveCD contents to rootfs, disable live-media services, change vfstab and etc).
Temporarily iso is here.

Wednesday, September 16, 2009

How to make a sparc Live CD from AI

That's what I did to get the LiveCD from last AI iso.
On sparc machine:

# mkdir -p /opt/livecd/s0.
# mount -F hsfs `lofiadm -a osol-1002-122-ai-sparc.iso` /mnt

I copied all iso's content to s0 and then I've unpacked /opt/livecd/s0/boot/boot_archive with root_archive to /opt/livecd/tmp.
Next:

# cd /opt/livecd/tmp
# echo snv122 > .volumeid
# mv .autoinstall .livecd

I've also removed last block about keyboard configuration and gdm in /lib/svc/method/live-fs-root.
Next I've created lofi directory in /opt/livecd/tmp/dev and symlink in this directory to ../../devices/pseudo/lofi@0:1 (this is required for mounting solaris.zlib).
I took hsfs.bootblock from SXCE DVD and put it in boot directory.

# cd /opt/livecd/s0/boot/
# root_archive pack boot_archive /opt/livecd/tmp

Script root_archive required small hack for boot-archive size - I've added line "size=130000" before "/usr/sbin/mkfile ${size}k "$TMR".
Next I've created symlinks for boot_archive in /opt/livecd/s0/platform/sun4v and /opt/livecd/s0/platform/sun4u
Now iso:

# cd /opt/livecd/
# mkisofs -G s0/boot/hsfs.bootblock -B ... -l -ldots -R -N -D -V snv122 -o /opt/sparc_snv122.iso s0/

Live CD boots on my old Ultra 60 (you can see some warnings and services errors but that's another story):


Tuesday, July 14, 2009

Minimal OpenSolaris SPARC install

Using previous instructions I've successfully installed opensolaris 2009.06 on my TestFarm (thanks, Jim) T2000 from existing Nevada b98.
Steps are identical: my machine have 4 disks, so I've prepared third disk (c0t2d0) for installation (I take 4gb):

Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 824 4.00GB (825/0/0) 8395200
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 14086 68.35GB (14087/0/0) 143349312
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0

Next steps (it's fast):

zpool create opensolaris c0t2d0s0
zfs create opensolaris/rootfs
zfs set compression=on opensolaris/rootfs
zfs set mountpoint=legacy opensolaris/rootfs
mkdir /zfsroot
mount -f zfs opensolaris/rootfs /zfsroot

Here's minimal list of packages for my T2000 (sun4v):

SUNWcsd
SUNWcs
SUNWcsl
SUNWcakr
SUNWcar
SUNWcfcl
SUNWckr
SUNWcnetr
SUNWcurl
SUNWefc
SUNWerid
SUNWesu
SUNWfctl
SUNWpd
SUNWfchba
SUNWfruid
SUNWgnu-idn
SUNWgss
SUNWgssc
SUNWinstall-libs
SUNWipf
SUNWipkg
SUNWkey
SUNWkvm
SUNWldom
SUNWlexpt
SUNWlibC
SUNWlibms
SUNWlibsasl
SUNWloc
SUNWlxml
SUNWmd
SUNWnfsc
SUNWnfsckr
SUNWopenssl
SUNWperl584core
SUNWpicl
SUNWpool
SUNWpr
SUNWsmapi
SUNWrmodu
SUNWssh
SUNWsshcu
SUNWsshd
SUNWPython
SUNWpython-pyopenssl
SUNWTcl
SUNWTk
SUNWadmap
SUNWadmlib-sysid
SUNWadmr
SUNWbash
SUNWbip
SUNWbzip
SUNWtecla
SUNWtls
SUNWtoo
SUNWwbsup
SUNWxwrtl
SUNWzfs
SUNWzfskr
SUNWzlib
SUNWzone
SUNWintgige
entire

I already have pkg built and installed from sources on my Nevada. Now network installation:

pkg image-create -F -f -a opensolaris.org=http://pkg.opensolaris.org /zfsroot

cd /zfsroot

for pkg in `cat pkg.lst`; do pkg install --no-refresh --no-index $pkg; done

echo "etc/zfs/zpool.cache" >> /zfsroot/boot/solaris/filelist.ramdisk

zpool set bootfs=opensolaris/rootfs opensolaris

echo "opensolaris/rootfs - / zfs - no -" >> /zfsroot/etc/vfstab

mkdir -p /opensolaris/platform/sun4v

cp /zfsroot/platform/sun4v/bootlst /opensolaris/platform/sun4v/

cp /zfsroot/lib/svc/seed/global.db /zfsroot/etc/svc/repository.db

devfsadm -R /zfsroot

bootadm update-archive -R /zfsroot

installboot -F zfs /platform/sun4v/lib/fs/zfs/bootblk /dev/rdsk/c0t2d0s0

Booting:

ok boot disk2
...
Sun Fire T200, No Keyboard
Copyright 2008 Sun Microsystems, Inc. All rights reserved.
OpenBoot 4.28.9, 16256 MB memory available
...
Boot device: /pci@780/pci@0/pci@9/scsi@0/disk@2 File and args:
SunOS Release 5.11 Version snv_111b 64-bit
Copyright 1983-2009 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
Hostname: unknown
Configuring devices.
Loading smf(5) service descriptions: 84/84
Reading ZFS config: done.
Mounting ZFS filesystems: (2/2)

unknown console login: root
Password:
Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008
root@unknown:~# df -h
Filesystem size used avail capacity Mounted on
opensolaris/rootfs 3.9G 630M 3.3G 16% /
/devices 0K 0K 0K 0% /devices
/dev 0K 0K 0K 0% /dev
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 12G 176K 12G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
fd 0K 0K 0K 0% /dev/fd
swap 12G 0K 12G 0% /tmp
swap 12G 16K 12G 1% /var/run
opensolaris 3.9G 60K 3.3G 1% /opensolaris


This install take only 630 mb. Now I can adjust my network settings and install additional packages.

Thursday, July 9, 2009

Get detailed disk info with Caiman libraries

Using Caiman libraries you can write small programs which can be very useful in sysadmin's daily work or can help making your own installer. For example, using libtd (Target Discovery) library you can get info about system disks and partitions very fast. Here's an example of using libtd test program (test_td):

# ./test_td -d
Disk discovery
Total number of disks: 3
---------------------------------
num | name| ctype|size [MB]|
---------------------------------
1 | c2t0d0| usb| 976|
2 | c0d0| ata| 76350|
3 | c1d0| ata| 38166|
---------------------------------

# ./test_td -p all
Partition discovery for all disks
-------------------------------------
num | name| active| ID| lswp|
-------------------------------------
1 | c2t0d0p1| Yes| BF| No|
2 | c0d0p1| Yes| BF| No|
3 | c1d0p3| No| 83| No|
4 | c1d0p2| Yes| 83| No|
5 | c1d0p1| No| 82| Yes|
-------------------------------------

Now verbose output:

# ./test_td -d -v
Disk discovery
Total number of disks: 3
-------------------------------------------------------------------------------
num | name| vendor| ctype| mtype| rem| lbl| bsize|#of blocks|size [MB]|
-------------------------------------------------------------------------------
1 | c2t0d0| Multi| usb| FIXED| Yes| VF| 512| 1999872| 976|
2 | c0d0| unknown| ata| FIXED| No| VF| 512| 156364992| 76350|
3 | c1d0| unknown| ata| FIXED| No| VF| 512| 78164352| 38166|
-------------------------------------------------------------------------------

# ./test_td -p all -v
Partition discovery for all disks
---------------------------------------------------------------------
num | name| active| ID| lswp| 1st block|#of blocks|size [MB]|
---------------------------------------------------------------------
1 | c2t0d0p1| Yes| BF| No| 2048| 1996800| 975|
2 | c0d0p1| Yes| BF| No| 16065| 156344580| 76340|
3 | c1d0p3| No| 83| No| 20547135| 57609090| 28129|
4 | c1d0p2| Yes| 83| No| 1012095| 19535040| 9538|
5 | c1d0p1| No| 82| Yes| 63| 1012032| 494|
---------------------------------------------------------------------

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.

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:


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

Monday, December 22, 2008

Installing pkg without pkg

Unfortunately I can't install some IPS packages without dependences. Christopher Bergström has written a small shell script for sunstudio installation. Some time I've tested it and have created the ruby version for installation of any package. This script does not process "driver" tag in manifest but in the rest is suitable for installation and a bit more exact than shell script. You can view the source code (getpkg.rb) here.
Sample usage (I want to install SUNWipkg to /opt/ipkg):
# getpkg inst_dir manifest_url 
getpkg.rb /opt/ipkg http://pkg.opensolaris.org/release/manifest/0/SUNWipkg%400.5.11%2C5.11-0.101%3A20081104T032047Z 

Monday, December 15, 2008

Preparing small miniroot with zfs and ssh

This is instructions for building smallest OpenSolaris miniroot (standalone RAM) with ssh and zfs.
I use the receptions familiar to funs of minimization according to Jim Connors's framework. But now we will use IPS for installation of packages and we should delete files of some packages manually ("--install" or "--uninstall --without-deps" not yet implemented in pkg).
Well, I'm running Solaris Express and will use "/opt/test" as working dir. Here are the packages for small miniroot (/opt/pkg.list):
SUNWcsd
SUNWcs
SUNWcakr
SUNWcar
SUNWckr
SUNWcnetr
SUNWcsl
SUNWesu
SUNWgss
SUNWgssc
SUNWkey
SUNWkvm
SUNWlibms
SUNWlibsasl
SUNWloc
SUNWlxml
SUNWnfsc
SUNWnfsckr
SUNWopenssl
SUNWos86r
SUNWpr
SUNWpsdcr
SUNWpsdir
SUNWrmodr
SUNWbip
SUNWsmapi
SUNWssh
SUNWsshcu
SUNWsshd
SUNWtecla
SUNWtls
SUNWtoo
SUNWusb
SUNWusbs
SUNWzfs
SUNWzfskr
SUNWzlib
SUNWzone
SUNWbash
SUNWrtls

As you can see, I have Realteck network adapter (SUNWrtls). Let's go:
# working dir
export ROOTDIR=/opt/test

# create the packaging db (pkg already installed on Nevada)
/usr/bin/pkg image-create -F -a opensolaris.org=http://pkg.opensolaris.org ${ROOTDIR}

cd ${ROOTDIR}
for pkg in `cat ../pkg.list`; do
/usr/bin/pkg install ${pkg}
done

But after that we have some additional packages because of dependences. Now we need to remove these unneeded packages (/opt/rm.txt) :
SUNWaudd
SUNWgccruntime
SUNWinstall-libs
SUNWmd
SUNWpicl
SUNWpool
SUNWwbsup

I cannot delete some packages and will use "pkg contents" command:
for pkg in `cat ../rm.txt`; do
pkg contents -m $pkg|grep file|sed -e 's/.*path=//; s/pkg.csize.*//'|\
awk '{print "./"$1}';
pkg contents -m $pkg|grep link|sed -e 's/.*path=//; s/target.*//'|\
awk '{print "./"$1}';
done > files.tmp

We need "libmeta.so" library for devfsadm:
cat files.tmp|sed 's/.*libmeta.*//g' > files.list

Now I delete packages files:
for file in `cat ../files.list `; do rm -rf $file; done

Basic miniroot configuration:
cd ${ROOTDIR}

# Copy usr/sfw/lib/libwrap.so.1 to usr/lib
cp ${ROOTDIR}/lib/svc/seed/global.db ${ROOTDIR}/etc/svc/repository.db

rm ${ROOTDIR}/usr/lib/libcrypto.so*
cp ${ROOTDIR}/usr/sfw/lib/libcrypto.so.0.9.8 ${ROOTDIR}/usr/lib


# Fix etc/vfstab
echo "/devices/ramdisk:a - / ufs - no nologging" >> ${ROOTDIR}/etc/vfstab

# Set the timezone
echo "TZ=US/Eastern" > ${ROOTDIR}/etc/TIMEZONE

# Set hostname
echo "small" > ${ROOTDIR}/etc/nodename

# Create /etc/inet/hosts and /etc/inet/ipnodes file
echo "127.0.0.1 localhost loghost" > ${ROOTDIR}/etc/inet/hosts
echo "192.168.1.1 small" >> ${ROOTDIR}/etc/inet/hosts
echo "::1 localhost loghost" > ${ROOTDIR}/etc/inet/ipnodes
echo "127.0.0.1 localhost loghost" >> ${ROOTDIR}/etc/inet/ipnodes
echo "192.168.1.1 small" >> ${ROOTDIR}/etc/inet/ipnodes

# Set nsswitch.conf
cp ${ROOTDIR}/etc/nsswitch.files ${ROOTDIR}/etc/nsswitch.conf

# Set IP Address
echo "small" > ${ROOTDIR}/etc/hostname.rtls0

# Set up default route
echo "192.168.1.200" > ${ROOTDIR}/etc/defaultrouter

# Set the environment variables for svccfg.
SVCCFG_DTD=${ROOTDIR}/usr/share/lib/xml/dtd/service_bundle.dtd.1
SVCCFG_REPOSITORY=${ROOTDIR}/etc/svc/repository.db
SVCCFG=/usr/sbin/svccfg

export SVCCFG_DTD SVCCFG_REPOSITORY SVCCFG

${SVCCFG} import ${ROOTDIR}/var/svc/manifest/milestone/sysconfig.xml

# turnoff boot-archive, manifest-import
${SVCCFG} -s system/boot-archive setprop start/exec=:true
${SVCCFG} -s system/manifest-import setprop start/exec=:true
${SVCCFG} -s network/rpc/bind delpg sysidtool
${SVCCFG} -s system/metainit:default setprop general/enabled=false

# Here's what needed to add ssh
${SVCCFG} import ${ROOTDIR}/var/svc/manifest/system/cryptosvc.xml
${SVCCFG} -s system/cryptosvc:default setprop general/enabled=true

${SVCCFG} import ${ROOTDIR}/var/svc/manifest/network/inetd.xml
${SVCCFG} -s network/inetd:default setprop general/enabled=true

${SVCCFG} import ${ROOTDIR}/var/svc/manifest/network/rpc/gss.xml
${SVCCFG} -s network/rpc/gss:default setprop general/enabled=true

${SVCCFG} import ${ROOTDIR}/var/svc/manifest/network/ssh.xml
${SVCCFG} -s network/ssh:default setprop general/enabled=true

# Creating RSA/DSA keys for ssh
/usr/bin/ssh-keygen -q -f ${ROOTDIR}/etc/ssh/ssh_host_rsa_key -t rsa -N ''
/usr/bin/ssh-keygen -q -f ${ROOTDIR}/etc/ssh/ssh_host_dsa_key -t dsa -N ''

# Edit etc/ssh/sshd_config to allow ssh to root account
ex -s ${ROOTDIR}/etc/ssh/sshd_config > /dev/null <<> /dev/null

# Remove packaging, xpg4, sfw - you can remove more but be carefully
rm -rf var/sadm/* var/pkg/*
rm -rf usr/xpg4 usr/sfw

Now I prepare a miniroot image:
# we need freespace ~10mb
size=`/usr/bin/du -ks ${ROOTDIR}|/usr/bin/nawk '{print $1+10240}'`

/usr/sbin/mkfile ${size}k /opt/miniroot
lofidev=`/usr/sbin/lofiadm -a /opt/miniroot`

# get the miniroot raw device and create a filesystem on it
rlofidev=`echo $lofidev |sed s/lofi/rlofi/`
/usr/sbin/newfs -m 0 $rlofidev

# mount ufs filesystem
/usr/sbin/mount -o nologging $lofidev /mnt

/usr/bin/find .  /usr/bin/cpio -pdum /mnt
/usr/sbin/umount /mnt

/usr/sbin/lofiadm -d /opt/miniroot
/usr/bin/7za a -tgzip -mx=9 /opt/miniroot.gz /opt/miniroot

Done. Now I have a small OpenSolaris 2008.11 miniroot with ZFS and SSH (32601K gzipped - I've also removed a number of unnecessary binaries from SUNWcs). It's possible to make an image even less.

Thursday, December 11, 2008

Creating 90mb LiveCD using Distribution Constructor

Continuing a theme, it's possible to create a 90mb iso (minimal working LiveCD without Gnome and X) using the Distribution Constructor - command-line tool for building preconfigured, bootable OpenSolaris images. In the OpenSolaris 2008.11 release, this tool takes an XML manifest file as input, and builds an ISO image that is based on the parameters specified in the manifest file. I'm running Solaris Express and will use old-format configuration file.
I have added additional packages (SUNWgzip, SUNWgrub, SUNWslim-utils) in my short list (see post of December 08). Note: I need only "rtls" driver for this test so you should add packages for your network adapters. Besides, I use checkpoints as it will be necessary to change a script "/lib/svc/method/live-fs-root".
I have downloaded Distribution Constructor kit:
# hg clone ssh://anon@hg.opensolaris.org/hg/caiman/distro_constructor

I only have changed the list of packages and use my own checkpoint in "build_dist.bash":
# ./build_dist.bash small.conf

After installation of packages I have a pause (thanks to checkpoint). Now it's necessary to remove string "/usr/sbin/set_lang" in "/lib/svc/method/live-fs-root" and set "system/coreadm enabled=false" in generic_live.xml (otherwise there will be an errors after booting). It's only first test, you can change more. Then I finish creating the image. In DC output there will be some errors - the majority of them concerns Gnome which is not present.
I boot LiveCD in virtual machine - at first sight it works perfectly .
The test is fulfilled: for my list of packages the final iso has the size 90mb (but you can add any packages which are necessary for you).

Tuesday, December 9, 2008

OpenSolaris: life without Gnome

I have console OpenSolaris installed (see my post of December 08). But I have forgotten to install the most valuable package:
pkg install SUNWzfs-auto-snapshot

Now I can install X:
pkg install SUNWxorg-server
pkg install SUNWxorg-xsvc
pkg install SUNWxorg-agp
pkg install SUNWxorg-graphics-ddx
pkg install SUNWxorg-client-programs
pkg install SUNWxwfsw
pkg install SUNWxwopt
pkg install FSWxorg-fonts

After installation I run "xinit" and get xterm. However it would be better to install some minimalistic window manager, for example, dwm.
pkg install SUNWwget
wget http://code.suckless.org/dl/dwm/dwm-5.3.1.tar.gz

Gcc,binutils,gmake and headers are required:
pkg install SUNWxorg-headers
pkg install SUNWgmake
pkg install SUNWbinutils
pkg install SUNWgcc

I love vim. Also I need gzip:
pkg install SUNWvim
pkg install SUNWgzip


If you plan to compile some other apps, I advice to install substudio:
pkg install sunstudioexpress

Next I unpack archive, correct config.h and compile dwm. It's possible to start dwm xsession from smf. You can look how it's made in BeleniX or MilaX.


As a result I got system with short boot time and an easy and fast window manager.
At the end I need usual user:
mkdir /home
useradd -d /home/me -m -s /bin/ksh -c "System Developer" me
passwd me

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...