Solaris Infrequently Asked and Obscure Questions

http://www.unixguide.net/sun/sunobscure.shtml#I.H4

Questions and Answers

  1. ^^ System
    1. ^^ General
      1. ^^ How do I untar a file with absolute paths to a relative location?
        1. Method 1 (user)
          1. /usr/bin/pax -r -s ',^/,,' -f file.tar
        2. Method 2 (root)
          1. mkdir /tmp/lib; cd /lib
          2. cp * /tmp/lib
          3. cp /usr/bin/tar /tmp
          4. cd /tmp
          5. /usr/bin/dd if=file.tar | /usr/bin/chroot /tmp ./tar xf -
      2. ^^ How do I do a recursive grep?
        1. Method 1 (recommended)
          1. /usr/bin/find . | /usr/bin/xargs /usr/bin/grep PATTERN
          2. displays filename:match
        2. Method 2 (recommended)
          1. /usr/bin/find . -exec /usr/bin/grep PATTERN {} /dev/null \;
          2. displays filename:match
      3. ^^ How do I find out the number of files used on local filesystems?
        1. System V
          1. /usr/bin/df -F ufs -o i
        2. Berkeley
          1. /usr/ucb/df -i
      4. ^^ How do I use a FIFO?
        1. /usr/bin/mkfifo fifo
        2. /usr/bin/compress < fifo > file.Z &
        3. /usr/bin/cat file > fifo
          1. compresses file into file.Z
      5. ^^ How do I list available signals?
        1. /usr/bin/kill -l
        2. Read /usr/include/sys/signal.h
        3. Solaris 2.6 / 7
          1. /usr/bin/man -s 5 signal
        4. Solaris 8 / 9 / 10
          1. /usr/bin/man -s 3HEAD signal
      6. ^^ How do I show how a process will respond to a given signal?
        1. /usr/proc/bin/psig pid
          1. you must be root or own the process to read /proc/pid
      7. ^^ How do I remove a file that begins with a - ?
        1. This problem, contrary to popular belief, has nothing to do with the shell. It has to do with how rm(1) parses options.
        2. Method 1
          1. /usr/bin/rm ./-file
        3. Method 2
          1. /usr/bin/rm -- -file
          2. many programs use getopt(), thus they'll interpret - as an argument, to tell getopt() there are no more arguments to parse, use --
      8. ^^ ls(1) no longer works, how can i view directory contents?
        1. echo *
          1. This method uses the shell built-in echo() in conjunction with the * matching properties to generate listing of current directory.
      9. ^^ How can I tell what the various ERROR codes mean?
        1. Read /usr/include/sys/errno.h
        2. /usr/bin/man -s 2 Intro
      10. ^^ How can I create a file of arbitrary size?
        1. Method 1
          1. /usr/sbin/mkfile 10m file
            1. Creates a 10 Megabyte file
            2. For each write() operation, there is no accompanying read() operation, making this method very efficient
        2. Method 2 (recommended)
          1. /usr/bin/dd < /dev/zero > file bs=1024 seek=10240 count=1
            1. Creates a 10 Megabyte file
            2. This method does not require many reads and writes since the file is sparse.
      11. ^^ How can I get seconds from epoch?
        1. Solaris 2.6 / 7
          1. /usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}'
        2. Solaris 8 / 9 / 10
          1. /usr/bin/perl -e 'printf "%d\n", time;'
      12. ^^ How do I get yesterdays date?
        1. Solaris 2.6 / 7
          1. TZ=timezone+shift date
            1. replace timezone with EST,CST,PST,etc
            2. replace shift with 24-(shift from GMT)
            3. Example
              1. EST=-5
              2. 24-(-5)=29
              3. TZ=EST+29 date
          2. echo `echo '*time-0t86400=Y' | /usr/bin/adb -k | tail -2`
        2. Solaris 8 / 9 / 10
          1. /usr/bin/perl -e 'printf "%s\n",scalar localtime(time-86400)'
          2. This breaks twice a year during the DST transition.
          3. 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>
      13. ^^ How do I get access, modify, creation time of a file?
        1. Access time (atime)
          1. /usr/bin/ls -ul filename
        2. Modify time (mtime)
          1. /usr/bin/ls -l filename
        3. Creation time
          1. There is no way to determine creation time in the ufs filesystem
        4. Change time (ctime)
          1. /usr/bin/ls -cl filename
          2. this includes status changes (like permissions)
        5. All in one (root)
          1. /usr/bin/ls -i filename | /usr/bin/awk \ '{print "0t"$1":ino?i"}' | /usr/sbin/fsdb -F ufs /dev/rdsk/c0t0d0s0
            1. assumes raw device of filesystem for filename is c0t0d0s0
      14. ^^ What is load?
        1. Load is the number of processes currently in the run queue.
        2. Method 1
          1. /usr/bin/w -u
          2. displays load average over last 1, 5 and 15 minutes
        3. Method 2
          1. /usr/bin/uptime
          2. displays load average over last 1, 5 and 15 minutes
      15. ^^ What is the run queue?
        1. 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.
        2. /usr/bin/vmstat 1 2
          1. Current run queue is indicated by the "r" heading
          2. First line of output is average since system boot
      16. ^^ How can I copy directory contents to a remote machine (without nfs)?
        1. Method 1
          1. /usr/bin/tar -cf - sourcepath | /usr/bin/rsh remote " cd /targetpath ; /usr/bin/tar -xBf - "
        2. Method 2
          1. /usr/bin/find sourcepath | /usr/bin/cpio -o | /usr/bin/rsh remote "cd /targetpath ; /usr/bin/cpio -id"
      17. ^^ How do I archive directories with 155+ character directory names or 100+ character file names?
        1. Solaris 2.6
          1. Sun's version of tar does not support this, use cpio
          2. /usr/bin/find . | /usr/bin/cpio -o > file.cpio
            1. -H tar produces warning on files with the aforementioned attributes
        2. Solaris 7 / 8 / 9 / 10
          1. Use the -E switch to enable extended headers
      18. ^^ How do I convert hexadecimal to decimal and vice versa?
        1. Method 1 - adb (Solaris 2.6 / 7)
          1. echo "0xff=d" | /usr/bin/adb
            1. converts ff into 255
          2. echo "0t255=x" | /usr/bin/adb
            1. converts 255 to ff
        2. Method 2 - mdb (Solaris 8 / 9 / 10)
          1. echo "0xff=d" | /usr/bin/mdb
            1. converts ff into 255
          2. echo "0t255=x" | /usr/bin/mdb
            1. converts 255 to ff
        3. Method 3 - bc
          1. echo "ibase=16; ff" | /usr/bin/bc
            1. converts ff into 255
          2. echo "obase=16; 255" | /usr/bin/bc
            1. converts 255 to FF
        4. Method 4 - dc
          1. echo "10 16 o i FF p" | dc
            1. converts FF to 255
          2. echo "16 10 o i 255 p" | dc
            1. converts 255 to FF
        5. Method 5 - printf
          1. /usr/bin/printf '%d\n' 0xff
            1. converts ff to 255
          2. /usr/bin/printf '%x\n' 255
            1. converts 255 to ff
      19. ^^ How do I convert binary to decimal and vice versa?
        1. Method 1 - bc
          1. echo "ibase=2; 11111111" | /usr/bin/bc
            1. converts 11111111 into 255
          2. echo "obase=2; 255" | /usr/bin/bc
            1. converts 255 to 11111111
        2. Method 2 - dc
          1. echo "2 10 o i 11111111 p" | dc
            1. converts 11111111 to 255
          2. echo "10 2 o i 255 p" | dc
            1. converts 255 to 11111111
      20. ^^ What can I do about zombie processes?
        1. Solaris 9 / 10
          1. ps –ef | grep defunct
          2. /usr/bin/preap pid
    2. ^^ Shell
      1. ^^ My setuid shell script keeps running as the real user, why?
        1. Bourne Shell
          1. The use of setuid shell scripts is discouraged
            1. If you must, protect yourself with trap()
          2. Bourne shell always sets the effective user and group IDs to the real user and group IDs.
          3. /bin/sh -p
        2. C Shell
          1. The use of setuid shell scripts is discouraged
          2. C shell does not run setuid/setgid shell scripts by default
            1. "/dev/fd/3: Bad file number" is a common error
          3. /bin/csh -b
      2. ^^ Why is cd() a shell built-in rather than an executable?
        1. Quick Answer
          1. a child process cannot modify the environment of the parent
        2. Long Answer
          1. 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.
      3. ^^ How do I redirect stderr?
        1. Bourne Shell
          1. to stdout
            1. command 2>&1
          2. to file
            1. command 2> file
          3. to null
            1. command 2> /dev/null
        2. C Shell
          1. to stdout
            1. command >& /dev/tty
          2. to file (without affecting stdout)
            1. ( command > /dev/tty ) >& file
          3. to null (without affecting stdout)
            1. a. ( command > /dev/tty ) >& /dev/null
      4. ^^ How do I rename files by extension like MS-DOS?
      5. DOS Example: move *.doc *.txt
    3. Korn Shell
    4. for x in *.doc; do mv $x ${x%.doc}.txt; done

^^ Kernel
  1. ^^ Where do I put kernel configuration?
    1. /etc/system
  2. ^^ 2. How do I add more PTYs?
    1. Solaris 2.6 / 7
      1. Do not attempt to do this with '/usr/bin/adb -k'.
      2. Modify /etc/system
        1. set pt_cnt=X
      3. /usr/sbin/reboot -- -r
    2. Solaris 8 / 9 / 10
      1. Dynamically allocated.
      2. Do not attempt to do this with '/usr/bin/mdb -k'.
      3. Limit is forced by modifying /etc/system
        1. set pt_cnt=X
      4. /usr/sbin/reboot -- -r
  3. ^^ What is shared memory?
    1. Just as it sounds. Shared memory is an Interprocess Communication (IPC) mechanism used by multiple processes to access common memory segments.
  4. ^^ How do I know the limits for shared memory kernel tunables?
    1. Read /usr/include/sys/shm.h
  5. ^^ What is a semaphore?
    1. A non-negative integer that is incremented or decremented relative to available resources.
  6. ^^ How do I know the limits for semaphore kernel tunables?
    1. Read /usr/include/sys/sem.h
  7. ^^ What is a door?
    1. A door is a file descriptor that describes a method for interprocess communication between client and server threads.
    2. A door file appears with file mode D---------.
  8. ^^ add_drv(1m) fails with "add_drv/rem_drv currently busy; try later".
    1. /usr/bin/rm /tmp/AdDrEm.lck
  9. ^^ How do I increase the number of file descriptors available to an application?
  10. 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?
  1. 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.
  2. register windows are important to preserve the state of the stack between function calls.
^^ What is the default memory page size?
  1. sun4u
    1. 8192 bytes
  2. sun4c/sun4m/sun4d
    1. 4096 bytes
^^ What is the current memory page size?
  1. /usr/bin/pagesize
^^ What kind of binaries can my kernel run?
  1. /usr/bin/isainfo -v
^^ What kind of kernel modules can my kernel run?
  1. /usr/bin/isainfo -kv
^^ Devices
  1. ^^ How do I make the system aware of new devices?
    1. Disks
      1. While the system is up ( no fcal )
        1. Solaris 2.6 / 7
          1. Generate /devices structure
            1. /usr/sbin/drvconfig
          2. Generate /dev/dsk and /dev/rdsk links
            1. /usr/sbin/disks
        2. Solaris 8 / 9
          1. Generate /devices and /dev/dsk, /dev/rdsk links
            1. /usr/sbin/devfsadm
        3. Solaris 10
          1. Generate /devices
            1. /devices is now dynamic and managed by the devfs filesystem
            2. If necessary, new devices can be configured using /usr/sbin/cfgadm
          2. Generate /dev/dsk, /dev/rdsk links
            1. /usr/sbin/devfsadm
      2. While the system is up ( fcal )
        1. Get the enclosure name
          1. /usr/sbin/luxadm probe
        2. Add the disk
          1. /usr/sbin/luxadm insert_device enclosure,slot
      3. With a reboot
        1. Method 1
          1. /usr/sbin/shutdown -g0 -i0 "disk addition"
          2. Reconfigure Boot (From OpenBoot PROM monitor)
            1. boot -r
        2. Method 2
          1. /usr/bin/touch /reconfigure
          2. /usr/sbin/shutdown -g0 -i6 "disk addition"
    2. Ports
      1. While the system is up
        1. Solaris 2.6 / 7
          1. Generate /devices structure
            1. /usr/sbin/drvconfig
          2. Generate /dev links
            1. /usr/sbin/ports
        2. Solaris 8 / 9
          1. Generate /devices structure and /dev links
            1. /usr/sbin/devfsadm
        3. Solaris 10
          1. Generate /devices
            1. /devices is now dynamic and managed by the devfs filesystem
            2. If necessary, new devices can be configured using /usr/sbin/cfgadm
          2. Generate /dev links
            1. /usr/sbin/devfsadm
    3. Tapes
      1. While the system is up
        1. Solaris 2.6 / 7
          1. Generate /devices structure
            1. /usr/sbin/drvconfig
          2. Generate /dev and /dev links
            1. /usr/sbin/tapes
        2. Solaris 8 / 9
          1. Generate /devices structure and /dev links
            1. /usr/sbin/devfsadm
        3. Solaris 10
          1. Generate /devices
            1. /devices is now dynamic and managed by the devfs filesystem
            2. If necessary, new devices can be configured using /usr/sbin/cfgadm
          2. Generate /dev links
            1. /usr/sbin/devfsadm
    4. Misc. Devices
      1. While the system is up
        1. Solaris 2.6 / 7
          1. Generate /devices structure
            1. /usr/sbin/drvconfig
          2. Generate /dev links
            1. /usr/sbin/devlinks
        2. Solaris 8 / 9
          1. Generate /devices structure and /dev links
            1. /usr/sbin/devfsadm
        3. Solaris 10
          1. Generate /devices
            1. /devices is now dynamic and managed by the devfs filesystem
            2. If necessary, new devices can be configured using /usr/sbin/cfgadm
          2. Generate /dev links
            1. /usr/sbin/devfsadm
  2. ^^ How do I know what the video configuration for my adapter/display is?
    1. M64 Adapter
      1. /usr/sbin/m64config -propt
    2. Creator 3D Adapter
      1. /usr/sbin/ffbconfig -propt
  3. ^^ How do I know what the adapter/display is capable of?
    1. M64 Adapter
      1. Display what the card is capable of
        1. /usr/sbin/m64config -res \?
      2. Display what the card and display are capable of
        1. /usr/sbin/m64config -prconf
    2. Creator 3D Adapter
      1. Display what the card is capable of
        1. /usr/sbin/ffbconfig -res \?
      2. Display what the card and display are capable of
        1. /usr/sbin/ffbconfig -prconf
  4. ^^ How do I change color depth?
    1. M64 Adapter
      1. /usr/sbin/m64config -depth 24
        1. Attempts to set the default color depth to 24.
    2. Creator 3D Adapter
      1. /usr/sbin/ffbconfig -depth 24
        1. Attempts to set the default color depth to 24.
  5. ^^ How can I prevent my system from halting when my terminal server is rebooted?
    1. Patches
      1. Solaris 2.6
        1. Install patch 105924-10 or later
      2. Solaris 7
        1. Install patch 107589-02 or later
      3. Solaris 8 / 9 / 10
        1. Integrated
    2. Method 1 (persistent)
      1. Modify /etc/default/kbd
        1. KEYBOARD_ABORT=alternate
      2. /usr/sbin/init 6
      3. New break sequence is "~^b"
    3. Method 2 (not persistent, system up)
      1. Solaris 2.6 / 7
        1. /usr/bin/kbd -a disable
        2. This disables keyboard abort (L1-A / Stop-A) until you perform Method 1
      2. Solaris 8 / 9 / 10
        1. /usr/bin/kbd -a alternate
        2. This allows for the alternate sequence to be immediately available until you perform Method 1
  6. ^^ What does hme stand for in /dev/hme?
    1. Happy Meal Ethernet
  7. ^^ Where are device drivers located?
    1. /kernel/drv/<driver>
  8. ^^ How do I configure a device driver?
    1. w/<driver>.conf
      1. man <driver>
      2. vi /kernel/drv/<driver>.conf
    2. w/o <driver>.conf
      1. man <driver>
      2. man driver.conf
  9. ^^ How do I configure the scsi-options for my scsi controller?
    1. /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>.
                                ^^^
          
    2. Convert to current hexadecimal value to binary
      1. echo 'obase=2;ibase=16;7F8' | /usr/bin/bc
        11111111000
             
    3. 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 */
          
    4. 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  */
          
    5. 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
          
    6. Example: Disabling Tagged Queuing on FAS SCSI controller Target 0
      1. 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
             
      2. Convert current binary value to hexadecimal
        1. echo "obase=16;ibase=2;1101111000" | /usr/bin/bc
          378
                
      3. Add to /kernel/drv/fas.conf
        target0-scsi-options=0x378;
        scsi-options=0x7f8;
             
  10. ^^ How do I change the default terminal setting on the system console?
    1. Solaris 2.6 / 7 / 8 / 9 / 10
      1. Edit the "co:" line in /etc/inittab
      2. Change "-T sun" to "-T vt100" or whatever your preferred terminal is
      3. Example:
        1. echo "g/^co:/s/sun/vt100/1\nw" | ed -s /etc/inittab
    2. Solaris 10
      1. Configure the service with svccfg
        1. SVC> select svc:/system/console-login:default
        2. svc:/system/console-login:default> setprop ttymon/terminal_type = "vt100"
        3. svc:/system/console-login:default> quit
^^ Filesystem
  1. ^^ How do I get a list of superblocks on a filesystem?
    1. assumes filesystem was created with default parameters
    2. /usr/sbin/newfs -N device | awk '/^ [0-9]/'
  2. ^^ How do I grow/shrink a ufs filesystem?
    1. Grow
      1. Unmounted filesystem (not /, /usr, /var)
        1. Allocate additional contiguous disk space with format(1m)
          1. Unnecessary if you are using a volume manager
        2. /usr/lib/fs/ufs/mkfs -G rawdevice newsize
      2. Mounted filesytem (not /, /usr, /var)
        1. Allocate additional contiguous disk space with format(1m)
          1. Unnecessary if you are using a volume manager
        2. /usr/lib/fs/ufs/mkfs -G -M mountpoint rawdevice newsize
    2. Shrink
      1. You cannot shrink a UFS filesystem
  3. ^^ How do I determine what type of filesystem a given device has?
    1. /usr/sbin/fstyp blockdevice
  4. ^^ What are inodes 0, 1, and 2 used for?
    1. Inode 0 is unusable. It is used to mark unused inodes.
    2. Inode 1 is unusable. Use of this inode for bad block information is deprecated.
    3. Inode 2 is "/" or "root" of the filesystem.
  5. ^^ What do I do if I have a corrupt boot block?
    1. ok boot cdrom -s
    2. /usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c#t#d#s#
  6. ^^ What is the DNLC?
  7. 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?
  1. 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?
  1. A value of 90% or less requires tuning.
  2. Method 1 (recommended)
    1. /usr/bin/vmstat -s | /usr/bin/grep "name lookup"
  3. Method 2
    1. Solaris 2.6 / 7
      1. echo '*ncstats*0t100%(*ncstats+*(ncstats+4)+*(ncstats+14))=D' | /usr/bin/adb -k
    2. Solaris 8 / 9 / 10
      1. 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?
  1. 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.
  2. this is done on a per filesystem, rather than per file basis
  3. direct i/o can be dangerous when used on filesystems that are accessed by applications that do not buffer data internally
  4. Method 1 (persistent)
    1. Add "forcedirectio" to mount options in /etc/vfstab
  5. Method 2 (not persistent, system up)
    1. /usr/sbin/mount -o remount,forcedirectio,(other options) /mountpoint
^^ How do I disable "access time" updates for file?
  1. This is useful for web servers and news servers to prevent unnecessary file I/O.
  2. Add "noatime" to mount options in /etc/vfstab
^^ What is the difference between file mode 1 and 5?
  1. mode 1 allows exec() of the binary
  2. mode 5 allows exec() of the binary and processes to mmap() pages from within userspace
  3. 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?
  1. Solaris 2.6 / 7
    1. there is no special flag to the umount() system call that allows this
  2. Solaris 8 / 9 / 10
    1. /usr/sbin/umount -f /mount
^^ What is the default ufs block size?
  1. 8192 bytes logical block, 1024 bytes fragment size
^^ X11
  1. ^^ How do I use an alternate window manager?
    1. Bypassing CDE
      1. echo "exec /path/to/alternate/window/manager" > .xsession
    2. Maintaining CDE
      1. Xresources
        1. cd /usr/dt/config/C/Xresources.d
        2. /usr/bin/cp Xresources.ow Xresources.wm
        3. Modify Xresources.wm
          1. Dtlogin*altDtName: Alternate WindowManager
          2. Dtlogin*altDtKey: /path/to/alternate/window/manager
          3. Dtlogin*altDtStart: /usr/dt/config/Xsession.wm
          4. Dtlogin*altDtLogo: WMlogo
      2. Xsession
        1. cd /usr/dt/config
        2. /usr/bin/cp Xsession.ow Xsession.wm
        3. Modify Xsession.wm
          1. Place windowmanager environment
      3. Logo (for display in CDE login)
        1. cd /usr/dt/appconfig/icons/C
        2. /usr/bin/cp OWlogo.pm WMlogo.pm
          1. Replace this with your own XPM file
  2. ^^ How do I disable X Windows from starting at boot?
    1. Method 1 (recommended)
      1. /usr/dt/bin/dtconfig -d
    2. Method 2
      1. /usr/bin/mv /etc/rc2.d/S99dtlogin /etc/rc2.d/s99dtlogin
  3. ^^ How do I disable that annoying beep?
    1. Method 1
      1. /usr/openwin/bin/xset b 0
    2. Method 2
      1. /usr/openwin/bin/xset b off
    3. Method 3
      1. /usr/openwin/bin/xset -b
  4. ^^ How do I disable the CDE front panel?
    1. Modify $HOME/.Xdefaults
      1. Dtwm*useFrontPanel: false
  5. ^^ How do I determine which X11 version and extensions are supported?
  6. /usr/openwin/bin/xdpyinfo -v
^^ Crash Dump
  1. ^^ When did it happen?
    1. Method 1 (to the minute)
      1. /usr/bin/who -b
    2. Method 2 (to the second)
      1. Solaris 2.6 / 7
        1. Become root
        2. echo '*time-(*lbolt%64)=Y' | /usr/bin/adb -k
      2. Solaris 8 / 9 / 10
        1. Become root
        2. echo '*time-(*lbolt%64)=Y' | /usr/bin/mdb -k
  2. ^^ How do I get information about what was going on?
    1. Enable savecore
      1. Solaris 2.6
        1. disabled by default
        2. Modify /etc/init.d/sysetup
          1. Uncomment last 6 lines
      2. Solaris 7 / 8 / 9 / 10
        1. Enabled by default
        2. Enable with '/usr/bin/dumpadm -y'
    2. Default file locations
      1. Corefile is /var/crash/`uname -n`/vmcore.n
      2. Namelist is /var/crash/`uname -n`/unix.n
    3. Process status
      1. Solaris 2.6 / 7
        1. Open the crash interpreter
        2. /usr/sbin/crash -d corefile -n namelist
          1. p -e
            1. The "p" command reads the process table
      2. Solaris 8 / 9 / 10
        1. Open the modular debugger
        2. /usr/bin/mdb namelist corefile
          1. ::ps
            1. The "::ps" command reads the process table
    4. Network status
      1. /usr/bin/netstat namelist corefile
    5. IPC status
      1. /usr/sbin/ipcs -C corefile -N namelist
^^ Veritas Volume Manager
  1. ^^ How do I allow a user to write to a managed raw device?
    1. /usr/bin/chown is not persistent across reboots
    2. /usr/sbin/vxedit set user=oracle group=dba mode=600 volume
  2. ^^ How do I move rootdg from one system to another?
    1. without this procedure, you will get error messages at boot because the system sees two instances of rootdg
    2. /etc/vx/diag.d/vxprivutil list /dev/rdsk/c#t#d#s# | awk '/^group/'
      1. note the disk group id number
    3. /usr/sbin/vxdg -C -n newdg import dgid
      1. dgid is group id from (a)
      2. this command creates disk group newdg and imports the disk
  3. ^^ What is the difference between Disk Suite and Veritas Volume Manager?
    1. Veritas Volume Manager logs metadata and filesystem data, whereas Disk Suite logs only metadata
  4. ^^ What is the difference between RAID 0+1 and 1+0?
    1. Diagram A (RAID 0+1)
      1.                                    [ v]
                                            ||
                                           [ p]
                                            ||
                                           [sv]
                                            ||
                    =======================[v2]=======================
                    |                                                |
                    ==========[p2]==========  ==========[p2]==========
                    |                      |  |                      |
                    =[s2]==[s2]==[s2]==[s2]=  =[s2]==[s2]==[s2]==[s2]=
             
      2. Striping occurs at the subvolume(p2) layer.
      3. Mirroring occurs at the subplex (v2) layer.
    2. Diagram B (RAID 1+0)
      1.                                      [ v]
                                              ||
                                             [ p]
                                              ||
                   ==========================[sv]==========================
                   |                                                      |
                   ===========[v2]===========    ===========[v2]===========
                   |                        |    |                        |
                   ====[p2]====  ====[p2]====    ====[p2]====  ====[p2]====
                   |          |  |          |    |          |  |          |
                   =[s2]==[s2]=  =[s2]==[s2]=    =[s2]==[s2]=  =[s2]==[s2]=
             
      2. Striping occurs at the subvolume(sv) layer.
      3. Mirroring occurs at the subplex (p2) layer.
    3. The diagrams above use the Veritas 3.x nomenclature.
    4. Volume Resynchronization
      1. 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.
    5. Fault Tolerance
      1. 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
  1. ^^ How do I make vxfs support large files?
    1. /usr/lib/fs/vxfs/fsadm -o largefiles /mountpoint
  2. ^^ How do I defragment a vxfs filesystem?
    1. Determine if necessary
      1. Method 1
        1. /usr/lib/fs/vxfs/df -o s /mountpoint
      2. Method 2
        1. /usr/lib/fs/vxfs/fsadm -ED /mountpoint
          1. reports on both extent and directory fragmentation
    2. /usr/lib/fs/vxfs/fsadm -ed /mountpoint
      1. reorganizes extents and directories
  3. ^^ How do I grow/shrink a vxfs filesystem?
    1. vxfs, unlike ufs, filesystems can be shrunk.
    2. Mounted filesystem (not /, /usr, /var)
      1. /usr/lib/fs/vxfs/fsadm -b size /mountpoint
  4. ^^ How do I prevent the vxfs filesystem from buffering my database files?
    1. Method 1 (persistent)
      1. Add "mincache=direct,convosync=direct" to mount options in /etc/vfstab
    2. Method 2 (not persistent, system up)
      1. /usr/sbin/mount -o remount,mincache=direct,convosync=direct,<other options> /mountpoint
      2. [UNVERIFIED] please email if you can confirm
    3. Method 3 (Quick I/O)
      1. This is presented as an add-on module for filesystem and ships with Veritas Database Edition.
      2. 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
      3. Quick I/O is enabled per filesystem, by default, but is configured on a per file basis
  5. ^^ How do I create a Quick I/O file?
    1. Oracle
      1. /usr/sbin/qiomkfile -h <header size> -s <extent size> /path/to/dbfile
        1. <header size> should correspond to DB_BLOCK_SIZE, 32k by default
        2. <extent size> should correspond to the size of the database. by allocating appropriate extents you can prevent fragmentation
  6. ^^ What is the default vxfs block size?
    1. Filesystem size <= 8GB
      1. 1024 bytes
    2. Filesystem size 8GB <= 16GB
      1. 2048 bytes
    3. Filesystem size 16GB <= 32GB
      1. 4096 bytes
    4. Filesystem > 32GB
      1. 8192 bytes
^^ Network
  1. ^^ Physical Layer
    1. ^^ How do I find the speed my network card is at?
      1. /usr/sbin/ndd -set /dev/hme instance 0
        1. Instance 0 - hme0
        2. Instance 1 - hme1
      2. /usr/sbin/ndd -get /dev/hme transciever_inuse
        1. 0 - onboard
        2. 1 - offboard card (mii)
      3. /usr/sbin/ndd -get /dev/hme link_status
        1. 0 - down
        2. 1 - up
      4. /usr/sbin/ndd -get /dev/hme link_speed
        1. 0 - 10Mb
        2. 1 - 100Mb
      5. /usr/sbin/ndd -get /dev/hme link_mode
        1. 0 - half duplex
        2. 1 - full duplex
    2. ^^ How do I configure what my network card is capable of?
      1. Method 1
        1. /etc/system
          1. this sets global defaults for the driver, therefore it is effective for all instances of the card
          2. HME/QFE/GE interfaces
            1. set hme:hme_adv_autoneg_cap=0
              1. Advertise auto negotiate capability
              2. 0 - off
              3. 1 - on
            2. set hme:hme_adv_100T4=0
              1. Advertise deprecated 100Mbit T4 capability
              2. 0 - off
              3. 1 - on
            3. set hme:hme_adv_100fdx=0
              1. Advertise 1000Mbit full duplex capability
              2. 0 - off
              3. 1 - on
            4. set hme:hme_adv_100hdx=0
              1. Advertise 100Mbit half duplex capability
              2. 0 - off
              3. 1 - on
            5. set hme:hme_adv_10fdx=0
              1. Advertise 10Mbit full duplex capability
              2. 0 - off
              3. 1 - on
            6. set hme:hme_adv_10hdx=0
              1. Advertise 10Mbit half duplex capability
              2. 0 - off
              3. 1 - on
          3. ERI interfaces
            1. set eri:adv_autoneg_cap=0
              1. Advertise auto negotiate capability
              2. 0 - off
              3. 1 - on
            2. set eri:adv_100T4=0
              1. Advertise deprecated 100Mbit T4 capability
              2. 0 - off
              3. 1 - on
            3. set eri:adv_100fdx=0
              1. Advertise 100Mbit full duplex capability
              2. 0 - off
              3. 1 - on
            4. set eri:adv_100hdx=0
              1. Advertise 100Mbit half duplex capability
              2. 0 - off
              3. 1 - on
            5. set eri:adv_10fdx=0
              1. Advertise 10Mbit full duplex capability
              2. 0 - off
              3. 1 - on
            6. set eri:adv_10hdx=0
              1. Advertise 10Mbit half duplex capability
              2. 0 - off
              3. 1 - on
      2. Method 2
        1. This method allows more granular control over the interface driver. You can specify configuration by port.
        2. /usr/sbin/ndd -set /dev/hme instance 0
          1. Instance 0 - hme0
          2. Instance 1 - hme1
        3. /usr/sbin/ndd -set /dev/hme adv_autoneg_cap 0
          1. Advertise auto negotiate capability
          2. 0 - off
          3. 1 - on
        4. /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 0
          1. Advertise 100Mbit full duplex capability
          2. 0 - off
          3. 1 - on
        5. /usr/sbin/ndd -set /dev/hme adv_100hdx_cap 0
          1. Advertise 100Mbit half duplex capability
          2. 0 - off
          3. 1 - on
        6. /usr/sbin/ndd -set /dev/hme adv_100T4_cap 0
          1. Advertise deprecated 100Mbit T4 capability
          2. 0 - off
          3. 1 - on
        7. /usr/sbin/ndd -set /dev/hme adv_10fdx_cap 0
          1. Advertise 10Mbit full duplex capability
          2. 0 - off
          3. 1 - on
        8. /usr/sbin/ndd -set /dev/hme adv_10hdx_cap 0
          1. Advertise 10Mbit half duplex capability
          2. 0 - off
          3. 1 - on
    3. ^^ How do I display what my link partner is capable of?
      1. /usr/sbin/ndd -set /dev/hme instance 0
        1. Instance 0 - hme0
        2. Instance 1 - hme1
      2. /usr/sbin/ndd -get /dev/hme lp_autoneg_cap
        1. link partner has auto negotiate capability
        2. 0 - off
        3. 1 - on
      3. /usr/sbin/ndd -get /dev/hme lp_100fdx_cap
        1. link partner has 100Mbit full duplex capability
        2. 0 - off
        3. 1 - on
      4. /usr/sbin/ndd -get /dev/hme lp_100hdx_cap
        1. link partner has 100Mbit half duplex capability
        2. 0 - off
        3. 1 - on
      5. /usr/sbin/ndd -get /dev/hme lp_100T4_cap
        1. link partner has deprecated 100Mbit T4 capability
        2. 0 - off
        3. 1 - on
      6. /usr/sbin/ndd -get /dev/hme lp_10fdx_cap
        1. link partner has 10Mbit full duplex capability
        2. 0 - off
        3. 1 - on
      7. /usr/sbin/ndd -get /dev/hme lp_10hdx_cap
        1. link partner has 10Mbit half duplex capability
        2. 0 - off
        3. 1 - on
    4. ^^ How can I tell if my card is active on the network?
      1. Method 1 (Openboot PROM)
        1. watch-net
    5. ^^ How do I use multiple ethernet interfaces on the same network segment?
      1. Method 1 (modern cards, 1997+)
        1. Modern Sun Adapters have unique mac addresses encoded in the FCode Prom.
        2. /usr/sbin/eeprom local-mac-address?=true
      2. Method 2 (older cards)
        1. 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.
                
        2. Setting the LAA bit can be done by using a 0A hex as the first digit instead of 08.
        3. /usr/sbin/ifconfig hme1 ether 0a:0:20:00:01
    6. ^^ How do I determine if local mac addresses are in use on my host?
      1. /usr/sbin/prtconf -pv | /usr/bin/grep local-mac-address
  2. ^^ Transport Layer
    1. ^^ How do I configure stronger sequence number generation?
      1. 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.
             
      2. /usr/sbin/ndd -set /dev/tcp tcp_strong_iss 2
        1. 0 - Sequential
        2. 1 - Random increment variance (Default)
        3. 2 - RFC 1948, unique-per-connection-ID.
      3. Modify /etc/default/inetinit.
        1. 1. TCP_STRONG_ISS=2
    2. ^^ I have a large amount of connections in state CLOSE_WAIT, what can be done to reduce this number in the future?
    3. Increase Connection Hash Table
    4. Used for faster connection lookups
  3. 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?
  1. Increase Transmit Window
    1. Increasing this value in excess of the 16bit window defined in RFC793, as SEG.WND, causes the Window Scaling option as defined in RFC1323.
    2. Increasing this value takes additional memory
    3. Solaris 8
      1. Default is 16384
    4. Solaris 9 / 10
      1. Default is 49152
    5. /usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 65536
  2. Increase Receive Window
    1. Increasing this value in excess of the 16bit window defined in RFC793, as SEG.WND, causes the Window Scaling option as defined in RFC1323.
    2. Increasing this value takes additional memory
    3. Solaris 8
      1. Default is 24576
    4. Solaris 9 / 10
      1. Default is 49152
    5. /usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 65536
^^ What do all the TCP states actually mean?
  1. CLOSED (0)
    1. Socket is closed
  2. LISTEN (1)
    1. Socket is passive, awaiting a connection request
  3. SYN_SENT (2)
    1. Socket is active, has sent a SYN
    2. Session not yet active
  4. SYN_RECEIVED (3)
    1. Socket is active, has sent and received SYN
    2. Session not yet active
  5. ESTABLISHED (4)
    1. Socket is active
    2. Session is active, has completed handshake
  6. CLOSE_WAIT (5)
    1. Socket is closed, received FIN, waiting for close
    2. Session is terminating
  7. FIN_WAIT (6)
    1. Socket is closed, sent FIN, waiting for FIN ACK
    2. Session is terminating
  8. CLOSING (7)
    1. Socket is closed, exchanged FIN, waiting for FIN ACK
    2. Session is terminating
  9. LAST_ACK (8)
    1. Socket is closed, received FIN, waiting for FIN ACK
    2. Session is terminating
  10. FIN_WAIT_2 (9)
    1. Socket is closed, received FIN ACK
    2. Session is complete
  11. TIME_WAIT (10)
    1. Socket is closed, waits for ( 2 * max segment life )
    2. Session is complete

转载于:https://www.cnblogs.com/cqubityj/archive/2012/03/21/2409242.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值