Solaris Tips & Tricks
Boot:
- You can reach the ok prompt by issuing a 'break' if you are connected to the sun box via console, or by pressing 'Stop-A' from the system's keyboard. You can also issue 'init 0', which will take you to the ok prompt.
- Find the PROM Revision for a System? Type in 'banner' at the 'ok' prompt (http://docs.sun.com/db/doc/817-1658/6mhcgstpg?a=view).
- Identify Devices on the System? 'setenv auto-boot? false', 'reset-all', 'probe-' (e.g. probe-scsi or probe-ide).
- Change the default boot device? 'setenv boot-device device[n]', where 'device' can be 'disk' or 'network', and 'n' can identify the disk number, for example (verify with 'printenv boot-device')
- You can boot in single mode by typing 'boot -s' at the 'ok' prompt. You can check the runlevel with 'who -r'.
- To boot a system interactively, one has to type in 'boot -a' at the 'ok' prompt. He/she will be asked for the name/path of the kernel, default directory(-ies) for modules, name of the system, root filesystem type (default 'ufs'), and path of the root device.
To boot a system interactively, 'boot -a' at the ok prompt.
NFS:
- There is no "/etc/exports" file on Solaris, but rather "/etc/dfs/dfstab". To share a resource, use "share(1M)". To share all the local resources specified in "/etc/dfs/dfstab", use "shareall(1M)".
Removable media:
- rmformat: format, label and set read/write software protection
- mkfs_pcfs and fsck_pcfs: tools for creating, checking and repairing PC filesystems.
- vold, the volume manager, can be configured via /etc/vold.conf
- Working with removable media means working with commands like 'vold' and 'volcheck'. Stopping the volume management: '/etc/init.d/volmgt stop'. You can find out if Removable media is still in use by using the command 'fuser'.
- Access to the removable media is by default granted to all the users, but can be restricted via RBAC. One can establish a new role, grant access to that resource (cdrw, for example), assign this role to all the users that need it, and then comment that resource out of '/etc/security/policy.conf' (for cdrw, that is "AUTHS_GRANTED=solaris.device.cdrw").
- "devfsadm" is a utility for making modifications to the dev filesystem.
Installing and removing software:
- One file can be removed from the disk and the software database with removef(1M).
Kernel:
- The platform-independent kernel is '/kernel/genunix', and the platform-specific kernel is '/platform/`uname -m`/kernel/unix'.
- Some infos about the device drivers loaded in the kernel can be found with: prtdiag(1M), sysdef(1M) and dmesg(1M).
- Some interesting kernel statistics are browseable via 'kstat(1M)' and 'netstat -k'.
- kadb is the kernel debugger. In order to force a crash dump, Stop-A, 'sync' at the ok prompt and then reboot.
- The drivers are found under '/kernel/drv' and '/platform/`uname -m`/kernel/drv'. After a device was added to the system (non-hot-pluggable), remember to 'touch /reconfigure', so that at the next reboot of the system the autoconfiguration will search for new devices, and load the driver for those devices. For the hot-pluggable SCSI and PCI devices, you can use 'cfgadm' to make those devices usable by the system.
- Modinfo/modunloa can be used to manage the kernel modules.
Accessing devices:
- 'devfsadm(1M)' command manages the devices in both '/dev' and '/devices'. It tries to connect a driver for each device found, and it creates the device files in '/devices' and the symlink in '/dev'. It also manages the 'path_to_inst(4)' database (to be found in '/etc/path_to_inst')
- The physical devices are to be found in '/devices'. Instance names are kernel abbreviations for every possible device on the system. The logical device names are used with most file system commands to refer to devices (located in '/dev').
General tips & tricks:
- The runlevel can be checked with 'who -r'. The runlevels are:
S -- single user
0 -- shutdown
1 -- administrative (access all filesystems, but user logins are disabled)
2 -- multiuser without NFS
3 -- normal, multiuser with NFS resources shared
5 -- powerdown with auto-poweroff
6 -- stop & reboot
- To find out the PROM revision from inside PROM, type 'banner'. The complete PROM commands from within Solaris are monitor and eeprom(1M).
- /etc/dispadmin.conf specifies the default scheduling class
- Snoop can be used to snoop an active interface.
- Management of diskless clients can be done with 'smosservice' and 'smdiskless'.
- in order to boot the 64 bit kernel instead of the 'default' 32, boot "kernel/sparcv9/unix" (as described in boot(1M))
- One can share local media by NFS, by editing the file '/etc/dfs/dfstab', adding a line like 'share -F nfs -o ro /dummy' (/dummy is the mount point), 'chmod 644 /etc/rmmount.conf', add the line 'share cdrom*' in that file, 'chmod 444 /etc/rmmount.conf' and then running 'share' for checking if the resource is indeed shared or not. ON THE CLIENT, you have to run 'showmount -e system-name' in order to see how the media is called, and then 'mount -F nfs -o ro system-name:/media/media-name local-mount-point'.
- When you need to check for patches, go to http://sunsolve.Sun.COM/pub-cgi/show.pl?target=patches/patch-access. In order to patch your system, you have to use: patchadd/patchrm, or PatchPro (downloadable from http://www.sun.com/PatchPro). 'smpatch update' will automatically check for the new patches the system needs, download them and install them on your system. You can also try 'smpatch analyze', 'smpatch download' and 'smpatch add'.
- Disks have device names like 'cWtXdYsZ', where W is the logical controller number, X is the physical bus target number, Y is the drive number and Z is the slice number (0-7) or the fdisk partition (0-4). The tapes have devices located under '/dev/rmt', their names being like 'XY', where X is the drive number, and Y can be one of: l (low), m (medium), h (high), u (ultra), c (compressed).
- 'newfs -T' will create a filesystem that can be expanded in the future to a multi-terabyte filesystem with 'growfs'. Also, UFS logging is enabled by default on systems with multiterabytes support, which means that 'fsck' doesn't have to be run at boot time. But a multiterabyte filesystem still has the limitation of a max file size of 1TB, and 1million files/TB. As well, a multiterabyte filesystem cannot be used as a root ('/') filesystem.
- The volume manager commands: 'metattach', 'metastat' (the devices are in /dev/md/rdsk).
- Enable Direct I/O for a filesystem with: "mount -forcedirectio". According to the Basic Administration Guide, "The direct I/O improvements brings I/O bound database performance on a UFS file system to about 90% of raw partition access speeds", which ain't that bad, is it? Besides direct I/O, logging should also be considered when mounting a filesystem.
- "labelit", "fsdb", "fstyp", "ncheck", "volcopy", "clri", "ff" -- interesting commands for Solaris filesystem administration.
- AutoFS (see automount/automountd) has a nice feature, through which you can specify a list of servers which offer the same file system, so if it doesn't succeed mounting the filesystem from one server, it tries the next one.
- You can find out details about the CPUs in the system with psrinfo(1M). With psradm(1M), one can take a CPU offline/online/no-intr (online - LWP + IRQs;, off-line -normally no LWPs or IRQs, but on some CPUs IRQs cannot be completely disabled; no-intr - only LWPs, but no IRQs).
- prstat(1M) is the equivalent of top, show statistics about the processes running on the system, and also user/project-based stats.
- When a box needs reconfiguration, one can run 'sys-unconfig(1M)', which will reset the box it it's 'as-manufactured' state and shutdown. After rebooting, you will be asked all the configuration questions all over again.
- /usr/sbin/sys-unconfig might worth remembering