您的位置:首页 > 产品设计 > UI/UE

Solaris Infrequently Asked and Obscure Questions

2012-03-21 09:31 399 查看
http://www.unixguide.net/sun/sunobscure.shtml#I.H4

Questions and Answers

^^ System ^^ General ^^ How do I untar a file with absolute paths to a relative location? Method 1 (user) /usr/bin/pax -r -s ',^/,,' -f file.tar

Method 2 (root) mkdir /tmp/lib; cd /lib
cp * /tmp/lib
cp /usr/bin/tar /tmp
cd /tmp
/usr/bin/dd if=file.tar | /usr/bin/chroot /tmp ./tar xf -

^^ How do I do a recursive grep? Method 1 (recommended) /usr/bin/find . | /usr/bin/xargs /usr/bin/grep PATTERN
displays filename:match

Method 2 (recommended) /usr/bin/find . -exec /usr/bin/grep PATTERN {} /dev/null \;
displays filename:match

^^ How do I find out the number of files used on local filesystems? System V /usr/bin/df -F ufs -o i

Berkeley /usr/ucb/df -i

^^ How do I use a FIFO? /usr/bin/mkfifo fifo
/usr/bin/compress < fifo > file.Z &
/usr/bin/cat file > fifo compresses file into file.Z

^^ How do I list available signals? /usr/bin/kill -l
Read /usr/include/sys/signal.h
Solaris 2.6 / 7 /usr/bin/man -s 5 signal

Solaris 8 / 9 / 10 /usr/bin/man -s 3HEAD signal

^^ How do I show how a process will respond to a given signal? /usr/proc/bin/psig pid you must be root or own the process to read /proc/pid

^^ How do I remove a file that begins with a - ? This problem, contrary to popular belief, has nothing to do with the shell. It has to do with how rm(1) parses options.
Method 1 /usr/bin/rm ./-file

Method 2 /usr/bin/rm -- -file
many programs use getopt(), thus they'll interpret - as an argument, to tell getopt() there are no more arguments to parse, use --

^^ ls(1) no longer works, how can i view directory contents? echo * This method uses the shell built-in echo() in conjunction with the * matching properties to generate listing of current directory.

^^ How can I tell what the various ERROR codes mean? Read /usr/include/sys/errno.h
/usr/bin/man -s 2 Intro

^^ How can I create a file of arbitrary size? Method 1 /usr/sbin/mkfile 10m file Creates a 10 Megabyte file
For each write() operation, there is no accompanying read() operation, making this method very efficient

Method 2 (recommended) /usr/bin/dd < /dev/zero > file bs=1024 seek=10240 count=1 Creates a 10 Megabyte file
This method does not require many reads and writes since the file is sparse.

^^ How can I get seconds from epoch? Solaris 2.6 / 7 /usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}'

Solaris 8 / 9 / 10 /usr/bin/perl -e 'printf "%d\n", time;'

^^ How do I get yesterdays date? Solaris 2.6 / 7 TZ=timezone+shift date replace timezone with EST,CST,PST,etc
replace shift with 24-(shift from GMT)
Example EST=-5
24-(-5)=29
TZ=EST+29 date

echo `echo '*time-0t86400=Y' | /usr/bin/adb -k | tail -2`

Solaris 8 / 9 / 10 /usr/bin/perl -e 'printf "%s\n",scalar localtime(time-86400)'
This breaks twice a year during the DST transition.
From perlfaq4;
Note very carefully that the code above assumes that your days
are twenty-four hours each.  For most people, there are two
days a year when they aren't: the switch to and from summer
time throws this off.  A solution to this issue is offered by
Russ Allbery.
sub yesterday {
my $now  = defined $_[0] ? $_[0] : time;
my $then = $now - 60 * 60 * 24;
my $ndst = (localtime $now)[8] > 0;
my $tdst = (localtime $then)[8] > 0;
$then - ($tdst - $ndst) * 60 * 60;
}
# Should give you "this time yesterday" in seconds since epoch relative to
# the first argument or the current time if no argument is given and
# suitable for passing to localtime or whatever else you need to do with
# it.  $ndst is whether we're currently in daylight savings time; $tdst is
# whether the point 24 hours ago was in daylight savings time.  If $tdst
# and $ndst are the same, a boundary wasn't crossed, and the correction
# will subtract 0.  If $tdst is 1 and $ndst is 0, subtract an hour more
# from yesterday's time since we gained an extra hour while going off
# daylight savings time.  If $tdst is 0 and $ndst is 1, subtract a
# negative hour (add an hour) to yesterday's time since we lost an hour.
#
# All of this is because during those days when one switches off or onto
# DST, a "day" isn't 24 hours long; it's either 23 or 25.
#
# The explicit settings of $ndst and $tdst are necessary because localtime
# only says it returns the system tm struct, and the system tm struct at
# least on Solaris doesn't guarantee any particular positive value (like,
# say, 1) for isdst, just a positive value.  And that value can
# potentially be negative, if DST information isn't available (this sub
# just treats those cases like no DST).
#
# Note that between 2am and 3am on the day after the time zone switches
# off daylight savings time, the exact hour of "yesterday" corresponding
# to the current hour is not clearly defined.  Note also that if used
# between 2am and 3am the day after the change to daylight savings time,
# the result will be between 3am and 4am of the previous day; it's
# arguable whether this is correct.
#
# This sub does not attempt to deal with leap seconds (most things don't).
#
# Copyright relinquished 1999 by Russ Allbery
# This code is in the public domain
</RRA@STANFORD.EDU>


^^ How do I get access, modify, creation time of a file?

Access time (atime)

/usr/bin/ls -ul filename

Modify time (mtime)

/usr/bin/ls -l filename

Creation time

There is no way to determine creation time in the ufs filesystem

Change time (ctime)

/usr/bin/ls -cl filename

this includes status changes (like permissions)

All in one (root)

/usr/bin/ls -i filename | /usr/bin/awk \ '{print "0t"$1":ino?i"}' | /usr/sbin/fsdb -F ufs /dev/rdsk/c0t0d0s0

assumes raw device of filesystem for filename is c0t0d0s0

^^ What is load?

Load is the number of processes currently in the run queue.

Method 1

/usr/bin/w -u

displays load average over last 1, 5 and 15 minutes

Method 2

/usr/bin/uptime

displays load average over last 1, 5 and 15 minutes

^^ What is the run queue?

The run queue consists of processes ready to run, i.e not otherwise blocked or waiting for i/o, that are contending for cpu resources to become available.

/usr/bin/vmstat 1 2

Current run queue is indicated by the "r" heading

First line of output is average since system boot

^^ How can I copy directory contents to a remote machine (without nfs)?

Method 1

/usr/bin/tar -cf - sourcepath | /usr/bin/rsh remote " cd /targetpath ; /usr/bin/tar -xBf - "

Method 2

/usr/bin/find sourcepath | /usr/bin/cpio -o | /usr/bin/rsh remote "cd /targetpath ; /usr/bin/cpio -id"

^^ How do I archive directories with 155+ character directory names or 100+ character file names?

Solaris 2.6

Sun's version of tar does not support this, use cpio

/usr/bin/find . | /usr/bin/cpio -o > file.cpio

-H tar produces warning on files with the aforementioned attributes

Solaris 7 / 8 / 9 / 10

Use the -E switch to enable extended headers

^^ How do I convert hexadecimal to decimal and vice versa?

Method 1 - adb (Solaris 2.6 / 7)

echo "0xff=d" | /usr/bin/adb

converts ff into 255

echo "0t255=x" | /usr/bin/adb

converts 255 to ff

Method 2 - mdb (Solaris 8 / 9 / 10)

echo "0xff=d" | /usr/bin/mdb

converts ff into 255

echo "0t255=x" | /usr/bin/mdb

converts 255 to ff

Method 3 - bc

echo "ibase=16; ff" | /usr/bin/bc

converts ff into 255

echo "obase=16; 255" | /usr/bin/bc

converts 255 to FF

Method 4 - dc

echo "10 16 o i FF p" | dc

converts FF to 255

echo "16 10 o i 255 p" | dc

converts 255 to FF

Method 5 - printf

/usr/bin/printf '%d\n' 0xff

converts ff to 255

/usr/bin/printf '%x\n' 255

converts 255 to ff

^^ How do I convert binary to decimal and vice versa?

Method 1 - bc

echo "ibase=2; 11111111" | /usr/bin/bc

converts 11111111 into 255

echo "obase=2; 255" | /usr/bin/bc

converts 255 to 11111111

Method 2 - dc

echo "2 10 o i 11111111 p" | dc

converts 11111111 to 255

echo "10 2 o i 255 p" | dc

converts 255 to 11111111

^^ What can I do about zombie processes?

Solaris 9 / 10

ps –ef | grep defunct

/usr/bin/preap pid

^^ Shell

^^ My setuid shell script keeps running as the real user, why?

Bourne Shell

The use of setuid shell scripts is discouraged

If you must, protect yourself with trap()

Bourne shell always sets the effective user and group IDs to the real user and group IDs.

/bin/sh -p

C Shell

The use of setuid shell scripts is discouraged

C shell does not run setuid/setgid shell scripts by default

"/dev/fd/3: Bad file number" is a common error

/bin/csh -b

^^ Why is cd() a shell built-in rather than an executable?

Quick Answer

a child process cannot modify the environment of the parent

Long Answer

a shell fork()s and then exec()s the requested executable. in doing so, the newly created process begins life with the environment of the parent process. the new child process then manipulates the environment in the manner requested, in this case a modification of the directory stack, and returns to the parent. however, since this change occurred in the child address space, the parent's environment was never changed, and therefore the requested operation did not take place.

^^ How do I redirect stderr?

Bourne Shell

to stdout

command 2>&1

to file

command 2> file

to null

command 2> /dev/null

C Shell

to stdout

command >& /dev/tty

to file (without affecting stdout)

( command > /dev/tty ) >& file

to null (without affecting stdout)

a. ( command > /dev/tty ) >& /dev/null

^^ How do I rename files by extension like MS-DOS?

DOS Example: move *.doc *.txt

Korn Shell

for x in *.doc; do mv $x ${x%.doc}.txt; done

^^ Kernel

^^ Where do I put kernel configuration?

/etc/system

^^ 2. How do I add more PTYs?

Solaris 2.6 / 7

Do not attempt to do this with '/usr/bin/adb -k'.

Modify /etc/system

set pt_cnt=X

/usr/sbin/reboot -- -r

Solaris 8 / 9 / 10

Dynamically allocated.

Do not attempt to do this with '/usr/bin/mdb -k'.

Limit is forced by modifying /etc/system

set pt_cnt=X

/usr/sbin/reboot -- -r

^^ What is shared memory?

Just as it sounds. Shared memory is an Interprocess Communication (IPC) mechanism used by multiple processes to access common memory segments.

^^ How do I know the limits for shared memory kernel tunables?

Read /usr/include/sys/shm.h

^^ What is a semaphore?

A non-negative integer that is incremented or decremented relative to available resources.

^^ How do I know the limits for semaphore kernel tunables?

Read /usr/include/sys/sem.h

^^ What is a door?

A door is a file descriptor that describes a method for interprocess communication between client and server threads.

A door file appears with file mode D---------.

^^ add_drv(1m) fails with "add_drv/rem_drv currently busy; try later".

/usr/bin/rm /tmp/AdDrEm.lck

^^ How do I increase the number of file descriptors available to an application?

File descriptors are used for more than just open files, they also provide the framework for socket i/o.

The kernel dynamically allocates resources for open files. There is no maximum number of file descriptors per system.

Depending on the programming interface used, an application may not be able to reach the file descriptor limit.

API limits (ref:Solaris Internals)

Solaris 2.6

stdio(3S) - 256

From stdio(3S); no more than 255 files may be opened using fopen(), and only file descriptors 0 through 255 can be used in a stream.

select(3c) - 1024

From select(3c); The default value for FD_SETSIZE (currently 1024) is larger than the default limit on the number of open files. It is not possible to increase the size of the fd_set data type when used with select().

Solaris 7 / 8 / 9 / 10

stdio(3s) - 256 (32-bit) / 65536 (64-bit)

select(3c) - 1024 (32-bit) / 65536 (64-bit)

65536 limit is attainable on 32-bit Solaris 7

#define FD_SETSIZE 65536 ; prior to includes

System defaults

Solaris 2.6 / 7

rlim_fd_max 1024

rlim_fd_cur 64

Solaris 8

rlim_fd_max 1024

rlim_fd_cur 256

Solaris 9 / 10

rlim_fd_max 65536

rlim_fd_cur 256

Modify /etc/system

set rlim_fd_max=8192 ; hard limit (per process)

set rlim_fd_cur=1024 ; soft limit (per process)

^^ What is a register window?

A register window is used by the operating system to store the current local and in registers upon a system interupt, exception, or trap instruction.

register windows are important to preserve the state of the stack between function calls.

^^ What is the default memory page size?

sun4u

8192 bytes

sun4c/sun4m/sun4d

4096 bytes

^^ What is the current memory page size?

/usr/bin/pagesize

^^ What kind of binaries can my kernel run?

/usr/bin/isainfo -v

^^ What kind of kernel modules can my kernel run?

/usr/bin/isainfo -kv

^^ Devices

^^ How do I make the system aware of new devices?

Disks

While the system is up ( no fcal )

Solaris 2.6 / 7

Generate /devices structure

/usr/sbin/drvconfig

Generate /dev/dsk and /dev/rdsk links

/usr/sbin/disks

Solaris 8 / 9

Generate /devices and /dev/dsk, /dev/rdsk links

/usr/sbin/devfsadm

Solaris 10

Generate /devices

/devices is now dynamic and managed by the devfs filesystem

If necessary, new devices can be configured using /usr/sbin/cfgadm

Generate /dev/dsk, /dev/rdsk links

/usr/sbin/devfsadm

While the system is up ( fcal )

Get the enclosure name

/usr/sbin/luxadm probe

Add the disk

/usr/sbin/luxadm insert_device enclosure,slot

With a reboot

Method 1

/usr/sbin/shutdown -g0 -i0 "disk addition"

Reconfigure Boot (From OpenBoot PROM monitor)

boot -r

Method 2

/usr/bin/touch /reconfigure

/usr/sbin/shutdown -g0 -i6 "disk addition"

Ports

While the system is up

Solaris 2.6 / 7

Generate /devices structure

/usr/sbin/drvconfig

Generate /dev links

/usr/sbin/ports

Solaris 8 / 9

Generate /devices structure and /dev links

/usr/sbin/devfsadm

Solaris 10

Generate /devices

/devices is now dynamic and managed by the devfs filesystem

If necessary, new devices can be configured using /usr/sbin/cfgadm

Generate /dev links

/usr/sbin/devfsadm

Tapes

While the system is up

Solaris 2.6 / 7

Generate /devices structure

/usr/sbin/drvconfig

Generate /dev and /dev links

/usr/sbin/tapes

Solaris 8 / 9

Generate /devices structure and /dev links

/usr/sbin/devfsadm

Solaris 10

Generate /devices

/devices is now dynamic and managed by the devfs filesystem

If necessary, new devices can be configured using /usr/sbin/cfgadm

Generate /dev links

/usr/sbin/devfsadm

Misc. Devices

While the system is up

Solaris 2.6 / 7

Generate /devices structure

/usr/sbin/drvconfig

Generate /dev links

/usr/sbin/devlinks

Solaris 8 / 9

Generate /devices structure and /dev links

/usr/sbin/devfsadm

Solaris 10

Generate /devices

/devices is now dynamic and managed by the devfs filesystem

If necessary, new devices can be configured using /usr/sbin/cfgadm

Generate /dev links

/usr/sbin/devfsadm

^^ How do I know what the video configuration for my adapter/display is?

M64 Adapter

/usr/sbin/m64config -propt

Creator 3D Adapter

/usr/sbin/ffbconfig -propt

^^ How do I know what the adapter/display is capable of?

M64 Adapter

Display what the card is capable of

/usr/sbin/m64config -res \?

Display what the card and display are capable of

/usr/sbin/m64config -prconf

Creator 3D Adapter

Display what the card is capable of

/usr/sbin/ffbconfig -res \?

Display what the card and display are capable of

/usr/sbin/ffbconfig -prconf

^^ How do I change color depth?

M64 Adapter

/usr/sbin/m64config -depth 24

Attempts to set the default color depth to 24.

Creator 3D Adapter

/usr/sbin/ffbconfig -depth 24

Attempts to set the default color depth to 24.

^^ How can I prevent my system from halting when my terminal server is rebooted?

Patches

Solaris 2.6

Install patch 105924-10 or later

Solaris 7

Install patch 107589-02 or later

Solaris 8 / 9 / 10

Integrated

Method 1 (persistent)

Modify /etc/default/kbd

KEYBOARD_ABORT=alternate

/usr/sbin/init 6

New break sequence is "~^b"

Method 2 (not persistent, system up)

Solaris 2.6 / 7

/usr/bin/kbd -a disable

This disables keyboard abort (L1-A / Stop-A) until you perform Method 1

Solaris 8 / 9 / 10

/usr/bin/kbd -a alternate

This allows for the alternate sequence to be immediately available until you perform Method 1

^^ What does hme stand for in /dev/hme?

Happy Meal Ethernet

^^ Where are device drivers located?

/kernel/drv/<driver>

^^ How do I configure a device driver?

w/<driver>.conf

man <driver>

vi /kernel/drv/<driver>.conf

w/o <driver>.conf

man <driver>

man driver.conf

^^ How do I configure the scsi-options for my scsi controller?

/usr/sbin/prtconf -v
SUNW,fas, instance #0
Driver properties:
name <target6-TQ> length <4>
value <0x00000000>.
name <target6-wide> length <4>
value <0x00000000>.
name <target6-sync-speed> length <4>
value <0x00002710>.
name <target0-TQ> length <4>
value <0x00000001>.
name <target0-wide> length <4>
value <0x00000000>.
name <target0-sync-speed> length <4>
value <0x00002710>.
name <pm_norm_pwr> length <4>
value <0x00000001>.
name <pm_timestamp> length <4>
value <0x3549c8e0>.
name <scsi-options> length <4>
value <0x000007f8>.
^^^


Convert to current hexadecimal value to binary

echo 'obase=2;ibase=16;7F8' | /usr/bin/bc
11111111000


From /usr/include/sys/scsi/conf/autoconf.h;
#define SCSI_OPTIONS_LINK       0x10    /* Global linked commands */
#define SCSI_OPTIONS_TAG        0x80    /* Global tagged command support */
#define SCSI_OPTIONS_DR         0x8     /* Global disconnect/reconnect  */
#define SCSI_OPTIONS_SYNC       0x20    /* Global synchronous xfer capability */
#define SCSI_OPTIONS_PARITY     0x40    /* Global parity support */
#define SCSI_OPTIONS_FAST       0x100   /* Global FAST scsi support */
#define SCSI_OPTIONS_WIDE       0x200   /* Global WIDE scsi support */
#define SCSI_OPTIONS_FAST20     0x400   /* Global FAST20 scsi support */


Order bits descending
#define SCSI_OPTIONS_FAST20     0x400   /* Global FAST20 scsi support */
#define SCSI_OPTIONS_WIDE       0x200   /* Global WIDE scsi support */
#define SCSI_OPTIONS_FAST       0x100   /* Global FAST scsi support */
#define SCSI_OPTIONS_TAG        0x80    /* Global tagged command support */
#define SCSI_OPTIONS_PARITY     0x40    /* Global parity support */
#define SCSI_OPTIONS_SYNC       0x20    /* Global synchronous xfer capability */
#define SCSI_OPTIONS_LINK       0x10    /* Global linked commands */
#define SCSI_OPTIONS_DR         0x8     /* Global disconnect/reconnect  */


Check if turned on or off
Global FAST20 scsi support                 1
Global WIDE scsi support                   1
Global FAST scsi support                   1
Global tagged command support              1
Global parity support                      1
Global synchronous xfer capability         1
Global linked commands                     1
Global disconnect/reconnect                1
0
0
0


Example: Disabling Tagged Queuing on FAS SCSI controller Target 0

Determine bit order to turn off tag queuing
Global FAST20 scsi support                 1
Global WIDE scsi support                   1
Global FAST scsi support                   1
Global tagged command support              0
Global parity support                      1
Global synchronous xfer capability         1
Global linked commands                     1
Global disconnect/reconnect                1
0
0
0


Convert current binary value to hexadecimal

echo "obase=16;ibase=2;1101111000" | /usr/bin/bc
378


Add to /kernel/drv/fas.conf
target0-scsi-options=0x378;
scsi-options=0x7f8;


^^ How do I change the default terminal setting on the system console?

Solaris 2.6 / 7 / 8 / 9 / 10

Edit the "co:" line in /etc/inittab

Change "-T sun" to "-T vt100" or whatever your preferred terminal is

Example:

echo "g/^co:/s/sun/vt100/1\nw" | ed -s /etc/inittab

Solaris 10

Configure the service with svccfg

SVC> select svc:/system/console-login:default

svc:/system/console-login:default> setprop ttymon/terminal_type = "vt100"

svc:/system/console-login:default> quit

^^ Filesystem

^^ How do I get a list of superblocks on a filesystem?

assumes filesystem was created with default parameters

/usr/sbin/newfs -N device | awk '/^ [0-9]/'

^^ How do I grow/shrink a ufs filesystem?

Grow

Unmounted filesystem (not /, /usr, /var)

Allocate additional contiguous disk space with format(1m)

Unnecessary if you are using a volume manager

/usr/lib/fs/ufs/mkfs -G rawdevice newsize

Mounted filesytem (not /, /usr, /var)

Allocate additional contiguous disk space with format(1m)

Unnecessary if you are using a volume manager

/usr/lib/fs/ufs/mkfs -G -M mountpoint rawdevice newsize

Shrink

You cannot shrink a UFS filesystem

^^ How do I determine what type of filesystem a given device has?

/usr/sbin/fstyp blockdevice

^^ What are inodes 0, 1, and 2 used for?

Inode 0 is unusable. It is used to mark unused inodes.

Inode 1 is unusable. Use of this inode for bad block information is deprecated.

Inode 2 is "/" or "root" of the filesystem.

^^ What do I do if I have a corrupt boot block?

ok boot cdrom -s

/usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c#t#d#s#

^^ What is the DNLC?

DNLC is the directory name look up cache

It is a hash table bucket structure of name cache entries for fast lookup. The elements in this cache are directory vnode, file name, and credential.

Solaris also employs a directory cache mechanism for large directories. This is an unordered linked list of free space entries.

Solaris caches names up to 30 characters. Longer names are read using the standard, slower method, by traversing the directory structure.

Read /usr/include/sys/dnlc.h

^^ How does the DNLC relate to the kernel vfs layer?

Since the DNLC is a reference to recently used vnodes, the filesystem will read from the DNLC prior to the underlying filesystem. This is due to the fact that every inode/rnode has a corresponding vnode. vfs is a layer of abstraction in the kernel that allows the kernel to support multiple filesystem types by presenting all filesystems in a uniform manner.

^^ How do I get statistics about DNLC performance?

A value of 90% or less requires tuning.

Method 1 (recommended)

/usr/bin/vmstat -s | /usr/bin/grep "name lookup"

Method 2

Solaris 2.6 / 7

echo '*ncstats*0t100%(*ncstats+*(ncstats+4)+*(ncstats+14))=D' | /usr/bin/adb -k

Solaris 8 / 9 / 10

echo '*ncstats*0t100%(*ncstats+*(ncstats+4)+*(ncstats+14))=D' | /usr/bin/mdb -k

^^ How do I prevent the ufs filesystem from buffering my database files?

ufs now has the ability to provide direct access to a file. This new method is not as effective as RAW access because the filesystem still allocates the file by indirect blocks which can fragment.

this is done on a per filesystem, rather than per file basis

direct i/o can be dangerous when used on filesystems that are accessed by applications that do not buffer data internally

Method 1 (persistent)

Add "forcedirectio" to mount options in /etc/vfstab

Method 2 (not persistent, system up)

/usr/sbin/mount -o remount,forcedirectio,(other options) /mountpoint

^^ How do I disable "access time" updates for file?

This is useful for web servers and news servers to prevent unnecessary file I/O.

Add "noatime" to mount options in /etc/vfstab

^^ What is the difference between file mode 1 and 5?

mode 1 allows exec() of the binary

mode 5 allows exec() of the binary and processes to mmap() pages from within userspace

this is why shared libraries generally need to be PROT_READ and PROT_EXEC at page level and -r-x at file level

^^ How can I force an unmount of a filesystem?

Solaris 2.6 / 7

there is no special flag to the umount() system call that allows this

Solaris 8 / 9 / 10

/usr/sbin/umount -f /mount

^^ What is the default ufs block size?

8192 bytes logical block, 1024 bytes fragment size

^^ X11

^^ How do I use an alternate window manager?

Bypassing CDE

echo "exec /path/to/alternate/window/manager" > .xsession

Maintaining CDE

Xresources

cd /usr/dt/config/C/Xresources.d

/usr/bin/cp Xresources.ow Xresources.wm

Modify Xresources.wm

Dtlogin*altDtName: Alternate WindowManager

Dtlogin*altDtKey: /path/to/alternate/window/manager

Dtlogin*altDtStart: /usr/dt/config/Xsession.wm

Dtlogin*altDtLogo: WMlogo

Xsession

cd /usr/dt/config

/usr/bin/cp Xsession.ow Xsession.wm

Modify Xsession.wm

Place windowmanager environment

Logo (for display in CDE login)

cd /usr/dt/appconfig/icons/C

/usr/bin/cp OWlogo.pm WMlogo.pm

Replace this with your own XPM file

^^ How do I disable X Windows from starting at boot?

Method 1 (recommended)

/usr/dt/bin/dtconfig -d

Method 2

/usr/bin/mv /etc/rc2.d/S99dtlogin /etc/rc2.d/s99dtlogin

^^ How do I disable that annoying beep?

Method 1

/usr/openwin/bin/xset b 0

Method 2

/usr/openwin/bin/xset b off

Method 3

/usr/openwin/bin/xset -b

^^ How do I disable the CDE front panel?

Modify $HOME/.Xdefaults

Dtwm*useFrontPanel: false

^^ How do I determine which X11 version and extensions are supported?

/usr/openwin/bin/xdpyinfo -v

^^ Crash Dump

^^ When did it happen?

Method 1 (to the minute)

/usr/bin/who -b

Method 2 (to the second)

Solaris 2.6 / 7

Become root

echo '*time-(*lbolt%64)=Y' | /usr/bin/adb -k

Solaris 8 / 9 / 10

Become root

echo '*time-(*lbolt%64)=Y' | /usr/bin/mdb -k

^^ How do I get information about what was going on?

Enable savecore

Solaris 2.6

disabled by default

Modify /etc/init.d/sysetup

Uncomment last 6 lines

Solaris 7 / 8 / 9 / 10

Enabled by default

Enable with '/usr/bin/dumpadm -y'

Default file locations

Corefile is /var/crash/`uname -n`/vmcore.n

Namelist is /var/crash/`uname -n`/unix.n

Process status

Solaris 2.6 / 7

Open the crash interpreter

/usr/sbin/crash -d corefile -n namelist

p -e

The "p" command reads the process table

Solaris 8 / 9 / 10

Open the modular debugger

/usr/bin/mdb namelist corefile

::ps

The "::ps" command reads the process table

Network status

/usr/bin/netstat namelist corefile

IPC status

/usr/sbin/ipcs -C corefile -N namelist

^^ Veritas Volume Manager

^^ How do I allow a user to write to a managed raw device?

/usr/bin/chown is not persistent across reboots

/usr/sbin/vxedit set user=oracle group=dba mode=600 volume

^^ How do I move rootdg from one system to another?

without this procedure, you will get error messages at boot because the system sees two instances of rootdg

/etc/vx/diag.d/vxprivutil list /dev/rdsk/c#t#d#s# | awk '/^group/'

note the disk group id number

/usr/sbin/vxdg -C -n newdg import dgid

dgid is group id from (a)

this command creates disk group newdg and imports the disk

^^ What is the difference between Disk Suite and Veritas Volume Manager?

Veritas Volume Manager logs metadata and filesystem data, whereas Disk Suite logs only metadata

^^ What is the difference between RAID 0+1 and 1+0?

Diagram A (RAID 0+1)

[ v]
||
[ p]
||
[sv]
||
=======================[v2]=======================
|                                                |
==========[p2]==========  ==========[p2]==========
|                      |  |                      |
=[s2]==[s2]==[s2]==[s2]=  =[s2]==[s2]==[s2]==[s2]=


Striping occurs at the subvolume(p2) layer.

Mirroring occurs at the subplex (v2) layer.

Diagram B (RAID 1+0)

[ v]
||
[ p]
||
==========================[sv]==========================
|                                                      |
===========[v2]===========    ===========[v2]===========
|                        |    |                        |
====[p2]====  ====[p2]====    ====[p2]====  ====[p2]====
|          |  |          |    |          |  |          |
=[s2]==[s2]=  =[s2]==[s2]=    =[s2]==[s2]=  =[s2]==[s2]=


Striping occurs at the subvolume(sv) layer.

Mirroring occurs at the subplex (p2) layer.

The diagrams above use the Veritas 3.x nomenclature.

Volume Resynchronization

There is an additional layer of abstraction in RAID 1+0 that allows for isolation of the subdisks into subplexes. Since the subplexes are smaller than the plexes in RAID 0+1, time to resynchronize is reduced.

Fault Tolerance

There is an additional layer of abstraction in RAID 1+0 that allows for isolation of the subdisks into subplexes. Since the subplexes now contain reduced amounts of disks, and are composed solely of single subdisk mirrors, the RAID 1+0 volume can sustain the loss of multiple disks pending all of the disks within a given subplex do not fail.

^^ Veritas Filesystem

^^ How do I make vxfs support large files?

/usr/lib/fs/vxfs/fsadm -o largefiles /mountpoint

^^ How do I defragment a vxfs filesystem?

Determine if necessary

Method 1

/usr/lib/fs/vxfs/df -o s /mountpoint

Method 2

/usr/lib/fs/vxfs/fsadm -ED /mountpoint

reports on both extent and directory fragmentation

/usr/lib/fs/vxfs/fsadm -ed /mountpoint

reorganizes extents and directories

^^ How do I grow/shrink a vxfs filesystem?

vxfs, unlike ufs, filesystems can be shrunk.

Mounted filesystem (not /, /usr, /var)

/usr/lib/fs/vxfs/fsadm -b size /mountpoint

^^ How do I prevent the vxfs filesystem from buffering my database files?

Method 1 (persistent)

Add "mincache=direct,convosync=direct" to mount options in /etc/vfstab

Method 2 (not persistent, system up)

/usr/sbin/mount -o remount,mincache=direct,convosync=direct,<other options> /mountpoint

[UNVERIFIED] please email if you can confirm

Method 3 (Quick I/O)

This is presented as an add-on module for filesystem and ships with Veritas Database Edition.

Quick I/O presents files with preallocated extents as character devices to the application in the form of ".filename::cdev:vxfs" by use of the vxqio device driver

Quick I/O is enabled per filesystem, by default, but is configured on a per file basis

^^ How do I create a Quick I/O file?

Oracle

/usr/sbin/qiomkfile -h <header size> -s <extent size> /path/to/dbfile

<header size> should correspond to DB_BLOCK_SIZE, 32k by default

<extent size> should correspond to the size of the database. by allocating appropriate extents you can prevent fragmentation

^^ What is the default vxfs block size?

Filesystem size <= 8GB

1024 bytes

Filesystem size 8GB <= 16GB

2048 bytes

Filesystem size 16GB <= 32GB

4096 bytes

Filesystem > 32GB

8192 bytes

^^ Network

^^ Physical Layer

^^ How do I find the speed my network card is at?

/usr/sbin/ndd -set /dev/hme instance 0

Instance 0 - hme0

Instance 1 - hme1

/usr/sbin/ndd -get /dev/hme transciever_inuse

0 - onboard

1 - offboard card (mii)

/usr/sbin/ndd -get /dev/hme link_status

0 - down

1 - up

/usr/sbin/ndd -get /dev/hme link_speed

0 - 10Mb

1 - 100Mb

/usr/sbin/ndd -get /dev/hme link_mode

0 - half duplex

1 - full duplex

^^ How do I configure what my network card is capable of?

Method 1

/etc/system

this sets global defaults for the driver, therefore it is effective for all instances of the card

HME/QFE/GE interfaces

set hme:hme_adv_autoneg_cap=0

Advertise auto negotiate capability

0 - off

1 - on

set hme:hme_adv_100T4=0

Advertise deprecated 100Mbit T4 capability

0 - off

1 - on

set hme:hme_adv_100fdx=0

Advertise 1000Mbit full duplex capability

0 - off

1 - on

set hme:hme_adv_100hdx=0

Advertise 100Mbit half duplex capability

0 - off

1 - on

set hme:hme_adv_10fdx=0

Advertise 10Mbit full duplex capability

0 - off

1 - on

set hme:hme_adv_10hdx=0

Advertise 10Mbit half duplex capability

0 - off

1 - on

ERI interfaces

set eri:adv_autoneg_cap=0

Advertise auto negotiate capability

0 - off

1 - on

set eri:adv_100T4=0

Advertise deprecated 100Mbit T4 capability

0 - off

1 - on

set eri:adv_100fdx=0

Advertise 100Mbit full duplex capability

0 - off

1 - on

set eri:adv_100hdx=0

Advertise 100Mbit half duplex capability

0 - off

1 - on

set eri:adv_10fdx=0

Advertise 10Mbit full duplex capability

0 - off

1 - on

set eri:adv_10hdx=0

Advertise 10Mbit half duplex capability

0 - off

1 - on

Method 2

This method allows more granular control over the interface driver. You can specify configuration by port.

/usr/sbin/ndd -set /dev/hme instance 0

Instance 0 - hme0

Instance 1 - hme1

/usr/sbin/ndd -set /dev/hme adv_autoneg_cap 0

Advertise auto negotiate capability

0 - off

1 - on

/usr/sbin/ndd -set /dev/hme adv_100fdx_cap 0

Advertise 100Mbit full duplex capability

0 - off

1 - on

/usr/sbin/ndd -set /dev/hme adv_100hdx_cap 0

Advertise 100Mbit half duplex capability

0 - off

1 - on

/usr/sbin/ndd -set /dev/hme adv_100T4_cap 0

Advertise deprecated 100Mbit T4 capability

0 - off

1 - on

/usr/sbin/ndd -set /dev/hme adv_10fdx_cap 0

Advertise 10Mbit full duplex capability

0 - off

1 - on

/usr/sbin/ndd -set /dev/hme adv_10hdx_cap 0

Advertise 10Mbit half duplex capability

0 - off

1 - on

^^ How do I display what my link partner is capable of?

/usr/sbin/ndd -set /dev/hme instance 0

Instance 0 - hme0

Instance 1 - hme1

/usr/sbin/ndd -get /dev/hme lp_autoneg_cap

link partner has auto negotiate capability

0 - off

1 - on

/usr/sbin/ndd -get /dev/hme lp_100fdx_cap

link partner has 100Mbit full duplex capability

0 - off

1 - on

/usr/sbin/ndd -get /dev/hme lp_100hdx_cap

link partner has 100Mbit half duplex capability

0 - off

1 - on

/usr/sbin/ndd -get /dev/hme lp_100T4_cap

link partner has deprecated 100Mbit T4 capability

0 - off

1 - on

/usr/sbin/ndd -get /dev/hme lp_10fdx_cap

link partner has 10Mbit full duplex capability

0 - off

1 - on

/usr/sbin/ndd -get /dev/hme lp_10hdx_cap

link partner has 10Mbit half duplex capability

0 - off

1 - on

^^ How can I tell if my card is active on the network?

Method 1 (Openboot PROM)

watch-net

^^ How do I use multiple ethernet interfaces on the same network segment?

Method 1 (modern cards, 1997+)

Modern Sun Adapters have unique mac addresses encoded in the FCode Prom.

/usr/sbin/eeprom local-mac-address?=true

Method 2 (older cards)

From InfoDoc 16733;
Section 3.2.3(4) of the IEEE 802.3 spec defines a reserved bit in the
Ethernet Address that can be used to administer a universally assigned
ethernet addresses. A Locally administered address (LAA) can be
implemented to ensure a unique HW address.


Setting the LAA bit can be done by using a 0A hex as the first digit instead of 08.

/usr/sbin/ifconfig hme1 ether 0a:0:20:00:01

^^ How do I determine if local mac addresses are in use on my host?

/usr/sbin/prtconf -pv | /usr/bin/grep local-mac-address

^^ Transport Layer

^^ How do I configure stronger sequence number generation?

From RFC 1948;
The initial sequence numbers are intended to be more or less random.
More precisely, RFC 793 specifies that the 32-bit counter be incremented
by 1 in the low-order position about every 4 microseconds.  Instead,
Berkeley-derived kernels increment it by a constant every second, and by
another constant for each new connection.  Thus, if you open a
connection to a machine, you know to a very high degree of confidence
what sequence number it will use for its next connection.  And therein
lies the attack.


/usr/sbin/ndd -set /dev/tcp tcp_strong_iss 2

0 - Sequential

1 - Random increment variance (Default)

2 - RFC 1948, unique-per-connection-ID.

Modify /etc/default/inetinit.

1. TCP_STRONG_ISS=2

^^ I have a large amount of connections in state CLOSE_WAIT, what can be done to reduce this number in the future?

Increase Connection Hash Table

Used for faster connection lookups

Must be set at boot time

Defaults

Solaris 2.6 / 7

Default is 256, Max is 262144

Solaris 8 / 9

Default is 512, Max is 1073741824

Solaris 10

Parameter Removed in Solaris 10

Modify /etc/system

set tcp:tcp_conn_hash_size=8192

/usr/sbin/init 6

Decrease Close Wait / Time Wait Interval

Solaris 2.6 / 7

Can be modified on the fly at any time

Default is 240000, Minimum Recommended is 60000, Range 1 to 600000

Measured in 1/1000ths of a second, default is 4 minutes

/usr/sbin/ndd -set /dev/tcp tcp_close_wait_interval 60000

Solaris 8

Can be modified on the fly at any time

Default is 240000, Minimum Recommended is 60000, Range 1 to 600000

Measured in 1/1000ths of a second, default is 4 minutes

/usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 60000

Solaris 9 / 10

Can be modified on the fly at any time

Default is 60000, Minimum Recommended is 60000, Range 1 to 600000

Measured in 1/1000ths of a second, default is 1 minute

/usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 60000

^^ How can I increase my TCP Window size?

Increase Transmit Window

Increasing this value in excess of the 16bit window defined in RFC793, as SEG.WND, causes the Window Scaling option as defined in RFC1323.

Increasing this value takes additional memory

Solaris 8

Default is 16384

Solaris 9 / 10

Default is 49152

/usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 65536

Increase Receive Window

Increasing this value in excess of the 16bit window defined in RFC793, as SEG.WND, causes the Window Scaling option as defined in RFC1323.

Increasing this value takes additional memory

Solaris 8

Default is 24576

Solaris 9 / 10

Default is 49152

/usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 65536

^^ What do all the TCP states actually mean?

CLOSED (0)

Socket is closed

LISTEN (1)

Socket is passive, awaiting a connection request

SYN_SENT (2)

Socket is active, has sent a SYN

Session not yet active

SYN_RECEIVED (3)

Socket is active, has sent and received SYN

Session not yet active

ESTABLISHED (4)

Socket is active

Session is active, has completed handshake

CLOSE_WAIT (5)

Socket is closed, received FIN, waiting for close

Session is terminating

FIN_WAIT (6)

Socket is closed, sent FIN, waiting for FIN ACK

Session is terminating

CLOSING (7)

Socket is closed, exchanged FIN, waiting for FIN ACK

Session is terminating

LAST_ACK (8)

Socket is closed, received FIN, waiting for FIN ACK

Session is terminating

FIN_WAIT_2 (9)

Socket is closed, received FIN ACK

Session is complete

TIME_WAIT (10)

Socket is closed, waits for ( 2 * max segment life )

Session is complete
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: