########################################################################## # Solaris Notes # # Anuradha Weeraman, 2001 # # $Id: solaris-notes.txt,v 1.1 2004/06/02 21:17:54 anuradha Exp $ # ########################################################################## ----- Installation minimum requirements Solaris 7 requires a minimum of 16MB and PROM level 1.1 or higher. Solaris software is grouped into packages, which in turn is grouped into software clusters. Solaris 7 has approx. 80 packages amounting to 900MB of disk space. Clusters are in turn grouped into four configuration clusters for ease of installation. They are end-user system support : 500MB developer system support : 700MB entire distribution : 900MB entire distribution plus OEM system support : 900MB These are similar to meta-packages or virtual packages in Linux distributions. ---------- ----- Differences with Linux 'ps aux' -> 'ps aef' on /dev/dsk/c0d0s0: fdisk /dev/rdsk/c0d0p0 to get the current runlevel: who -r /var/log/messages -> /var/adm/messages Kernel modules can be checked by 'modinfo'. kernel modules can be loaded and unloaded using 'modload' and 'modunload' respectively. ---------- ----- pgrep Similar to 'ps aux | grep something' ---------- ----- init For each runlevel, there is a script in /sbin such as /sbin/rc1.d /sbin/rc2.d .... these execute scripts in /etc/rc?.d in ascii sorted order. [K,S][0-9][0-9][A-Z] When you make changes to /etc/inittab, do an 'init q' to restart it. look into /etc/inittab for more details If you do not want a particular script to run when entering a particular runlevel, change the uppercase S or K filename to a lowercase one. ---------- ----- Kernel Important kernel information is stored in /etc/system ---------- ----- booting OpenBoot PROM -> bootblk (Boot PROM phase) -> ufsboot (Boot program phase) -> kernel -> init boot -a : interactive boot boot -r : reconfiguration boot boot -s : boots into single-user state boot -v : boots in verbose mode The first task of kernel after initialization is to start the swapper process. it is involved in scheduling other processes. It has a process id of 0. Its first job is to start init. Init is the mother of all processes. It examines /etc/inittab which has the following format : id:runlevel:action:process Fields with action set to sysinit is run first and then the scripts according to the default run level specified. ---------- ----- Shutting down /usr/sbin/shutdown : sends warning to users, waits for 60 seconds, performs graceful shutdown to the single user state. syntax : shutdown -i -g -y /sbin/init : no warnings will be issued and the runlevel scripts will be executed. init 0 will perform a shutdown while init 6 a reboot. syntax : init /usr/sbin/halt : use it when the system must be stopped immediately. no warning will be issued. /usr/sbin/reboot : like halt, it does and unconditional shutdown of the system without warning users. but they do synchrnize file systems. /usr/sbin/poweroff : is equivalent to init 5 When a system has crashed or hung, you can press 'STOP+A' or 'L1-A' to get back to boot PROM. On terminals, press the BREAK key. When at the boot PROM prompt, type 'sync' to synchronize the disks. Press the abort sequence again and type 'reset' to reset the hardware and start the boot process. ---------- ----- Startup order 1. Plug in the power cables 2. Turn on the monitor 3. Turn on disk drives, tape drives and printers 4. Turn on the CPU ---------- ----- SPARC SPARC - Scaleable Processor ARChitecture ---------- ----- OpenBoot PROM, Booting and the UNIX Kernel OpenBoot PROM (OBP) is based on an interactive command interpreter. Its firmware is stored in the socketed startup PROM. It consists of two chips, the startup PROM itself, which contains extensive firmware allowing access to user-written startup drivers and extended diagnostics, and an NVRAM chip. it has the user-definable system parameters and writable areas for user- controlled diagnostics, macros and device aliases. Its where system identification information such as the hostid is stored. OpenBoot is currently at version 3. it was first introduced with the sun SPARCstation 1. version 2 came with SPARCstation 2 and currently version 3 comes with the Ultra series systems. Version 3 has advancements such as its programmable user interface based on the interactive programming language forth. Accessing the OpenBoot environment : 1. By halting the operating system 2. By pressing Stop+A 3. When the system starts up and when its not configured to boot unattended, it stops at the openboot prompt. 4. If the system detects a hardware error from which it cannot recover (this is known as a watchdog reset) OpenBoot allows device drivers to be loaded from a plug-in device such as an SBUS card. This lets devices evolve without changing the system PROM. Plug-in drivers are written in a machine-independent interpreted language called FCode. each OpenBoot PROM contains an FCODE interpreter, this allows the same device driver to be used on machines with different CPU instruction sets. Nodes with children usually represent buses and their assiciated controllers. Each child of that node is assigned a physical address in the parent's address space. It usually contains a physical characteristic unique to the device such as the bus address or the slot number. Its user interface is programmable by the use of the interactive programming language Forth. On older Sun systems such as SPARCstation10 and SPARCstation20, the command line interface has two modes : the restricted monitor and the forth monitor. The restricted monitor provides a simple set of commands to initiate booting of the system execution, or enter the forth monitor. The restricted monitor is also used to implement system security. The restricted monitor prompt : Type b (boot), c (continue), or n (new command mode) > The forth monitor is the default mode in OpenBoot. Its an interactive command interpreter and gives you access to an extensive of function for hardware and software diagnosis. The forth monitor prompt is 'ok'. when you enter the forth monitor mode, the following screen is displayed : Type help for more information ok On older sparcstations, to exit the forth monitor and enter the restricted monitor, type : ok old-mode (ok is the prompt) OpenBoot also deals directly with the hardware. It identifies them in the following format : driver-name@unit-address:device-arguments eg. /sbus@lf,0/esp@0,40000/da@3,0:a Its a series of nodes separated by slashes. The unit-address is a text string representing the physical address of the device in its parent's address space. The openboot command 'show-devs' can be used to get a listing of all devices. since device paths are long, device aliases can be used to simplify the task. standard device aliases are : disk /sbus@1,f8000000/esp@0,40000/sd@3,0:a disk1 /sbus@1,f8000000/esp@0,40000/sd@1,0:a disk2 /sbus@1,f8000000/esp@0,40000/sd@2,0:a disk3 /sbus@1,f8000000/esp@0,40000/sd@3,0:a The 'devalias' command can be used to change or add device aliases : devalias - displays current device aliases devalias_alias - displays device pathname of 'alias' devalias_alias device-path - defines an alias devalias disk3 /iommu/sbus/espdma@f,40000/esp@f,800000/sd@3,0 These user-defined aliases are lost on reboot. If you want permanent aliases, you need to put them into nvram, which can be done using 'nvalias' and 'nvunalias'. More openboot commands : password sets the security password printenv [variable] displays the current and default value for each variable setenv var value sets variable. takes effect only after a reboot set-default variable resets variable to factory default set-defaults resets variables to the factory defaults It is also possible to set these variables up using the commandline using the 'eeprom' command. eg. eeprom auto-boot?=true eeprom eeprom security-password= Changing PROM password: New password: Retype new password: There is no way to break into the system if you forget the password. Beware. It is also possible to reset the variables to factory defaults by pressing Stop+N while the machine is powering up. The security password should only be set using the two above-mentioned ways. The password should have 0-8 chars. after setting the password you can set the security mode using : setenv security-mode [full|command|none] full - all openboot commands except 'go' require a password command - all ob commands except boot and go require a password none - no password is required (default) The following perform the openboot diagnostics : probe-scsi probe-scsi-all (if you have more than one scsi bus) test device-specifier test floppy test net test-all [device-specifier] watch-clock watch-net Type 'eject-floppy' to remove the diskette. The following are system information commands : banner (displays the power on banner) show-sbus (list of installed and probed SBus devices) .enet-addr (current Ethernet address) .idprom (displays ID PROM contents, formatted) .traps (list of SPARC trap types) .version (version and date of the startup PROM) .speed (CPU and bus speeds) show-devs The console is used as the primary means of communication between OpenBoot and the user. The console consists of an input device and an output device. The following are the console configuration variables : input-device console input device (usually keyboard, ttya, ttyb) output-device console output device (usually screen, ttya, ttyb) screen-#columns default is 80 screen-#rows default is 34 These values do not take effect until next power cycle. If keyboard is specified but not found, it falls back on ttya, the serial port, for the system console. boot has the following syntax : boot [OBP name] [filename] [options] [flags] OBP name can be a physical path or a devalias. Filename is the location of the kernel, it defaults to /platform/platform-name/kernel/unix. options are -a, -f, -r. eg. boot disk3 boot -a boot disk3 -a The PROM assumes that the program for the primary startup (bootblk) is in the primary bootblock, which resides in blocks 1 to 15 of the startup device. the bootblock is created using the installboot command. installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0 The program in the bootblock are will load the secondary startup program, ufsboot if booting from disk, or inetboot if booting across the network. Ufsboot will search for the kernel in a platform dependent search path. it usually is : /platform/platform-name. /platform/`uname -m` boot disk5 kernel/unix -s bootblk will hand control over to ufsboot which in turn will search and load the standalone program /platform/SUNW,SPARCstation-10/kernel/unix using -s flag also equal to /platform/sun4m/kernel/unix with the -s flag. The kernel usually is : /platform/`uname -m`/kernel/unix The kernel initializes and begins loading modules using ufsboot to read the files. After loading enough modules to mount the root filesystem, it unmaps ufsboot program and continues using its own resources. It then starts the swapper and initializes init. It consists primarily of a small static core and many dynamically loadable kernel modules. The command 'modinfo' provides info about currently loaded kernel modules. When the kernel loads, it reads /etc/system for configuration information. The command 'sysdef' can be used to verify changes to kernel at boot time. The command 'adb' can change kernel parameters on a running system and could potentially crash or corrupt your system if used improperly. it can also be used to verify changes to kernel. adb -k /dev/ksyms /dev/mem /dev/ksyms is a special file that provides an image of the kernel's symbol table. This can be used to examine the information in memory. By typing the name of the variable you are looking for followed by how you want it to appear (/D for decimal and /X for hex) you can see the value of the variable : maxusers/D ----------- ----- Platform You can use 'uname -i' to figure out your platform name You can use 'uname -m' to get the hardware class of your machine. for SPARCstation10, the hardware-class-name will be sun4m. ----------- ----- System configurations Server /, /usr, swap /export, /export/swap, /export/home /opt Clients Diskless clients remotely mounts /, /usr/, /export/home, swap Javastation clients (easiest, when it comes to administration) ditto, no local administration Solstice autoclients (relatively low network overhead) 100MB+ disk, cacheFS /, /usr are remote, but cached locally good field-replaceable unit (FRU) Stand-alone systems /, /usr, /home, swap ---------- ----- Installation If you already have a pre-installed version of solaris, 'shutdown' and 'halt' it. It will put you at 'ok' or '>' prompt. if you are at the '>' prompt instead of the 'ok' prompt, press 'n'. Insert the cd in the drive and say 'boot cdrom'. Solaris has several methods of installation : interactive, custom jumpstart and webstart. Interactive does a step-by-step guided installation. It installs only the SunOS software, the others have to manually installed. Custom jumpstart, also known as auto-install requires an up-front setup of configuration files and automatically installs solaris. It only install the "end-user distribution group" and sets up minimal swap space. This is highly cost-effective when installing in bulk and ensures consistency. You can install the jumpstart software on existing systems by using the 're-preinstall' command. Web start is sun's browser-based "virtual assistant" for installing software. this can be used to create an installation profile to be used by jumpstart. If the system does not have a cdrom drive, solaris can also be installed across the network either from a remote cd or a cd image on a remote disk drive. This must be provided by an installation server. With the cd image either copied to the hard drive or the cdrom mounted and shared. The information you need to have beforehand : hostname, ip address, whether using NIS or NIS+. ---------- ----- Partitions and filesystems Like in the case of OpenBSD, Solaris partitions are known as slices. By default, home directories are located in the /export file system. the disk containing the /, /usr and swap partitions are known as the system disk. The others are known as secondary disks or non-system disks. Multiple disks lets you distribute the workload evenly among different I/O systems and avoids I/O bottlenecks. Having swap space distributed across disks increases performance. ---------- ----- Device naming conventions Devices are described in three different naming conventions in solaris : The physical device name The instance name The logical device name The physical device name represents the full device pathname of the device. eg. /devices/sbus@1,f8000000/esp@0,40000/sd@3,0:a The commands 'prtconf', 'sysdef' and 'dmesg' can be used to get information about the physical device names. The instance name represents the kernel's abbreviated name for every possible device on the system. eg. sd0, sd1 represents the instance names of two SCSI disk devices instance names are mapped in /etc/path_to_inst file. Logical device names in the /dev directory are symbolically linked to physical device files in the /devices directory. they are used in : adding a new disk to the system moving a disk from one system to another accessing (or mounting) a file system residing on a local disk backing up a local file system repairing a file system /dev/dsk - block interface to disk devices /dev/rdsk - raw or character interface to disk devices /dev/rmt - tape devices /dev/term - serial-line devices /dev/cua - dial-out modems /dev/pts - pseudo terminals /dev/fbs - frame buffers /dev/sad - STREAMS administrative driver Logical devices have major and minor numbers that indicate device drivers, hardware addresses and other characteristics. The logical device name for a disk has the following format : /dev/[r]dsk/cxtxdxsx where: cx refers to the scsi controller number tx refers to the scsi bus target number dx refers to the disk number (always 0, except on storage arrays) sx refers to the slice or partition number eg. /dev/dsk/c0t3d0s0 - refers to slice 0 on a scsi disk drive with a target id of 3 on scsi controller 0. buffered device. devices in /dev/rdsk have a raw or character interface while those in /dev/dsk have a buffered block interface. choosing on depends on the way the application was designed to handle. ---------- ----- UNIX file systems In UNIX, file systems have two basic components : files and directories. They can be disk-based, network-based or virtual file systems. Solaris uses a Virtual File System (VFS) architecture, which provides a standard interface for different file systems. Disk geometry is specified by means of heads, tracks, sectors and cylinders. Disk controller can be either separate as in SCSI or integrated as in IDE/EIDE. Areas where data cannot be written and retrieved reliably are known as defects. The controller tries to identify them and keeps track of them. The last two cylinders of a disk are set aside for diagnostic use and for storing the defect list. A special area of every disk is set aside for storing information about the disk controller, geometry and slices. This is known as the disk's label or Volume Table of Contents (VTOC). To label a disk is to write slice information. you usually label a disk after defining its slices. Partition table identifies the disk's slices. it can be displayed using 'format'. The following are disk-based file systems : UFS - the UNIX File system, based on BSD FAT Fast File System (the traditional UNIX file system.) HSFS - High Sierra and ISO 9660 file system, for using CD-ROMs. PCFS - PC file system, to read/write DOS-formatted disks Network File System (NFS) is an example of a network-based file system. Virtual file systems are virtual or memory-based file systems. most of them do no use file system disk space. cache file systems are an example. the following are some virtual file systems : SWAPFS - file system used by kernel for swapping. PROCFS - Process File System resides in memory. and is mounted in /proc where programs can access the processes' address space by using file system calls. LOFS - the Loopback File System lets you create a new virtual fs. CacheFS- the Cache File System lets you use disk drives on local workstations to store frequently used data from a remote system TMPFS - the temporary file system uses local memory for file system reads and writes, so its much faster. this also means that information stored in these are not permanent. its the default file system used by /tmp directory. when memory is insufficient to store files in TMPFS, it uses swap space. Always remember, slice 2 of any disk refers to the *whole* disk. Slices can be viewed using the 'prtvtoc' command. Solaris can have a maximum of 8 slices (0-7) on a single disk. Slices are bound by the below rules : each slice holds only one file system no file system can span multiple slices after created, its size cannot be modified, without repartitioning they cannot span multiple disks These can be overcome by using logical volumes. The system disk usually has only the following slices: /, /usr and swap. 'prtvtoc' can be used with the raw devices to get volume table of contents : prtvtoc /dev/rdsk/c0t3d0s2 A formatted disk holds only 90-95% of initial disk capacity due to overheads. The 'format' utility can be used in formatting disks, repairing, partitioning. Logical volumes can be managed by the following to unbundled Sun packages : Solstice DiskSuite Sun Enterprise Volume Manager They allow file systems to span multiple disks are provide for improved I/O and reliability compared to the standard solaris file system. They are known as Logical Volumes (LVM). Solstice DiskSuite comes with the server version of solaris. The Enterprise Volume Manager has to be purchased separately and is not part of the standard solaris operating system distribution. Typically, DiskSuite is used on Sun's multipacks while the Enterprise Volume Manager is used on SparcStorage arrays. UFS provide the following features : state flages : shows the state of the file system as clean, stable, active or unknown. these eliminate unnecessary fs checks extended fundamental types (EFT) : 32-bit UID, GID and device numbers Large file systems : a UFS file system can be as large as 1TB and can have regular files upto 2GB. UFS has the following types of blocks : Boot block - information used when booting the system Superblock - information about the file system Inode - stores all information about a file except its name Storage or data block - stores data for each file The Boot block is the first 8KB in a slice. Without the superblock, the fs becomes unreadable. Its located at the beginning of the disk slice and is replicated in each cylinder group. A copy is also kept up-to-date in memory this is why that if the system abruptly halts the file system could be in an inconsistent state. Use 'sync' to prevent this. An inode is 128 bytes and is stored in the cylinder information block. The maximum number of files in a UFS fs is dictated by the number of inodes. By default, one inode is allocated for each 2KB of data space. Storage blocks are also called data blocks and are allocated in two sizes : 4KB/8KB logical block size 1KB fragmentation size For regular files, the storage blocks contain the contents of the file. For a directory, the storage blocks contain entries that give the inode number and the filenames of the files in the directory. Blocks not currently used as inodes, indirect address blocks or storage blocks are marked as free in the cylinder group map. It also keeps track of fragments to prevent fragments fromd degrading disk performance. The 'newfs' command is a front-end to 'mkfs'. before a filesystem is to be created the disk must be formatted and divided into slices. 'newfs' removes any data and creates the skeleton of a directory structure, including the 'lost+found' directory. Its a good habit to run fsck on a newly created fs. newfs /dev/rdsk/c0t3d0s7 The percentage of free space allocated to root is determined by an equation rather than the 10% that used to be. This is more efficient. The logical block size is the size of the blocks that the UNIX kernel uses to read or write files. Its usually different from the physical block size (usually 512 bytes), which is the size of the smallest block that the disk controller can read or write. You cannot change the logical block size after creating a filesystem. By default it is 8192 bytes (8KB), it also supports block sizes of 4096 bytes (4KB). ***** PAGE 107 (TECHMEDIA) ***** ---------- ----- rsh & rsh restricted shell = /usr/lib/rsh remote shell = /usr/bin/rsh ---------- ----- Finding suids and sgid To search for all suids owned by root on the system : find / -user root -perm -4000 -exec ls -l {} \; To search for all sgids owned by root on the system : find / -group root -perm -2000 -exec ls -l {} \; ---------- ----- Text editors and pagers textedit (openwindows) dtpad (CDE) pg more less ---------- ----- Printing lp report lp -dlaserprinter report1 report2 report3 lpstat cancel ---------- ----- head or tail head -1 file1 tail -5 file2 tail -f logfile # displays continually ---------- ----- diff and patch echo "anuradha" > file1 echo "anuradha" > file2 echo "chathra" >> file2 diff file1 file2 > patchfile patch file1 < patchfile ---------- ----- Conversion unix2dos dos2unix ---------- ----- Transcript To get a transcript of all work done on the command line, use the 'script' command. It will invoke a new shell and record everything that takes places into a file called 'typescript' in the current directory. Just exit the new shell once you are finished. ---------- ----- Mail clients mailtool (openwindows) dtmail (CDE) mail (Berkeley) mailx (SysV) Netscape mail pine emacs xmh ---------- ----- Other 'dt' programs dtterm # terminal dtfile # file manager dtcm # calendar manager dtappgather # establishes search paths that the desktop will use ---------- ----- Killing X Kill the process 'Xsun' ---------- ----- Remapping mouse buttons With a three button mouse, you can make it a left handed mouse by : xmodmap -e 'pointer = 3 2 1' With a two button mouse : xmodmap -e 'pointer = 2 1' ---------- ----- ping Just 'ping host' alone will tell you whether the system is alive or not, to continually display the results, use 'ping -s host'. ---------- ----- whois whois sobell whois \!MS989 whois -h whois.arin.net 203.143.20 whois -h whois.arin.net AA000 # technical contact handle North American registry - whois.arin.net European registry - whois.ripe.net Asia-Pacific registry - whois.apnic.net American military - whois.nic.mil American government - whois.nic.gov ---------- ----- yp ypcat group ypmatch users group ----------