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]

星期三 一月 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]

星期六 十二月 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]

星期五 十一月 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]

星期二 十一月 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]

星期四 九月 06, 2007
在MacBook Pro上安装Solaris
最近在最新的苹果MacBook Pro上成功安装了OpenSolaris b70。唯一的问题是有线和无线网卡不能工作。以下是我的解决方法。[Read More]
Posted at 04:39下午 九月 06, 2007 by judy in Solaris  |  评论[0]

星期五 八月 31, 2007
Solaris常用调试工具
本文总结了solaris常用的调试工具及命令。这些命令可用于查看系统或进程状态,控制、调试进程及跟踪调试核心。
[Read More]
Posted at 11:02上午 八月 31, 2007 by judy in Solaris  |  评论[0]

在Solaris上用cdrecord刻录CD/DVD
cdrecord是OpenSolaris上一个功能强大的用以刻录CD/DVD的命令行工具。与之前的cdrw相比, cdrecord能更好的兼容USB和1394接口的刻录机,而cdrw则仅推荐在内置的IDE/ATAPI刻录机上使用。 [Read More]
Posted at 10:51上午 八月 31, 2007 by judy in Solaris  |  评论[0]

星期三 一月 31, 2007
如何配置Solaris的PPPOE以支持ADSL访问
Solaris下配置PPPOE的详细步骤[Read More]
Posted at 07:57下午 一月 31, 2007 by judy in Solaris  |  评论[0]