Thursday, November 12, 2009

Sun INIT States

Sun init States

Solaris init states refer to the level of services provided by the system. The exact services and processes run at each init level are determined by the scripts in the /etc/rc#.d directories. The default service levels for each init state are listed below:

* 0: The system is at the PROM monitor (ok>) or security monitor (>) prompt. It is safe to shut down the system when it is at this init state.
* 1, s or S: This state is known as "single-user" or "system administrator" mode. Root is the only user on the system, and only basic kernel functions are enabled. A limited number of filesystems (usually only root and /usr) are mounted. This init state is often used for sensitive functions (such as kernel libc patches) or while troubleshooting a problem that is keeping the system from booting into multiuser mode.
* 2: Multiple users can log in. Most system services (except for NFS server and printer resource sharing) are enabled.
* 3: Normal operating state. NFS and printer sharing is enabled, where appropriate.
* 4: Usually undefined.
* 5: Associated with the boot -a command. The system is taken to init 0 and an interactive boot is started.
* 6: Reboot. This state takes the system to init state 0 and then to the default init state (usually 3, but can be redefined in the /etc/inittab file).

The init states are defined in the /etc/inittab file, which usually points at the scripts in /sbin/rcrun-level. These scripts in turn examine the contents of the /etc/rcrun-level directories. The scripts in these directories whose names begin with the letter K are run in "stop" mode first in alphabetical order. Then the scripts whose names begin with the letter S are run in "start" mode in alphabetical order.

To get to a desired run level n, each of the rc (run control) scripts from 1 to n is run. To get to run level 0, the K scripts are run in each rc#.d directory between the current run level and 0 in reverse numerical order.

In the default configuration, the rc scripts accomplish the following tasks:

* /sbin/rc0
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
* /sbin/rc1
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
o Bring up the system in single-user mode.
* /sbin/rc2
o Set the TIMEZONE variable.
o Stop the print and NFS services.
o Stop the vold daemon.
o Mount local filesystems, enable disk quotas (as appropriate).
o Remove temporary files.
o Create new device entries if this is the result of a boot -r.
o Save a core file if enabled.
o Configure system accounting, (as appropriate).
o Set the default router.
o Set the NIS domain.
o Set up the network interfaces appropriately.
o Start inetd.
o Start named, if appopriate.
o Start rpcbind.
o Start kerbd (the Kerberos client daemon) if appropriate.
o Start ypbind or rpc.nisd as appropriate.
o Start keyserv.
o Start statd and lockd.
o Mount NFS filesystems from /etc/vfstab.
o Start the automounter.
o Start cron.
o Start lp daemons, as appropriate.
o Start sendmail.
* /sbin/rc3
o Clean up sharetab.
o Start nfsd and mountd.
o Start rarpd and rpc.bootparamd, as appropriate.
* /sbin/rc4 is usually not defined. It can be used in a non-default configuration to achieve a tailored run level.
* /sbin/rc5
o Kill print daemons.
o Unmount local file systems.
o Kill syslogd.
o Unmount NFS file systems.
o Stop NFS services.
o Stop NIS services.
o Stop RPC services.
o Stop cron services.
o Stop statd and lockd (NFS client services).
o Kill active processes.
o Initiate an interactive boot.
* /sbin/rc6
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
o Boots to the initdefault level from the /etc/inittab
* /sbin/rcS: This run level differs from 1 in the following particulars:
o Minimal network is established.
o System name is set.
o root, /usr and /usr/kvm filesystems are checked and mounted (if necessary).
o Pseudo file systems proc and /dev/ are started.
o Rebuilds device entries (for reconfiguration reboots only).

Read the rest of this entry...

Bookmark and Share My Zimbio http://www.wikio.com

Tuesday, October 27, 2009

ZFS Cheat Sheet

Create simple striped pool:
zpool create [pool_name] [device] [device] ...
zpool create datapool c5t433127A900011C370000C00003210000d0 c5t433127B4001031250000900000540000d0

Create mirrored pool:
zpool create [pool_name] mirror [device] [device] ...
zpool create datapool mirror c5t433127A900011C370000C00003210000d0 c5t433127B4001031250000900000540000d0

Create Raid-Z pool:
zpool create [pool_name] raidz [device] [device] [device] ...
zpool create datapool raidz c5t433127A900011C370000C00003210000d0 c5t433127B4001031250000900000540000d0 c5t439257C4000019250000900000540000d0

Transform simple pool to a mirror:
zpool create [pool_name] [device]
zpool attach [pool_name] [existing_device] [new_device]
zpool create datapool c5t433127A900011C370000C00003210000d0
zpool attach datapool c5t433127A900011C370000C00003210000d0 c5t433127B4001031250000900000540000d0

Expand simple pool:
zpool create [pool_name] [device]
zpool add [pool_name] [new_device]
zpool create datapool c5t433127A900011C370000C00003210000d0
zpool add datapool c5t433127B4001031250000900000540000d0

Expand mirrored pool by attaching additional mirror:
zpool add [pool_name] mirror [new_device] [new_device]
zpool add datapool mirror c5t433127A900011C370000C00003460000d0 c5t433127B400011C370000C00003410000d0

Replace device in a pool:
zpool replace [pool_name] [old_device] [new_device]
zpool replace datapool c5t433127A900011C370000C00003410000d0 c5t433127B4001031250000900000540000d0

Destroy pool:
zpool destroy [pool_name]
zpool destroy datapool

Set pool mountpoint:
zfs set mountpoint=/path [pool_name]
zfs set mountpoint=/export/zfs datapool

Display configured pools:
zpool list
zpool list

Display pool status info:
zpool status [-v] [pool_name]
zpool status -v datapool

Display pool I/O statistics:
zpool iostat [pool_name]
zpool iostat datapool

Display pool command history:
zpool history [pool_name]
zpool history datapool

Export a pool:
zpool export [pool_name]
zpool export datapool

Import a pool:
zpool import [pool_name]
zpool import datapool

Create a filesystem:
zfs create [pool_name]/[fs_name]
zfs create datapool/filesystem

Destroy a filesystem:
zfs destroy [pool_name]/[fs_name]
zfs destroy datapool/filesystem

Rename a filesystem:
zfs rename [pool_name]/[fs_name] [pool_name]/[fs_name]
zfs rename datapool/filesystem datapool/newfilesystem

Move a filesystem:
zfs rename [pool_name]/[fs_name] [pool_name]/[fs_name]/[fs_name]
zfs rename datapool/filesystem datapool/users/filesystem

Display properties of a filesystem:
zfs get all [pool_name]/[fs_name]
zfs get all datapool/filesystem

Make a snapshot:
zfs snapshot [pool_name]/[fs_name]@[time]
zfs snapshot datapool/filesystem@friday

Roll back filesystem to its snapshot:
zfs rollback [pool_name]/[fs_name]@[time]
zfs rollback datapool/filesystem@friday

Clone a filesystem:
zfs snapshot [pool_name]/[fs_name]@[time]
zfs clone [pool_name]/[fs_name]@[time] [pool_name]/[fs_name]
zfs snapshot datapool/filesystem@today
zfs clone datapool/filesystem@today datapool/filesystemclone

Backup filesystem to a file:
zfs send [pool_name]/[fs_name] > /path/to/file
zfs send datapool/filesystem@friday > /tmp/filesystem.bkp

Restore filesystem from a file:
zfs receive [pool_name]/[fs_name] < /path/to/file zfs receive datapool/restoredfilesystem < /tmp/filesystem.bkp Create ZFS volume: zfs create -V [size] [pool_name]/[vol_name] zfs create -V 100mb datapool/zvolume newfs /dev/zvol/dsk/datapool/zvolume

Read the rest of this entry...

Bookmark and Share My Zimbio http://www.wikio.com