Solaris Tips

Mostly Solaris 10   

Stoping console break

 edit /etc/default/kbd

and remove the KEYBOARD_ABORT=disable comment

or add the above line

then activate with kbd -i

 

Shuting down a zone

do not do a zoneadm -z <zone> halt - it's nasty

zlogin <zone> init 0


Starting a zone

zoneadm -z <zone> boot

Zone status

zoneadm list -cv

Adding filesystems to a zone

from the GZ
root@pbigz00 [root] # zonecfg -z <zone>
zonecfg:pbidb01> add fs
zonecfg:pbidb01:fs> set dir=/optware/oracle
zonecfg:pbidb01:fs> set special=/dev/md/dsk/d52
zonecfg:pbidb01:fs> set raw=/dev/md/rdsk/d52
zonecfg:pbidb01:fs> set type=ufs
zonecfg:pbidb01:fs> add options [nodevices,logging]
zonecfg:pbidb01:fs> end
zonecfg:pbidb01> verify
zonecfg:pbidb01> commit

/optware/oracle will be pulled into the zone
note you cannot mount the filesystem in the global zone at the sametime

Removing a filesystem from a zone
zonecfg:pbidb01> remove fs dir=/optware
Dumping a zone config to a text file
 zonecfg -z pbidb01 info
zonename: pbidb01
zonepath: /export/zones/pbidb01
autoboot: true
pool:
limitpriv:
fs:
        dir: /optware/oracle
        special: /dev/md/dsk/d52
        raw: /dev/md/rdsk/d52
        type: ufs
        options: [nodevices,logging]
fs:
        dir: /oradata/ICPB1
        special: /dev/md/dsk/d53
        raw: /dev/md/rdsk/d53
        type: ufs
        options: [nodevices,logging]
fs:
        dir: /oradata/BIEMEA
        special: /dev/md/dsk/d55
        raw: /dev/md/rdsk/d55
        type: ufs
        options: [nodevices,logging]
fs:
        dir: /oradata/POEUI
        special: /dev/md/dsk/d56
        raw: /dev/md/rdsk/d56
        type: ufs
        options: [nodevices,logging]
fs:
        dir: /oradata/POEUI3
        special: /dev/md/dsk/d57
        raw: /dev/md/rdsk/d57
        type: ufs
        options: [nodevices,logging]
fs:
        dir: /oradata/exp
        special: /dev/md/dsk/d54
        raw: /dev/md/rdsk/d54
        type: ufs
        options: [nodevices,logging]
net:
        address: 1.2.3.4
        physical: eri0
device
        match: /dev/tlock
rctl:
        name: zone.cpu-shares
        value: (priv=privileged,limit=20,action=none)
attr:
        name: comment
        type: string
        value: "Zone pbidb01 created by mkzone"



Login into zones

ssh as normal

or is you cannot
as root :
zlogin zonename

will give you root on the zone

Console login to a zone

zlogin -C zonename

Run a command on a zone

zlogin zonename "command"

Growing a zone exported filesystem (sds)

shutdown the zone
double check the metadevice that the file system exists on on the global zone
check for space on the parent device

 metastat d50

 d50: Soft Partition
    Device: d100
    State: Okay
    Size: 125829120 blocks (60 GB)
        Extent              Start Block              Block count
             0                    20384                125829120

d100: Mirror
    Submirror 0: d101
      State: Okay
    Submirror 1: d102
      State: Okay
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 1432373760 blocks (683 GB)

now we know it's part of d100

check the unallocated space of d100

metarecover -v -n /dev/md/rdsk/d100 -p
Verifying on-disk structures on d100.
The following extent headers were found on d100.
                Name  Seq#    Type               Offset               Length
                 d50     0   ALLOC                20383            125829121
                 d51     0   ALLOC            125849535            125829121
                 d52     0   ALLOC            251678687             41943041
                 d53     0   ALLOC            293621759            387973121
                 d54     0   ALLOC            681594911            104857601
                 d55     0   ALLOC            786452543            136314881
                 d56     0   ALLOC            922767455            272629761
                 d56     1   ALLOC           1363169439             68132865
                 d57     0   ALLOC           1195397247            167772161
                NONE     0     END           1432373759                    1
                NONE     0    FREE           125829121            125829121
there is 125829121 blocks free space! (60gb)
now increase the metadevice
metattach d50 60g
metastat d50


d50: Soft Partition
    Device: d100
    State: Okay
    Size: 251658242 blocks (120 GB)
        Extent              Start Block              Block count
             0                    20384                125829121
             1                              125829121                                 125829121

now growfs the softpartition

growfs /dev/md/rdsk/d56
(dont panic it just looks like a newfs!)

test mount on global zone , umount and restart zone with new volume size

Metasets

Normal metacommands will function as expected but will need to be called with –s to allow for metaset use
Eg: metastat –s <setname>

Create metaset (you can have 4 hosts)

    metaset –s <setname> -a h <hostname> <hostname> <hostname> <hostname>

add disks to metaset

    metaset –s <setname> -a <cXtXdX> ….


At this point normal SDS commands can be used to create volumes on the metasets

Eg: metainit –s <setname>  dXXX 1 1 cXtXdX cYtYdY

Failover
Failover from one node to another is done with metoffline and metaonline
On host 1
    Metaoffline –s <setname> dX

On host 2
    Metaonline –s <setname> dX

Dtrace stuff



Dtrace - watch new processes and print full ags
dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }'




New command options under Sol 10

prstat -Z - show zone info
df -h - show df in more human readable form

Enable Resource Pools

/usr/sbin/svcadm enable svc:/system/pools:default

Display current pool settings

poolcfg -dc info

system default
        string  system.comment
        int     system.version 1
        boolean system.bind-default true

        pool pool_default
                int     pool.sys_id 0
                boolean pool.active true
                boolean pool.default true
                int     pool.importance 1
                string  pool.comment
                pset    pset_default

        pset pset_default
                int     pset.sys_id -1
                boolean pset.default true
                uint    pset.min 1
                uint    pset.max 65536
                string  pset.units population
                uint    pset.load 93
                uint    pset.size 4
                string  pset.comment

                cpu
                        int     cpu.sys_id 1
                        string  cpu.comment
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 0
                        string  cpu.comment
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 3
                        string  cpu.comment
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 2
                        string  cpu.comment
                        string  cpu.status on-line

Reset Pools to default

/usr/sbin/pooladm –x

 Hack Hostid on the fly 

get the target host id :

/usr/bin/adb -w -k /dev/ksyms /dev/mem

hw_serial /D
hw_serial /D+4
hw_serial /D+8

/usr/bin/adb -w -k /dev/ksyms /dev/mem << EOF
hw_serial /W 32312539
hw_serial+4 /W 30355635
hw_serial+8 /W 39344400
EOF


defeats flexlm ! and others !


E450 disk to slot map

prtdiag -v shows this


Front Status Panel:
-------------------
Keyswitch position is in On mode.

System LED Status:    POWER     GENERAL ERROR      ACTIVITY
                      [ ON]         [OFF]           [ ON]
                    DISK ERROR  THERMAL ERROR  POWER SUPPLY ERROR
                      [OFF]         [OFF]           [OFF]

Disk LED Status:        OK = GREEN      ERROR = YELLOW
                DISK 18: [EMPTY]        DISK 19: [EMPTY]
                DISK 16: [EMPTY]        DISK 17: [EMPTY]
                DISK 14: [EMPTY]        DISK 15: [EMPTY]
                DISK 12: [EMPTY]        DISK 13: [EMPTY]
                DISK 10: [EMPTY]        DISK 11: [EMPTY]
                DISK  8: [EMPTY]        DISK  9: [EMPTY]
                DISK  6: [EMPTY]        DISK  7: [EMPTY]
                DISK  4: [EMPTY]        DISK  5: [EMPTY]
                DISK  2:    [OK]        DISK  3:    [OK]
                DISK  0:    [OK]        DISK  1:    [OK]


But you know your have at least 12 internal disks in yout e450 !!!!

Sun E450 owners manual

At the ok prompt enter the following command:

setenv disk-led-assoc 0 x y

where:n x is an integer between 1 and 10 identifying the PCI slot number where the
lower UltraSCSI controller is installed
n y is an integer between 1 and 10 identifying the PCI slot number where the
upper UltraSCSI controller is installed
For example, if the controller cards are installed in PCI slots 5 and 7, enter the
following:
setenv disk-led-assoc 0 5 7

 then reset system for changes to take effect

Sendmail - without daemon

echo "MODE=" > /etc/default/sendmail

then bounce sendmail , you wull now notice it's got to -bd in the args

now we need to alter the submit.cf , best to use the macros lest it get clobbered with a patch


 perl -p -i*.bak -e 's/127.0.0.1/mailhost/g' /usr/lib/mail/cf/submit.cf
 (assming mailhost is the name of your smtp server)
   

Compile the new submit.cf file
cd /usr/lib/mail/cf
/usr/ccs/bin/m4 ../m4/cf.m4 submit.mc > submit.cf
Copy this new submit.cf file into place
cp /usr/lib/mail/cf/submit.cf /etc/mail/submit.cf


Remember every time you apply a sendmail patch on this machine, rebuild the submit.cf file.
- caveat -
only tested on Solaris 9 ;) .... YMMV

New (Since 10U2) networking commands


## show interface ,  link and status
# dladm show-dev
e1000g0         link: up        speed: 1000  Mbps       duplex: full
e1000g1         link: unknown   speed: 0     Mbps       duplex: unknown
e1000g2         link: unknown   speed: 0     Mbps       duplex: unknown
e1000g3         link: unknown   speed: 0     Mbps       duplex: unknown


# dladm show-link
e1000g0         type: non-vlan  mtu: 1500       device: e1000g0
e1000g1         type: non-vlan  mtu: 1500       device: e1000g1
e1000g2         type: non-vlan  mtu: 1500       device: e1000g2
e1000g3         type: non-vlan  mtu: 1500       device: e1000g3

Link aggregation with solaris 10

prior to Sol10 U2? you had to buy suntrunking to truck interfaces

unplumb the e1000g0 we used to build the system
# ifconfig e1000g0 unplumb
also the ipv6 version if used
# ifconfig e1000g0 inet6 unplumb

# dladm create-aggr -d e1000g0 -d  e1000g1 1
# dladm show-aggr
key: 1 (0x0001) policy: L4      address: 0:21:28:f:be:7a (auto)
           device       address                 speed           duplex  link    state
           e1000g0      0:21:28:f:bb:7a   1000  Mbps    full    up      standby
           e1000g1      0:21:28:f:bb:7b   1000  Mbps    full    up      standby
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
        inet6 ::1/128

now plumb the aggr interface

# ifconfig aggr1 plumb
# ifconfig aggr1 192.168.1.2 netmask 255.255.255.0

setup a hostname.aggr1 file to ensure the interfaces are setup on boot


 Convert SDxx to cxtxdxsx paths

annoying when you have many disks and the san guys add more and your hit with a deluge of this messages:

Sep 10 13:22:48 blue      Corrupt label; wrong magic number

Sep 10 13:22:48 blue scsi: [ID 107833 kern.warning] WARNING: /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/sd@0,b (sd223):

Sep 10 13:22:48 blue      Corrupt label; wrong magic number

Sep 10 13:22:48 blue scsi: [ID 107833 kern.warning] WARNING: /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/sd@0,b (sd223):

 


the following script helps map the SDxx instance to scsi hardware location

#!/bin/sh
#
#  @(#) wd 1.1 99/03/09
#
#  Used to convert sd instance numbers (eg. sd20) to SCSI hardware location
#  (eg. c1t5d0s0) or the other way around.  Can also list all such devices
#  by using the -all option.
#
#  Credits:
#      hw2inst() function based on "phylog" script by Nick Hindley
#      inst2hw() function based on "whatdev" script from Sun Microsystems
#
#  Revision History
#      1.1 1999-03-09  Mike van der Velden
#          Original Version.   Converts sdxx to cxdxtxsx and back.
#          Optionally lists all such devices.
#
#  Feedback, bug fixes, enhancements?  Send to mvanderv@yahoo.com
#

inst2hw ()
{
    # Convert the sd instance number into the SCSI hardware location.  
    # Grabbed from the "phylog" script by Nick Hindley, 1998-08-04
    
    DEVNAME=$1
    TYPE=`echo $DEVNAME | cut -c 1-2`
    NUM=`echo $DEVNAME | cut -c3-255`

    DEVPATH=`sed 's/"//g' /etc/path_to_inst | \
             nawk -v type=$TYPE -v num=$NUM   \
                  '{if (($2==num) && ($3==type)) print $1;}'`
    
    if [ -z "$DEVPATH" ]; then
        echo "No such device $DEVNAME"
        exit 2
    fi

    # now get all the devices out of /dev.  
    # No way that I know of to map this back.

    for p in /dev/dsk /dev/rdsk /dev/rmt /dev/osa/dev/dsk /dev/osa/dev/rdsk;
    do
        if [ -d $p ]; then
            DEV=`ls -l $p | \
                    nawk -v device=$DEVPATH \
                         '{if ($NF ~ device)  {print $(NF - 2);exit;}}'`
            if [ ! -z "$DEV" ]; then
                # still need work on the st/rmt devices, which currently
                # prints out as a simple number, not as, say rmt/0.
                echo $DEV
                break
            fi
        fi
    done
}


hw2inst ()
{
    # Convert the SCSI hardware location into the sd instance number.
    # From the script "whatdev" from the Solaris 2.X on Sun Hardware 
    # Answerbook (or http://docs.sun.com)

    devname=$1

    for p in /dev /dev/osa/dev/dsk /dev/osa/dev/rdsk /dev/dsk /dev/rdsk /dev/rmt; 
    do
        if [ -h $p/$devname ]; then
            DEVPATH=$p/$devname
            break
        fi
    done

    if [ -z "$DEVPATH" ]; then
        echo "No such device $devname"
        exit 2
    fi
    

    # print out the drive name - st0 or sd0 - given the /dev entry  
    # first get something like "/iommu/.../.../sd@0,0"  
    DEV=`/bin/ls -l $DEVPATH | \
         nawk '{ n = split($11, a, "/"); split(a[n],b,":"); \
                 for(i = 4; i < n; i++) printf("/%s",a[i]); \
                 printf("/%s\n", b[1]) }'`  
    if [ ! -z "$DEV" ]; then
        # get the instance number and concatenate with the "sd"  
        nawk -v dev=$DEV \
             '$1 ~ dev { n = split(dev, a, "/"); split(a[n], b, "@"); \
                         printf("%s%s\n", b[1], $2) }' /etc/path_to_inst  
    fi
}




###############################################################
#
# MAIN
#

USAGE="$0 <device> | -all"

# "verbose" is an unadvertised option, useful for debugging
if [ "$1" = "-v" ]; then
    set -x
    shift
fi

if [ -z "$1" ]; then
    echo "Usage:  $USAGE"
    exit 1
fi


case $1 in

    s*)  # make sure slice number is *not* part of the name
         DEVNAME=`echo $1 | sed "s/\(s[dt][0-9]*\)[a-h]$/\1/"`
         inst2hw $DEVNAME
         ;;

    c*)  # make sure slice number *is* part of the name
         DEVNAME=`echo $1 | sed "s/\(c[0-9]t[0-9]d[0-9]\)$/\1s0/"`
         hw2inst $DEVNAME
         ;;

   -all) if [ -d /dev/osa ]; then
             PREFIX="/dev/osa"
         fi
         for d in ${PREFIX}/dev/rdsk/c?t?d?s0; do
             DEVNAME=`basename $d`
             printf "%s --- " $DEVNAME
             hw2inst $DEVNAME
         done
         ;;

esac

exit 0

Stoping Break on a SUN   

Power-switch key method:

On Enterprise-type Suns, the power switch has four positions: off, on, diagnostic and secure. With the power switch in the secure position, the system ignores BREAKs generated by keyboard reconnect, serial terminal loss, Stop-a or a serial terminal BREAK key.

Command method:

In /etc/default/kbd, add the variable KEYBOARD_ABORT=disable then use the command kbd -i

which reads /etc/default/kbd and disables keyboard abort. 


Playing With Tapes


cfgadm -al 

cfgadm -c configure c3

cfgadm -o show_FCP_dev -al
cfgadm -o show_SCSI_LUN -al

cfgadm -o unusable_FCP_dev -c unconfigure c4::2101001b32b4eb6c
cfgadm -c unconfigure c4::2101001b32b4eb6c

cfgadm -alo show_FCP_dev

luxadm -e port           

luxadm -e forcelip /dev/cfg/c4
luxadm -e dump_map /dev/cfg/c4
devfsadm -C

# luxadm probe
# luxadm qlgc            >>show Sun/Qlogic HBA’s


Vlans on solaris

vlanid * 1000 + instance

example :

vlan 2142

ifconfig nxge2142001 plumb

nxge2142001: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
        inet 10.238.142.37 netmask ffffff00 broadcast 10.238.142.255