Archive for the ‘Opensolaris’ Category

wget behind proxy

Friday, March 26th, 2010

One of the ways to get wget to work behind proxy is to create .wgetrc file in the user’s home directory. In it put this:

http_proxy = http://proxy_server_yourdomain.com:8080/

if your proxy is using authentication, add also the following lines to your .wgetrc file

proxy_user=user
proxy_password=password

Configure Opensolaris host to have HBAs in target mode (COMSTAR)

Wednesday, February 24th, 2010

Configuring Opensolaris host to have HBAs in target mode (COMSTAR) will effectively turn your Opensolaris host into host that will act as a storage array. Most of the Emulex 2GB and up and Qlogic 4GB HBAs and up are supported to work in target mode in Comstar project, se this thread for more info about supported HBAs http://opensolaris.org/jive/thread.jspa?threadID=81627

We start checking installed HBAs:

root@opensolaris:~# fcinfo hba-port
HBA Port WWN: 10000000c9328447
Port Mode: Initiator
Port ID: 0
OS Device Name: Not Applicable
Manufacturer: Emulex
Model: LP9002L
Firmware Version: 3.93a0 (C2D3.93A0)
FCode/BIOS Version: none
Serial Number: 0000C9328447
Driver Name: emlxs
Driver Version: 2.50i (2009.11.10.12.30)
Type: unknown
State: offline
Supported Speeds: 1Gb 2Gb
Current Speed: not established
Node WWN: 20000000c9328447
HBA Port WWN: 10000000c9328448
Port Mode: Initiator
Port ID: 0
OS Device Name: Not Applicable
Manufacturer: Emulex
Model: LP9002L
Firmware Version: 3.93a0 (C2D3.93A0)
FCode/BIOS Version: none
Serial Number: 0000C9328448
Driver Name: emlxs
Driver Version: 2.50i (2009.11.10.12.30)
Type: unknown
State: offline
Supported Speeds: 1Gb 2Gb
Current Speed: not established
Node WWN: 20000000c9328448

We need to change port mode to target, that is done by editing emlxs driver config file (/kernel/drv/emlxs.conf), you need to change target-mode from 0 to 1:

# target-mode: Controls COMSTAR target mode support for an adapter port.
#
# 0 = Disables target mode support. Enables initiator mode support.
# 1 = Enables target mode support. Disables initiator mode support.
#
# Usage examples:
# target-mode=1; Sets global default for target mode
# emlxs0-target-mode=0; emlxs0 will be an initiator port
# emlxs1-target-mode=1; emlxs1 will be a target port
#
# Range: Min:0 Max:1 Default:0
#
target-mode=1;

and in the next section you need to remove comment in the ddi-forceattach line, so you’ll have

ddi-forceattach=1;

In order for driver settings to take effect, you need to reboot.

After reboot make sure that Comstar services are running:

# svcs stmf
# svcadm enable stmf

And now we can see that there are 2 targets:

root@opensolaris:~# stmfadm list-target
Target: wwn.10000000C9328448
Target: wwn.10000000C9328447

Which is also confirmed by fcinfo command:

root@opensolaris:~# fcinfo hba-port
HBA Port WWN: 10000000c9328447
Port Mode: Target
Port ID: 0
OS Device Name: Not Applicable
Manufacturer: Emulex
Model: LP9002L
Firmware Version: 3.93a0 (C2D3.93A0)
FCode/BIOS Version: none
Serial Number: 0000C9328447
Driver Name: emlxs
Driver Version: 2.50i (2009.11.10.12.30)
Type: unknown
State: offline
Supported Speeds: 1Gb 2Gb
Current Speed: not established
Node WWN: 20000000c9328447
HBA Port WWN: 10000000c9328448
Port Mode: Target
Port ID: 0
OS Device Name: Not Applicable
Manufacturer: Emulex
Model: LP9002L
Firmware Version: 3.93a0 (C2D3.93A0)
FCode/BIOS Version: none
Serial Number: 0000C9328448
Driver Name: emlxs
Driver Version: 2.50i (2009.11.10.12.30)
Type: unknown
State: offline
Supported Speeds: 1Gb 2Gb
Current Speed: not established
Node WWN: 20000000c9328448

Disable nwam on Opensolaris and manually configure IP settings

Sunday, December 27th, 2009

Nwam stands for “Network Auto-Magic” and is part of Opensolaris project. It is meant to automatically configure IP settings for primarily laptop users. While it is useful to an extent, real annoyance is that is enabled by default (I guess it is supposed to be, otherwise it wouldn’t serve its purpose) upon Opensolaris installation. If you want to manually setup your IP, do the following:

svcadm disable svc:/network/physical:nwam

make sure that everything looks good in the following files:
/etc/hosts
IP hostname hostname.domain

/etc/resolv.conf
#Google’s name servers, easy to remember
nameserver 8.8.8.8
nameserver 8.8.4.4

/etc/defaultrouter
IP_of_your_router

/etc/hostname.yge0
IP_of_the_host

/etc/nsswitch.conf
hosts: files dns

/etc/inet/netmasks
#for 192.168.1 network it would be
192.168.1.0 255.255.255.0

svcadm enable svc:/network/physical:default

root@opensolaris:/etc/inet# dladm show-link
LINK CLASS MTU STATE BRIDGE OVER
yge0 phys 1500 up — –

If any any time you experience difficulties, run ‘svcs -x’ (no quotes) to see which service has a problem and what is causing it. To list all services running, type ‘svcs’, to list all services including disabled ones type ‘svcs -a’.
These changes are persistent across reboots.

Create Ramdisk in Opensolaris

Monday, November 16th, 2009

There are couple of ways at least to create a ramdisk in Opensolaris and the one described here is using ramdiskadm command:

root@opensolaris:~# pfexec ramdiskadm -a ramdisk1 512m
/dev/ramdisk/ramdisk1

we have just created 512MB ramdisk . To verify:

root@opensolaris:~# ramdiskadm
Block Device Size Removable
/dev/ramdisk/ramdisk1 536870912 Yes

then we add previously created ramdisk to zpool:

root@opensolaris:~# zpool create rampool /dev/ramdisk/ramdisk1

root@opensolaris:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rampool 70K 472M 19K /rampool
rpool 6.83G 287G 81K /rpool
rpool/ROOT 3.04G 287G 19K legacy
rpool/ROOT/opensolaris 8.55M 287G 2.87G /
rpool/ROOT/opensolaris-1 3.03G 287G 2.87G /

we can see that out rampool ram disk is mounted /rampool

root@opensolaris:~# ls -la /rampool/
total 3
drwxr-xr-x 2 root root 2 2009-11-15 22:52 .
drwxr-xr-x 26 root root 27 2009-11-15 22:47 ..

root@opensolaris:~# zpool status
pool: rampool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
rampool ONLINE 0 0 0
/dev/ramdisk/ramdisk1 ONLINE 0 0 0

errors: No known data errors

pool: rpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c10d1s0 ONLINE 0 0 0

errors: No known data errors

our ram disk is now ready to be used.

Flush DNS resolver cache on OS X, Linux, Solaris and Windows

Wednesday, October 21st, 2009

OS X: dscacheutil -flushcache

Linux (CentOS, RHEL): /sbin/service nscd restart

Solaris: ps -eaf|grep nscd

kill -9 PID   ### PID is process ID from the previous step

/usr/sbin/nscd

Windows (from command line of course): ipconfig /flushdns (run ipconfig /displaydns to view the DNS resolver cache)

rsync over ssh

Wednesday, October 21st, 2009

This example show how to rsync files over ssh running the rsync on the destination host:

rsync -avz -e ssh remote_user@remote_host:/remote/dir /local/dir/

in this case you’d have to enter remote_user password. If you are running rsync on a regular basis, create ssh keys with no password and copy public key to the .ssh/authorized_keys file on the remote user you are connecting as on the remote host.

You can also copy multiple files or directories from the destination host:

rsync -avz -e ssh  remote_host:/remote_dir/file1 remote_dir2/file2 /local/dir

Meaning of options used (from rsync man page):

-a, –archive               archive mode; same as -rlptgoD (no -H)

-z, –compress              compress file data during the transfer

-v, –verbose               increase verbosity

-e, –rsh=COMMAND           specify the remote shell to use

multiple domains in one reverse zone

Monday, October 12th, 2009

This is quick and dirty way to jam all your subnets into one bind zone. This is not recommended way to run DNS, but if you are in a hurry and you want to get DNS working in your organization quickly without spending too much time setting up zones and name servers, you can get them to work easily in one zone. Forward requests are typically not a problem and they resolve fine when multiple subnets are  in the one zone file. Problem is with reverse records and you can get that to work in one zone file if you name your reverse zone file in-addr.arpa. Read more below:

After you create your zones, check zones with named-checkzone and correct any errors. If you get simiar error as: Jan 17 15:07:56 r2d2 named[4499]: mydomain.in-addr.arpa:326: ignoring out-of-zone data (21.161.27.172.in-addr.arpa)
that is because your zone is not considered authoratitive for the PTR records you are trying to put in. To define correct PTR zone, choose one of the following zones (example domain is 192.22.239.x):

zone “139.239.22.195.in-addr.arpa” IN {} (recommended)
zone “239.22.195.in-addr.arpa” IN {}
zone “22.195.in-addr.arpa” IN {}
zone “195.in-addr.arpa” IN {}
zone “in-addr.arpa” IN {}  // this could take almost any number of domains in one zone
zone “arpa” IN {} (discouraged)

Of course multiple PTR zones in one zone is not really recommended and maybe can be used only for internal DNS

correct PTR zone template is:

$TTL 60
in-addr.arpa. IN  SOA c3po.myzone.zone. root.c3po.myzone.zone. (
2007011703      ; serial, todays date + todays serial #
10800           ; refresh, seconds
3600            ; retry, seconds
604800          ; expire, seconds
3600 )          ; Negative caching TTL, seconds

in-addr.arpa.  IN NS  c3po.myzone.zone.
101.111.170.10.in-addr.arpa. IN PTR     c3po.myzone.zone.
15.24.24.10.in-addr.arpa.    IN PTR    net1.myzone.zone.

Forward zone template:

$TTL 60
myzone.zone. IN  SOA c3po.myzone.zone. root.c3po.myzone.zone. (
2007011703      ; serial, todays date + todays serial #
10800           ; refresh, seconds
3600            ; retry, seconds
604800          ; expire, seconds
3600 )          ; negative caching of TTL, seconds

myzone.zone.  IN  NS  c3po.myzone.zone.
localhost            IN  A     127.0.0.1
c3po.visops.zone.                  IN  A     10.170.111.101

net1.myzone.zone.        IN  A    10.24.24.15

localzone template:

0.0.127.in-addr.arpa. IN  SOA c3po.myzone.zone. root.c3po.myzone.zone. (
2007011703      ; serial, todays date + todays serial #
10800           ; refresh, seconds
3600            ; retry, seconds
604800          ; expire, seconds
3600 )          ; negative caching of TTL, seconds

0.0.127.in-addr.arpa.  IN NS  c3po.myzone.zone.

1.0.0.127.in-addr.arpa.  IN PTR localhost.

/etc/named.conf template (for bind 9.2 and later)

options {

directory “/var/named”; // the default

dump-file               ”data/cache_dump.db”;
statistics-file         ”data/named_stats.txt”;
memstatistics-file      “data/named_mem_stats.txt”;

};

logging
{
/*      If you want to enable debugging, eg. using the ‘rndc trace’ command,
*      named will try to write the ‘named.run’ file in the $directory (/var/named).
*      By default, SELinux policy does not allow named to modify the /var/named directory,
*      so put the default debug log file in data/ :
*/
channel default_debug {
file “data/named.run”;
severity  dynamic;
};
};

zone “myzone.zone” in {
type master;
file “db.myzone”;
};

zone “in-addr.arpa” in {
type master;
file “in-addr.arpa”;
};

zone “0.0.127.in-addr.arpa” in {
type master;
file “named.local”;
};

zone “.” in {
type hint;
file “named.ca”;
};

echo redirects with sudo don't work

Monday, October 12th, 2009

if you try something like sudo echo “This is test” >> /some/file_owned_by_root you’ll get : Permission denied” message.

The problem is that the redirect is opening a sub-shell which is owned by the user who intiated echo command and not root.  In this case this user doesn’t have permission to write to /some/file_owned_by_root.

Solution is to run:

sudo sh -c ‘echo “This is test” >> /some/file_owned_by_root’

sh -c will read the commands from the string and basically all the commands will be run as root (with sudo before sh -c)

“man sudo” also explains similar use case:

To make a usage listing of the directories in the /home partition.  Note that this runs the commands in a sub- shell to make the cd and file redirection work.

$ sudo sh -c “cd /home ; du -s * â sort -rn > USAGE”

Asus Crosshair II Formula network driver install

Monday, October 12th, 2009

Asus Crosshair II Formula is using Marvell 88E8056 PCI-E Gigabit Ethernet Controller. To get network interfaces to work under Opensolaris (Solaris Express Community Edition snv_101 X86, version 10/08) follow these steps:

Get driver from
http://www.skd.de/e_en/support/driver.html?navid=14

Pick the product SK-9E22 10/100/1000Base-T Dual Port Server Adaptor

pkgrm SK98sol  ### remove exisiting (wrong) driver

vi /etc/driver_aliases ### remove all lines that start with sk98sol

gunzip skgesol_x64v8.19.1.3.tar.Z
tar xvf skgesol_x64v8.19.1.3.tar
pkgadd -d . SKGEsolx
/usr/X11/bin/scanpci -v
pci bus 0×0009 cardnum 0×00 function 0×00: vendor 0x11ab device 0x4364
Marvell Technology Group Ltd. 88E8056 PCI-E Gigabit Ethernet Controller
CardVendor 0×1043 card 0x81f8 (ASUSTeK Computer Inc., Card unknown)
STATUS    0×0010  COMMAND 0×0047
CLASS     0×02 0×00 0×00  REVISION 0×12
BIST      0×00  HEADER 0×00  LATENCY 0×00  CACHE 0×08
BASE0     0x00000000fd4fc004  addr 0x00000000fd4fc000  MEM 64BIT
BASE2     0x00006c01  addr 0x00006c00  I/O
MAX_LAT   0×00  MIN_GNT 0×00  INT_PIN 0×01  INT_LINE 0x0a
BYTE_0    0×00  BYTE_1  0×00  BYTE_2  0xf0  BYTE_3  0×01

(we need to know bus type (pci-x or pci (2nd line), vendor 0x11ab  and device 0×4364 from above output)

update_drv -a -i ‘”pciex11ab,4364″‘ skge ### (if this was pci device, then it would be update_drv -a -i ‘”pci11ab,4364″‘ skge)

echo $?   ### check exit code from above command
touch /reconfigure
sync
init 6

### after reboot do some checks ###
grep skge /etc/path_to_inst
“/pci@0,0/pci10de,77a@14/pci1043,81f8@0″ 0 “skge”

grep skge /etc/driver_aliases
skge “pci1148,9e00″
skge “pci1148,9000″
skge “pci1148,5021″
skge “pci1148,5041″
skge “pci1148,5043″
skge “pci1148,5051″
skge “pci1148,5061″
skge “pci1148,5071″
skge “pci1148,5081″
skge “pci1148,9821″
skge “pci1148,9822″
skge “pci1148,9841″
skge “pci1148,9842″
skge “pci1148,9843″
skge “pci1148,9844″
skge “pci1148,9861″
skge “pci1148,9862″
skge “pci1148,9871″
skge “pci1148,9872″
skge “pci1259,2916″
skge “pci1259,2970″
skge “pci1259,2971″
skge “pci1259,2972″
skge “pci1259,2973″
skge “pci1259,2974″
skge “pci1259,2975″
skge “pci1259,2976″
skge “pci1259,2977″
skge “pciex11ab,4364″

### add DNS server(s) ###
echo “nameserver 192.168.1.1″ > /etc/resolv.conf

### interface doesn’t work by default, it needs to be unplumbed and plumbed on each boot and default route added since content of /etc/defaultrouter is ignored by this driver)
### best is to put this to a script in /etc/rc3.d/S99_nicstart
ifconfig skge0 unplumb
ifconfig skge0 plumb
ifconfig skge0 192.168.1.88 netmask 255.255.255.0 up
route add default 192.168.1.1

chmod 744 /etc/rc3.d/S99_nicstart ### then run this script or reboot

### check link status and speed
dladm show-link
LINK        CLASS    MTU    STATE    OVER
skge0       phys     1500   unknown  –

bash-3.2# kstat skge|grep ifspeed
ifspeed                         1000000000  ### if there are 9 zeros, speed is gigE, 8 zeros is 100mb/s
ifspeed                         1000000000