Solaris OpenSolaris
Judy Chen's Blog
Main | Next page »
星期四 四月 24, 2008
Setup DHCP server on Solaris
Today I wanted to setup a DHCP server on a machine installed with Solaris Express. Within just a few minutes, it's done. :) Solaris has improved a lot on operability, on user experience.

To do it, run "/usr/sadm/admin/bin/dhcpmgr" and follow the step by step instructions. Pretty easy, ahha.
Posted at 11:17上午 四月 24, 2008 by judy in Solaris  |  评论[0]

星期二 四月 15, 2008
利用BrandZ在Solaris上运行Linux应用程序
Solaris提供了丰富的兼容性,其中之一就是可在其上直接运行Linux应用程序,而无需对Linux应用程序做任何修改,实现这个功能的机制包括BrandZXen。这两者之间的区别在于Xvm允许在机器上跑整个Linux操作系统,包括kernel;而BrandZ仅允许运行Linux用户态的应用程序,底层跑的仍然是Solaris核心。本文将教你如何一步步地创建出一个运行Linux应用程序的BrandZ。

  1. 以超级用户身份登陆或su

  2. 创建zone
    # zonecfg -z centos
    centos: No such zone configured
    Use 'create' to begin configuring a new zone.
    zonecfg:centos>  create -t SUNWlx
    zonecfg:centos> set zonepath=/export/centos_root
    zonecfg:centos> add net
    zonecfg:centos:net> set address=192.168.0.2/24
    zonecfg:centos:net> set physical=e1000g0
    zonecfg:centos:net> end
    zonecfg:centos> commit
    zonecfg:centos> exit


  3. 安装lx zone
    • OpenSolaris网站上下载CentOS Linux

    • 以下载的tar包为源安装CentOS
      # zoneadm -z centos install -d /export/centos_fs_image.tar
      A ZFS file system has been created for this zone.
      Installing zone 'centos' at root directory '/export/centos_root'
      from archive '/export/centos_fs_image.tar'

      This process may take several minutes.

      Setting up the initial lx brand environment.
      System configuration modifications complete.
      Setting up the initial lx brand environment.
      System configuration modifications complete.

      Installation of zone 'centos' completed successfully.

      Details saved to log file:
          "/export/centos_root/root/var/log/centos.install.9025.log"


  4. 检查安装后zone的状态
    # zoneadm list -iv
      ID NAME             STATUS     PATH                           BRAND    IP   
       0 global           running    /                              native   shared
       - centos           installed  /export/centos_root            lx       shared


  5. 启动安装好的zone
    # zoneadm -z centos boot
    chichi# zoneadm list -iv
      ID NAME             STATUS     PATH                           BRAND    IP   
       0 global           running    /                              native   shared
       9 centos           running    /export/centos_root            lx       shared


  6. Login
    # zlogin centos

    要运行X应用程序的话,用ssh进行X输出重定向
    # ssh -X centos

  7. 和网络配置相关的设置
    • 设置DNS
      $ cat /etc/sysconfig/network
      NETWORKING=yes
      HOSTNAME=centos
      GATEWAY=192.168.0.1
      $ cat /etc/resolv.conf
      nameserver 192.168.0.1

  8. 安装附加软件包
    # yum install libstdc++

参考链接:
Posted at 05:40下午 四月 15, 2008 by judy in Solaris  |  评论[0]

星期五 三月 21, 2008
打造Source Insigh风格的XEmacs

Source Insight是Windows平台上一款功能强大的代码浏览工具,提供了方便的导航功能。在Solaris上,利用xemacs + ecb + cscope,可以轻松打造出类似Source Insight风格的代码编辑/浏览器。先看一下完成后的屏幕截图。下面是具体的打造过程。

一、安装软件包

首先,安装来自blastwave.org的pkg-get。这里有详细的安装步骤。

其次 ,安装xemacs。

# /opt/csw/bin/pkg-get -i xemacs
# /opt/csw/bin/pkg-get -i xemacs_packages>

XEmacs将被安装到/opt/csw目录下。

要使能ecb,启动xemacs后键入M-x ecb-activate。查看更多帮组信息 ,键入M-x ecb-show-help。

在这里再介绍一下xemacs的启动文件。XEmacs每次启动的时候都要读取启动文件的内容,启动文件通常是~/.emacs或~/.xemacs/init.el,其中包含了XEmacs界面风格等基本配置信息。在XEmac中通过Options->Edit Init File即可编辑该文件。

二、CScope

  1. 下载xscope.el并放到~/.xemacs目录下,在启动文件中加入如下文本。

    (setq cscope-do-not-update-database t)
    (load-file "~/.xemacs/xcscope.el")
    (require 'xcscope)


  2. 在源码目录下创建cscope数据库
    # cscope -b
    "-b"选项表示只生产cscope数据库,不启动cscope

  3. 使用技巧
    Index files: C-c s I
    Find global definition: C-c s d
    Find symbol definition: C-c s s
    Find this file: C-c s f
    Find functions calling this function: C-c s c
    Find functions called by this function: C-c s C
    Find this pattern: C-c s e
    Find this text string: C-c s t
    Find files including this file: C-c s i

三、语法高亮显示 

如果偏好浅色背景,在启动文件中加入如下文本。若偏好深色背景的话,则可在启动文件中加入这段文本

另外,Emacs颜色可用字符串(red)或16进制数(0xff0000)表示。这里有一个详细的Emacs字符名称和颜色对照表。

四、 其他优化设置

在菜单中添加一个History(最近打开的文件列表)菜单项。下载mas-file-history到~/.xemacs目录下,并在启动文件中叫如如下文本。

(load-file "~/.xemacs/mas-file-history.el") ; creates a menu with a list of recently opened files
(setq mas-file-history-menu-path nil)       ; put the menu at the top of the XEmacs window
(setq mas-file-history-menu-title "History"); the name of the menu
(with-temp-buffer)                          ; this hack seems to be necessary

用“%”匹配对应的括号。

(global-set-key "%" 'match-paren)

(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))

拼写检查

安装aspell:pkg-get -i aspell
在启动文件中加入如下文本:(setq-default ispell-program-name "aspell")

Posted at 05:38下午 三月 21, 2008 by judy in General  |  评论[0]

星期三 一月 23, 2008
Getting Started with ZFS

I installed Solaris Developer Release 1/08 on my machine and tried with ZFS. I have to say that I was impressed by the powerful functionality and easy usage model of ZFS. I used to maintain a website server which is based on LAMP. Now I would take SAMP + ZFS as a better solution. In SDR 1/08, Web Stack Admin provides easy access to Apache2, MySQL and PHP, while ZFS shows immense scalability, great data integrity and simple administration. SAMP would be another topic. Here I just want to focus on how to start using ZFS.


After installation, the default root system is UFS. ZFS boot is still in work. I converted Solaris slice c0d0s7, which is mounted on /export to ZFS. Before creating zfs pools, remove "/dev/dsk/c0d0s4 ..." entry from /etc/vfstab and unmount it.

# umount /export


Now create a ZFS pool.

# zpool create zfs_export c0d0s7

invalid vdev specification
use '-f' to override the following errors:
/dev/dsk/c0d0s7 contains a ufs filesystem.

The command failed because the slice contained a ufs filesystem. Add -f option to zpool create command.

# zpool create -f zfs_export c0d0s7
# zpool list

NAME         SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
zfs_export  66.5G   111K  66.5G     0%  ONLINE  -


Change mount point to /export.

# zfs set mountpoint=/export zfs_export
# zfs list
NAME           USED  AVAIL  REFER  MOUNTPOINT
zfs_export     117K  65.5G    18K  /export


Share /export via NFS as read/write.

# zfs set sharenfs=on zfs_export
# share

zfs_export@zfs  /export   rw   ""


Share /export via SMB.

# svcadm enable -r smb/server
   
svcadm: svc:/milestone/network depends on svc:/network/physical, which has multiple instances.
# svcs | grep smb
online         13:28:03 svc:/network/smb/server:default
# zfs set sharesmb=on zfs_export
# zfs set sharesmb=name=myshare zfs_export
i# sharemgr show -vp                      

default smb=() nfs=()
zfs
    zfs/zfs_export nfs=()
          /export
                  myshare=/export
                  zfs_export=/export


Recover 'rm' ed files?

AFAIK, the answer is noway.


Make zfs root filesystem and boot from it?

Please refer to: Manuual Setup to Boot ZFS on x86


Useful zfs links

Official Getting Started
7 Easy Tips for ZFS Starters
ZFS Community at OpenSolaris.org


Posted at 04:49下午 一月 23, 2008 by judy in Solaris  |  评论[2]

星期一 一月 07, 2008
Creating ad-hoc wireless connection with Solaris
I just released Solaris Atheros driver ath 0.7(source and binary) to OpenSolaris laptop community. The notable feature of this new version is ad-hoc(IBSS) mode support. The released package consists of two parts:

With ad-hoc mode support, now you can connect two laptops(PCs)  together directly via wireless connection.

What's Ad-Hoc Network

Ad-hoc network is also referred to as Independent BSS(IBSS). Stations in IBSS network communicate with each other directly. It's in contrast to Infrastructure BSS (sometimes briefly called BSS), in which a special node known as access point(AP)  manages communication among other nodes. Below is an illustration.

ibss & bss
Figure 1 Independent and Infrastructure BSS

Minimal configuration, flexibility and quick deployment make ad-hoc networks suitable for emergency solution. One typical use is to create an ad-hoc network for sharing data in a conference room to support the meeting. When the meeting ends, the ad-hoc network is dissolved.

How to Configure

Ath 0.7 requires OpenSolaris build 68 or later version.

Firstly, download and install ath 0.7.

# wget http://opensolaris.org/os/community/laptop/downloads/ath-0.7-pkg.tar.gz
# gunzip -c ath-0.7-pkg.tar.gz | tar xf -
# pkgadd -d ./SUNWatheros SUNWatheros

On the first laptop, create an IBSS with specific ESSID(wireless network name) and WEP encryption. Even WEP is proved to be unsafe, it's better than none.
# ifconfig ath0 plumb
# wificonfig -i ath0 setparam createibss=yes essid=mywifi encryption=wep wepkey1=1234567890

Currently, dladm doesn't support IBSS mode. So please use wificonfig to create and connect to an ad-hoc network.

On the second laptop, you'll find previously created ad-hoc network in scan results. connect to it as below.
# wificonfig scan
# wificonfig -i ath0 setparam essid=mywifi bsstype=ibss encryption=wep wepkey1=1234567890

Now the two computers are connected via ad-hoc network.

To get these two computers communicated with each other, manually setup IP address for each one as below:
# ifconfig ath0 192.168.xxx.xxx netmask + up
Ok, here you go.

Known Issue

Solaris IBSS doesn't support WPA yet. Also it's not on our todo list. If it's an important feature for you, please drop a note to OpenSolaris laptop community.


Posted at 01:44下午 一月 07, 2008 by judy in Wireless  |  评论[0]

星期六 十二月 29, 2007
Solaris on MacBook
I've got another MacBook Pro with Intel 2GHz Core 2 Duo CPU. It's installed with Mac OS X 10.4, but shipped with a Leopard installation DVD. Having heard so much about Leopard (good and bad), the first thing I did is upgrading.

Next thing is to install Solaris Developer Release 1/08 on MacBook. The installation failed two times, and succeeded at the third time. It cost me almost 4 hours. Below is a summary of the installation.

Step one, re-partition the hard disk. Bootcamp 2.0 has already been included in Leopard. Ran Finder->Applications->Utilities->Boot Camp Assistant to create a Windows partition. Changing the partition size by dragging the bar between two areas. Or alternatively, command line tool diskutil can also be used to shrink the HFS+ partition. Given a 150G hard disk, run below commands in a termal.
$ sudo -i
# diskutil resizeVolume disk0s2 100G "MS-DOS FAT32" 48G

Step two, change EFI partition's ID to something that Solaris doesn't understand. I did it in running Leopard. For safety, you may restart and boot from the OSX installation CD. When the installer starts, run terminal from tool menu. Umount the disk
# umount /dev/disk0
Change EFI partition's ID.
# fdisk -e /dev/rdisk0
setpid 1
AF
write
quite

Step three, install rEFlt show GUI boot menu. Download rEFlt form here.

Step four, change Windows partition to Solaris2 partition. Insert Solaris Express install CD. Reboot and hold on "C" key to boot from CD. Select "Solaris Express" from grub menu. On the next screen, Choose "4. .Solaris Interactive Text (Console session)". Continue with the installation until you see screen titled with "Solaris Interactive Installation".  press F5 to exit installation. Then you'll be dropped to a terminal. Run format to re-create a Solaris2 partition.
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1d0 <DEFAULT ... >
...
Specify disk (enter its number): 0
format> fdisk
# Delete the third Windows partition and create a Solaris2 partition
# Enter 5 to save and exit fdisk
format> quit

Step five, run install-solaris on the terminal to restart the installation. Almost at the end, the installation will fail. It's an unknown bug 6413235. Exit the installation program to enter a terminal. Do workaround for 6413235.
# mount -o remount,rw /
# cd /sbin
# mv fdisk fdisk.real
# cat >fdisk
#!/bin/sh
echo "$*" | grep -- "-F" > /dev/null
if [ $? = 1 ] ; then
    /sbin/fdisk.real $*
fi
CTRL-D
# chmod +x fdisk
Restart the installation by running install-solaris. Now you can finish the installation successfully.

Restart the Mac, now you'll see Solaris from the rEFlt boot menu, which is shown as a Linux penguin icon.

For how to make wired and wireless LAN work, please refer to my previous blog.

Posted at 01:02下午 十二月 29, 2007 by judy in Solaris  |  评论[6]

星期四 十二月 20, 2007
Solaris如何配置SpeedStep

1. 什么是SpeedStep

为了延 长笔记本电脑上电池的使用寿命,Intel的CPU采用了称为SpeedStep的技术,SpeedStep技术动态改变CPU的倍频以降低其工作频率, 甚至降低核心电压。这样当CPU工作在较低频率时,就可以节省耗电量,减小发热,以及降低风扇噪音。起初支持SpeedStep技术的CPU有两种工作模 式,一种是外接交流电,CPU工作在较高频率的最优性能模式(maximum performance mode);另一种是用电池供电,CPU的工作在较低频率的电池优化模式(battery-optimized mode)。笔记本根据外接电源自动选择工作模式。随后,Intel发布了增强的SpeedStep技术(Enhanced SpeedStep),系统根据当前负载自动改变CPU的频率和核心电压。在此基础上,Intel进一步增强了SpeedStep技术(Enhanced Improved SpeedStep),CPU支持多种工作频率和核心电压,在两种基本工作模式之间增加了多种中间模式,系统根据当前负载自动切换CPU的工作模式。

2. Solaris上配置SpeedStep


OpenSolaris Express/Developer Edition支持Enhanced SpeedStep技术。其支持的Intel CPU包括

有一个简单的方法判断某CPU是否支持SpeedStep技术,就是运行kstat查看cpu_info模块的supported_frequencies_Hz属性。
$ kstat -m cpu_info -s supported_frequencies_Hz
module: cpu_info instance: 0
name: cpu_info0 class: misc
supported_frequencies_Hz 2800000000:3200000000


module: cpu_info instance: 1
name: cpu_info1 class: misc
supported_frequencies_Hz 2800000000:3200000000
如上所示,如果CPU支持的频率数多于一个,就说明Solaris支持该CPU上的SpeedStep技术。

那么如何激活SpeedStep呢?在/etc/power.conf配置文件中,修改关键字cpupm和cpu-threshold如下。
cpupm            enable
cpu-threshold 15s
这样,如果系统空闲超过15秒,CPU就会降低工作频率。用kstat检查cpu_info模块的current_clock_Hz属性。
$ kstat -m cpu_info -s current_clock_Hz 
module: cpu_info instance: 0
name: cpu_info0 class: misc
current_clock_Hz 2800000000

module: cpu_info instance: 1
name: cpu_info1 class: misc
current_clock_Hz 2800000000
和Intel的SpeedStep技术相对应的是AMD的PowerNow技术。然而目前Solaris并不支持PowerNow。
Posted at 11:09上午 十二月 20, 2007 by judy in Solaris  |  评论[0]

星期五 十二月 14, 2007
重设Mac OS X的密码

本质上和linux或Solaris是一样的,进入单用户模式就可以了。在OS X上的具体过程如下。


 

Posted at 04:09下午 十二月 14, 2007 by judy in General  |  评论[0]

星期五 十一月 30, 2007
Solaris中检测内存异常访问
本文介绍了在solaris中如何利用核心内存分配的调试功能检测内存异常(corruption)。引起内存异常的常见操作包括:
[Read More]
Posted at 10:33上午 十一月 30, 2007 by judy in Solaris  |  评论[0]

Solaris中如何检测内核代码的内存泄漏

 本文介绍如何利用mdb的::findleaks检测内核代码的内存泄漏。

本文将以一个驱动程序(tleak.c tleak.conf)为例说明如何利用mdb的::findleaks命令检测内核代码是否存在内存泄漏。

请 注意,上一篇文章给的示例应用程序其内存泄漏发生在堆(heap)上,当程序退出的时候,堆随之被释放掉,所以并不会对系统造成影响。而本文提供的示例驱 动tleak将在内核产生内存泄漏,所以请谨慎使用,不熟悉内核的朋友请不要在自己的机器上运行该驱动及以下步骤。(USE AT YOUR OWN RISK)

tleak是一个伪字符设备,每打开一次,会进行一次内存分配,则当第二次打开该设备的时候就会产生内存泄漏,主要函数tleak_open()定义如下:

[Read More]
Posted at 10:28上午 十一月 30, 2007 by judy in Solaris  |  评论[0]

Solaris中如何检测用户应用程序内存泄漏

Solaris中如何利用libumem和mdb检测内存异常,如内存泄漏、越界访问等。

内存泄漏(Memory Leak)通常是由应用程序没有释放其在堆(heap)上分配的内存而造成的。
对于由应用程序引起的内存泄漏,我们可以借助libumem来方便地进行调试。libumem是一个运行在用户模式的内存分配程序库。并已包含在 Solaris 9及以后的Solaris版本中。

 

[Read More]
Posted at 10:21上午 十一月 30, 2007 by judy in General  |  评论[0]

星期二 十一月 27, 2007
Solaris和Ubuntu双系统安装
分享在IBM R50上安装了OpenSolaris b70和Ubuntu 7.04双系统的过程。

首先安装Ubuntu到一个主分区上,安装完成后,备份/boot/grub/menu.lst到U盘上。
然后安装OpenSolaris到另一个主分区,安装完成后,修改/boot/grub/menu.lst文件,把刚才备份的Ubuntu的menu.lst文件中相关内容拷贝到Solaris的menu.lst文件中。[Read More]
Posted at 02:31下午 十一月 27, 2007 by judy in Solaris  |  评论[0]

在Solaris上Mount NTFS / FAT32 / FAT16 / EXT2 / EXT3文件系统
如何用FSWpart,FSWfsmisc在Solaris上Mount NTFS / FAT32 / FAT16 / EXT2 / EXT3文件系统。[Read More]
Posted at 02:28下午 十一月 27, 2007 by judy in Solaris  |  评论[0]

星期一 十一月 26, 2007
Wake On LAN及其在Solaris中的实现
本文介绍了什么是Wake On LAN,并给出了一个WOL应用程序示例。[Read More]
Posted at 03:08下午 十一月 26, 2007 by judy in Solaris  |  评论[0]

Solaris 3D桌面:Compiz Fusion
如何在Solaris上安装运行3D桌面Compiz Fusion。[Read More]
Posted at 11:39上午 十一月 26, 2007 by judy in Solaris  |  评论[0]