Essentials for Solaris Administration
Author: T.Mashayamombe
Instructor: T.Mashayamombe
Chapters
1 An overview of UNIX Commands
2 Solaris Booting Process
3 Booting Problems In Solaris
4 OpenBoot In Solaris
5 Backup In Solaris
6 File System Check (FSCK)
7 Crontab
8 Format And Newfs
9 Solstice DiskSuite
10 Solaris Networking
11 Solaris Installation
Chapter 1 –An overview of UNIX commands
Unix commands are the first thing needed by a unix sysadmin who are starting to work in unix operating system . Unix operating systems comes with online manual system which can be used to see the command details , syntax options and examples on while working on a unix system. Unix manual can be accessed using man Following are a few of the most popular and useful commands used in unix operating system | |
wildcard characters | |
* | The * wildcard character substitutes for one or more characters in a filename. For instance, to list all the files in your directory that end with .c, enter the command ls *.c |
? | ? (question mark) serves as wildcard character for any one character in a filename. For instance, if you have files named prog1, prog2, prog3, and prog3 in your directory, the Unix command:
|
dir | |
Change | cd dir Change to directory d |
Make | mkdir dir Create new directory d |
Move | mv dir1 dir2 Rename directory d1 as d2 |
Remove | rmdir dir Remove directory d |
file | |
list , no details only names | ls filename , filename with wildcard character/s. |
list , details | ls -1 filename , filename with wildcard character/s. |
move to directory | mv filename dirname (wildcard character/s supported) |
copy file to other/current directory | cp file directory/newfile or cp directory/oldfile . |
Delete the file | rm file , rm -rf directory - Recursively remove files & directly without any warning. |
file | file filename , file command tries to determine the file type , text , executable etc after comparing the values in /etc/magic . |
File edit/create/view | |
vi - vi full screen editor | vi filename , Opens a existing file or creates |
ed - Line Text editor | ed filename |
count - Line, word, & char | wc filename |
Text content display - List contents of file at once | cat filename |
Text content display by screen : List contents of file screen by screen | more filename |
Concatenate - file1 & file2 into file3 | cat file1 file2 >file3 |
File operation | |
Change read/write/execute mode of fil | chmod mode file |
chown | chown [-R] [-h] owner[:group] file |
move (rename ) file | mv file1 file2 Rename file file1 as file2 |
Remove | rm file Delete (remove) file f |
Compare two files | cmp file1 file2 |
Copy file file1 into file2 | cp file1 file2 |
Sort Alphabetically | sort file |
Sort Numerically | sort -n file |
Split f into n-line pieces | split [-n] f |
match pattern | grep pattern file Outputs lines that |
Lists file differences | diff file1 file2 |
head f Output beginning of file | head file |
Output end of file | tail file |
PROCESS | |
Suspend current process | CTRL/z * |
Interrupt processes | CTRL/c * |
Stop screen scrolling | CTRL/s * |
Resume screen scrolling | CTRL/q * |
Sleep for n seconds | sleep n |
Print list of jobs | jobs |
Kill job n | kill % |
Remove process n | kill -9 n |
status process status stats | ps |
Resume background job n | bg [%n] |
Resume foreground job n | fg [%n] |
Exit from shell | exit |
User admin | |
add a new user login to the system | # useradd -u 655 -g 20 -d /home/ttes testlogin loginname -u is userid , if not specified system takes highest available . -g group id should be existing in /etc/group , if not specified other or user is assigned. -d home directory , default is to use user as the directory name under the home directory. loginname - new login name to be created . #useradd testlogin will create a user by the name 'testlogin' with all default values . |
password Change | passwd |
alias (csh/tcsh) - Create command | alias name1 name2 |
alias (ksh/bash) - Create alias command | alias name1="name2" |
alias - Remove alias | unalias name1[na2...] |
printer | |
Output file f to line printer | lp -d printer file |
| |
System Status | |
Display disk quota | quota |
Print date & time | date |
List logged in users | who |
Display current user | whoami |
Output user information | finger [username] |
Display recent commands | history |
Environment Variable | |
set | set command alone displays the environment variables, it is used to set options in ksh like set -o vi |
export | export variable , export makes variable visible in sub shells. |
Set environment variable (csh/tcsh) to value v | sentenv name v |
Set environment variable (ksh/bash) to value v | export name=v example : export TERM=vt100 |
Connectivity | |
Connecting to a remote host | $telnet hostname/ip address or $telnet Telnet brings up the login prompt of remote host and expects you to enter your user name & password .Without argument it enters command mode (telnet>) and accepts command listed by ? at telnet> prompt. |
Securely connecting to a remote host | ssh username@hostname or ssh -l username hostname Depending on ssh setting for your account you may or may not be asked a password to login. Your login/passwd will be same login password as you would use with telnet connection. Communication is encrypted between two hosts so if someone intercepts your communication he will not be able to use it. |
Copy files from/to remote host | ftp hostname ftp expects you to enter your username/passwd or if it is ftp only account it will require ftp account password . put , mput (multipleput) command is used to transfer files to remote host. get , mget (multipleput) command is used to transfer files from remote host. ftp allows some limited number of commands to be executed at ftp> prompt & summary of ftp command can be found by using ? at ftp> prompt |
Securely copy files from/to remote host | sftp username@hostname:remotefile localfile Communication is encrypted between two hosts. |
Test the tcp/ip connectivity between two hosts | ping hostname If you can ping a host the host is reachable from the machine that you are using . Router/firewall configuration may prevent ping to succeed . |
Backup and Restore | |
backup and restore using tar , TApeaRchive | tar tvf filename.tar --- View the table of content of a tar archive tar xvf filename.tar --- Extract content of a tar archive tar cvf filename.tar file1 file2 file3 --- Create a tar archive called filename.tar using file1, file2,file3 . tar can't copy the special files , device files .Not suitable for taking root backup. |
backup and restore using cpio , CopyInputOutput | cpio is mostly used in conjunction with other commands to generate a list of files to be copied : cpio can copy special files and hence useful in taking root backup containing device file. |
Find files , directories | |
find files , directories | Find command is used to find the files , directories and to run commands on the list of files thus generated .By default, find does not follow symbolic links. find . -name *.log -print --- Simple find to list log files find . -name '*.log' -exec rm {} \; -- Simple find to find log files and delete them . find accepts a long list of options to find the files based on different parameters such as create time , modified time , of certain size etc. Please refer to man find for more option. |
vi editor Quick reference Table of Contents 1. Introduction 2. Requirement 3. Creating , opening files in vi 5. Saving & exiting the vi editor 6. vi commands , quick reference 7. Next Steps Introduction: __________ vi pronounced as " vee eye " is a unix editor available on almost all the unix operating systems , solaris , bsd ,aix , hpux etc. This document is a quick reference to vi editor and will be of help if your are new to unix , learning unix or just refreshing your vi knowledge after a few years. Requirements: ____________ In order to work correctly the vi need correct terminal type (TERM) setting .The TERM setting depends on the type of terminal you have . Commonly used TERM types are vt100 , vt220 and ansi . In most cases vt100 will work fine . In case vi is not able to understand the TERM you have given, it starts in open mode giving you a line by line display . Generally TERM is taken from .profile or /etc/profile but can be set at the command line as : $TERM=vt100 $export TERM echo $TERM will display the current TERM set. Create new file or Open existing file in vi __________________________________ vi without any file name will open a new file where you can enter the text and edit but while coming out you will be asked to enter a valid file name to save the text. vi with a file name as argument will open that file for editing if the file already exists it opens it otherwise it creates a new file by the argument. Example : $vi testfile Creates or opens the existing file called testfile Modes in vi ____________ vi operates in following two modes : i. ) Command Mode : After a file is opened it is opened in command mode ,that is , input from the keyboard will be treated as vi commands and you will not see the words you are typing on the screen . ii.) Insert Mode: To enter the text you have to put vi in insert by pressing 'i' or 'a' after which you can add the text and whatever is being type will be seen on the screen. . To switch between these mode Esc key is used . Esc i (text mode) Esc (command mode) Saving & Exiting vi editor ______________________ You can exit vi in different ways : 1.) Quit without saving : If you don't want to save the work :q will take you out without saving your editing in vi. 2.) Write & quit : . Simple :w saves the current file but don't exit. For save and quit :wq is used in vi. 3.) Forced Quite : An ! (Exclamation sign at the end of exit commands ( :q! , :wq! ) causes a forced quit from vi after ignoring editing (for :q!) or writing (for :wq!) all the changes.. |
|
vi commands , quick reference | |
Moving Cursor in File | |
Left | h |
Right | i |
Up | k |
Down | j |
Line | |
Beginning | ^ or B |
end | $ |
Sentance : | |
Next sentence | ) |
Previous sentance | ( |
Paragraph | |
Next | } |
Previous | { |
File | |
Go to end of file | :$ |
on chacter forword | :w |
One word forword | :W |
go to a line number | :line_number |
display file info . | ^g |
Inserting and appending text : | |
inserts text to the left of cursor | i |
nserts in the beginning of line | I |
appends text to right of cursor | a |
appends to the end of line | A |
Adding new line | |
add a new line below the current line | o |
adds a new line above the current line. | O |
deleting the text : | |
deletes text above the text | x |
deletes text character on right of cursor | X |
deletes line 20 | 20d |
deletes current line | dd |
delete till end of current line. | D |
Replacing a character & word | |
replace the character above the cursor. | r |
replces characters until Esc is pressed. | R |
replaces the word from cursor to the end indicated by $ sign . | cw |
replaces till end of line. | C |
Substitute | |
subistutes current charcater. | s |
substitutes entire line. | S |
Undo the last change | |
undo last change. | u |
undo changes to the current line. | U |
Copy and pasting lines | |
copys the current line into buffer. | yy |
copies 5 lines from the current line. | 5yy |
pastes the current buffer. | p |
Searching | |
Searches for the word name in the file | :/name |
n continues search forward. | n |
N searches backwards | N |
Saving | |
saves the text does not quit. | :w |
saves & quit the editor . | :wq! |
Save | ZZ |
Quit without saving | q! |
| |
Search & Replace | s/ |
Repeating last command | . |
Recovering a unsaved vi file. | vi -r filename |
7. Next Steps :
vi editor is all time favorite for the unix admins and there are some books available if you are interested in exploring the more powers of vi editor. The editor is also covered in system administration books so you may find a chapter devoted to vi editor in most of the unix system administration books
Chapter 2
Booting process in Solaris what happens when a system boots up Understanding the booting process is important in the sense that you can get a clear idea when a system faces a booting problem if you are familiar with the booting sequence and steps involved. You can thereby isolate a booting phase and quickly resolve the issues. Booting process in Solaris can be divided in to different phases for ease of study . First phase starts at the time of switching on the machine and is boot prom level , it displays a identification banner mentioning machine host id serial no , architecture type memory and Ethernet address This is followed by the self test of various systems in the machine. The booting process undergoes the following phases afterwards : 1) init phase 2) inittab file 4.) Next Steps | |
INIT phase
Init phase is started by the execution of /sbin/init program and starts other processes after reading the /etc/inittab file as per the directives in the /etc/inittab file .
Two most important functions of init are
a) It runs the processes to bring the system to the default run level state ( Run level 3 in Solaris , defined by initdefault parameter in /etc/inittab )
b) It controls the transition between different run levels by executing appropriate rc scripts to start and the stop the processes for that run level.
/etc/inittab file
This file states the default run level and some actions to be performed while the system reaches up to that level. The fields and their explanation are as follows :
S3:3:wait:/sbin/rc3 > /dev/console 2>&1 < /dev/console
S3 denotes a identification if the line
3 is run level
wait is action to be performed
/sbin/rc3 is the command to be run.
So the fields in the inittab are
Identification : run level : action : process
The complete line thus means run the command /sbin/rc3 at run level 3 and wait until the rc3 process is complete.
The action field can have any of the following keywords :
Initdefault : default run level of the system
Respawn : start and restart the process if it stops.
Powerfail : stop on powerfail
Sysinit : start and wait till console in accessible .
Wait : wait till the process ends before going on to the next line.
RC scripts & Run Levels
Rc scripts performs the following functions :
a) They check and mount the file systems
b) Start and stop the various processes like network , nfs etc.
c) Perform some of the house keeping jobs.
System goes in to one of the following run level after booting depending on default run level and the commands issued for changing the run level to some other one.
0 Boot prom level ok> or > prompt in Sun.
1 Administrative run level . Single user mode
2 Multiuser mode with no resource sharing .
3 Multiuser level with nfs resource sharing
4 Not used
5 Shutdown & power off (Sun 4m and 4u architecture )
6 Reboot to default run level
S s Single user mode user logins are disabled.
Broadly speaking the running system can be in any of the folloing state
Single user – Minimum processes running , user logins disabled and root password is required to gain access to the shell .
Multiuser - All system processes are running and user logins are permitted
Run level of a desired state is achieved by a number of scripts executed by the rc program the rc scripts are located in /etc/rc0.d , /etc/rc1.d , /etc/rc2.d , /etc/rc3.d & /etc/rcS.d directories . All the files of a particular run level are executed in the alphanumeric order .Those files beginning with letter S starts the processes and those beginning with K stops the processes.
These files are hard linked to the files in /etc/init.d in order to provide a central location for all these files and eliminating the need to change the run level in case these scripts needs to be run separately . The files in /etc/init.d directory are without any S , K and numeric prefix instead a stop / start argument has to be supplied whenever these scripts are to be executed .
By default system has a number of rc scripts needed for run level transition but sometimes it becomes necessary to start some custom scripts at the booting time and turn them off at the shutdown . Custom scripts can be put in any of the required rc directory but following major considerations has to be kept in mind :
- The sequence number of the file should not conflict with other files.
- The sevices needed should be available by previously executed scripts.
- File should be hard linked to the /etc/init.d directory .
- The system looks for only those files beginning with letter K & S , any thing else is ignored , therefore, to make a file inactive simply changing uppercase K or S to lower case will cause system to ignore it .
Chapter 3 Booting Problems in Solaris Booting problems poses serious challenge to the system administrators as system is down and no one can use it . This article tries to cover some of the general booting problems and their possible solutions to enable understand the problem cause and bring the system up very quickly. Following are some of the booting issues ,error messages their meaning and possible solutions 1) Booting in single user mode and mounting root disk . 3) "Timeout waiting for ARP/RARP packet"? error message. 4) "The file just loaded does not appear to be executable" error message. 5) "bootblk: can't find the boot program" error message. 6) "boot: cannot open kernel/unix" error message . 7) "Error reading ELF header"? error message . 8) "Cannot open '/etc/path_to_inst'" error message. 9) "Can't stat /dev/rdsk/c0t3d0s0" error message . 10) Next Steps 1.Booting in single user mode and mounting root hard disk. Most important step in diagnosing the booting problems is booting the system in single user mode and examining the hard disk for possible errors & work out the corrective measure. Single user mode can be achieved by any of the following methods :- ok> boot -s ;from root disk ok> boot net -s ;from network ok>boot cdrom -s ;from cdrom Rebooting with command: cdrom -s Configuring the /devices directory Configuring the /dev directory | INIT: SINGLE USER MODE # # fsck /dev/rdsk/c0t3d0s0 # mount /dev/dsk/c0t3d0s0 /mnt Perform the required operation on mounted disk , now accessible through /mnt ,& unmount the hard disk after you are done ; # umount /mnt # reboot |
|
2.Making boot device alias
In case system can not boot from primary disk and it is needed to make another boot disk to access the data , nvalias command is used .
nvalias command makes the device alias and assigns an alternate name to a physical disk. Physical address of target disk is required which can be had by show-disk command on ok>.
ok> nvalias disk7 /iommu@f,e0000000/sbus@f,e0001000/dma@3,81000/esp@3,80000/sd2,0
The new aliased disk can be named as boot disk or can be used for booting by refering its name .
ok> setenv boot-device disk7
ok>reset
or
ok> boot disk7
3."Timeout waiting for ARP/RARP packet"?
At ok> type printenv and look for these parameters .
boot-device disk
mfg-switch? false
diag-switch? false
if you see "boot-device net " or true value for the other two parameter change it to the values above.
In case you wants to boot from network make sure your client is properly configured in boot server and network connections & configuration are proper.
4."The file just loaded does not appear to be executable."
Boot block on the hard disk is corrupted .Boot the system in single user mode with cdrom and reinstall boot block .
#installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0
5."bootblk: can't find the boot program"
boot block can not find the boot programe - ufsboot in Solaris .Either ufsboot is missing or corrupted . In such cases it can be restored from the cdrom after booting from cdrom & mounting the hard disk
# cp /platform/`uname -i`/ufsboot /mnt/platform/`uname -i`
6."boot: cannot open kernel/unix"
Kernel directory or unix kernel file in this directory is not found .Probably deleted during fsck or deleted by mistake .Copy it from the cdrom or restore from the backup tape.
# cp /platform/`uname -i`/kernel/unix /mnt/platform/`uname -i`/kernel
7."Error reading ELF header."?
Kernel directory or unix kernel file in this directory is corrupted.Copy it from the cdrom or restore from the backup tape.
# cp /platform/`uname -i`/kernel/unix /mnt/platform/`uname -i`/kernel
8."Cannot open '/etc/path_to_inst'"
System can not find the /etc/path_to_install file .It might be missing or corrupted and needs to be rebuild.
To rebuild this file boot the system with -ar option :
ok>boot -ar
Press enter to select default values for the questions asked during booting and select yes to rebuild /etc/path_to_install
The /etc/path_to_inst on your system does not exist or is empty. Do you want to rebuild this file [n]? y
system will continue booting after rebuilding the file.
9."Can't stat /dev/rdsk/c0t3d0s0"
When booted from cdrom and done fsck the root partition comes out to be fine but on booting from root disk this error occurs. The device name for / is missing from /dev/dsk directory and to resolve the issue /dev & /devices directories has to be restored from root backup tapes
This article covered Solaris booting process . Booting process is the starting task of all the sysadmin activities to be carried out later like user creation , network configuration etc. While most of the sysadmin aspects are covered in this site still it pays to have a system administration book handy . There are some good books available on unix and Solaris administration which broaden your understanding of Solaris & unix and there by helping in your day today work and providing you satisfaction of work.
Chapter 4
Sun OpenBoot Parameters and commands About Openboot : The firmware in Sun's boot PROM is called OpenBoot. The main features of openboot are initial program loading , & debugging features to assist kernel debugging .OpenBoot supports plug-in device drivers which are written in language Forth. . This plug in feature allows Sun or any third-party vendors to develop new boot devices but without making any changes to boot PROM. Accessing the openboot : Openboot console can be accessed by any of the following means . Be careful not to do this on a live system as you might end up in rebooting the server . 1. Rebooting a system , if auto-boot is not set to true rebooted system returns to OK> prompt which is openboot prompt 2. Pressing the keys L1 and A or STOP A , at the same time will bring you to the OpenBoot system. You will see the display Type b (boot), c (continued), or n (new command mode) Typing OpenBoot Parameters & commands: Following two tables gives a list of Openboot parameters & commands |
|
OpenBoot Parameters | ||||
General | boot | Network | DIAGNOSTICS | input/output |
printenv Display all variables and current values. setenv Set variable to the given value. set-default Reset the value of variable to the factory default. set-defaults Reset variable values to the factory defaults. | auto-boot ?=true System directly boots without stopping at OK> after power on. boot-comman d=boot boot-file: boot-device =disk net Device to boot from , multiple devices can be specified using spaces .Other devices will be selected if first device fails. | tpe-link-test? =true Tests the UTP ethernet port link and flashes error messages if there is no network link. local-mac-address? =false Use the system's MAC address instead of network card's MAC address . Ports ttyb-rts-dtr-off =false =true =false =true =9600,8,n,1,- =9600,8,n,1,- | diag-file: boot file for diagnostic mode This variable contains the default diagnostic mode boot arguments. booting device in diagnostic mode. diag-switch?=false If true system runs in diagnostic mode. diag-level=max be min , max and minus . There may be additional platform specific values. If set to off, POST is not called. The default value is platform-dependent. | input-device=keyboard Input device used at power-on ( keyboard, ttya, or ttyb). keyboard-click?=false keyboard click sound keymap: For custom keyboards output-device=screen Output device used at power-on (screen, controls the behavior of the terminal emulator. The value false causes the terminal emulator to stop interpreting ANSI escape sequences resulting in echoing them to the output device. Columns and Rows of display screen. |
SCSI | bus | nvram | Security | oem options |
scsi-initiator-id=7 SCSI bus address of host adapter, range 0-7. Used in shared scsi storage envornment. | pcia-probe-list =1,2,3,4 =1,2,3 sbus-probe-list =2,0,1,3 Order to probe pci and sbus buses for devices. | use-nvramrc?=false If true , execute commands in NVRAMRC during sys- Displays contents of NVRAM | security-mode=none Firmware security level (options: none, command , Security password setting when security mode is command or full. No. of bad security login . password Set security-password | oem-logo=false mfg-mode=off |
Useful commands at OK prompt. | ||
Dignostics : | boot | NVRAM |
banner this command shows the following systems hardware informatiion : Model, architecture, processor,keyboard, openboot version, Serial no. ethernet address & host id. Show ticks of real-time clock Monitor network broadcast packets Monitor broadcast packets on all net interfaces Show attached SCSI devices probe-scsi-all Show attached SCSI devices for all host adapters- internal & external. | boot - boot kernel from default device. DEVALIAS ok>show-devs ok cd /pci@1f,4000/scsi@3 ok .properties ok ls f00809d8 tape f007ecdc disk ok .speed CPU Speed : 200.00MHz UPA Speed : 100.00MHz PCI Bus A : 66Mhz PCI Bus B : 33Mhz | nvedit Start nvramrc line editor using a temporary edit buffer |
Key Sequences These commands are disabled if the PROM security is on. Also, if your system has full security enabled, you cannot apply any of the suggested commands unless you have the password to get to the ok prompt. Stop - Bypass POST. This command does not depend on security-mode. (Note: some systems bypass POST as a default; in such cases, use Stop-D to start POST.) Stop-A Abort. Stop-D - Enter diagnostic mode (set diag-switch? to true). Stop-F - Enter Forth on TTYA instead of probing. Use exit to continue with the initialization sequence. Useful if hardware is broken. Stop-N Reset NVRAM contents to default values. |
Chapter 5
System Backups
ufsdump
1. Used for complete file system backup .
2. It copies every thing from regular files in a file system to special character and block device files.
2. It can work on mounted or unmounted file systems.
Tar:
1. Used for single or multiple files backup .
2. Can't backup special character & block device files .
3. Works only on mounted file system.
Identifying the tape device
dmesg | grep st
Checking the status of the tape drive
mt -f /dev/rmt/0 status
Backup file system using ufsdump
ufsdump 0cvf /dev/rmt/0 /dev/rdsk/c0t0d0s0
or
ufsdump 0cvf /dev/rmt/0 /usr
To restore a dump with ufsrestore
ufsrestore rvf /dev/rmt/0
ufsrestore in interactive mode allowing selection of individual files and directories using add , ls , cd , pwd and extract commands .
ufsrestore -i /dev/rmt/0
Making a copy of a disk slice using ufsdump
ufsdump 0f - /dev/rdsk/c0t0d0s7 |(cd /mnt/backup ;ufsrestore xf -)
Backing up all files in a directory including subdirectories to a tape device (/dev/rmt/0),
tar cvf /dev/rmt/0 *
Viewing a tar backup on a tape
tar tvf /dev/rmt/0
Extracting tar backup from the tape
tar xvf /dev/rmt/0
(Restoration will go to present directory or original backup path depending on relative or absolute path names used for backup )
Backup using cpio
find . -depth -print | cpio -ovcB > /dev/rmt/0
Viewing cpio files on a tape
cpio -ivtB < /dev/rmt/0
Restoring a cpio backup
cpio -ivcB < /dev/rmt/0
Compressing a file
compress -v file_name
gzip filename
To uncompress a file
uncompress file_name.Z
or
gunzip filename
tar: /dev/rmt/0: No such file or directory
==========================================
The default tape device /dev/rmt/0, or possibly the device
specified by the TAPE environment variable, is not currently
connected to the system, is not configured, or its hardware
symbolic link is broken.
List the files in the /dev/rmt directory to see which tape
devices are currently configured. If none are configured,
ensure
that a tape device is correctly attached to the system, and
reboot with the -r option to reconfigure devices.
If tape devices other than /dev/rmt/0 are configured, you
could
specify one of them after the -f option of tar(1).
tar: directory checksum error
=============================
This error message from tar(1) indicates that the checksum of the
directory and the files it has read from tape does not match the
checksum advertised in the header block. Usually this indicates
the wrong blocking factor, although it could indicate corrupt
data on tape.
To resolve this problem, make certain that the blocking factor
you specify on the command line (after -b) matches the blocking
factor originally specified. If in doubt, leave out the block
size and let tar determine it automatically. If that doesn't
help, tape data could be corrupted.
tar: tape write error
=====================
A physical write error has occurred on the tar(1) output file,
which is usually a tape, although it could be a diskette or disk
file. Look on the system console, where the device driver should
provide the actual error condition. This might be a write-
protected tape, a physical I/O error, an end-of-tape condition,
or a File too large limitation.
In the case of write-protectedtapes, enable the write switch.
For physical I/O errors, the best course of action is to replace
the tape with a new one. For end-of-tape conditions, try using a
higher density if the device supports one, or use cpio(1) or pax
(1) for their multi-volume support., When encountering File too
large limitations, use the parent shell'slimit(1) or ulimit
facility to increase the maximum file size.
For more information on tar tapes, see the section on copying UFS
files in the System Administration Guide,Volume I.
Text is lost because the maximum edit log size has been exceeded.
=================================================================
This message appears at the beginning of a cmdtool(1) session
after 100,000 characters have gone by in the scrolling window.
Clicking on the top rectangle of the scrollbar might display this
message. No data were lost, but the user cannot scroll back
before this wraparound point.
To increase the maximum size of the Command Tool log file, use
cmdtool with the-M option, specifying more than 100,000 bytes.
THE FOLLOWING FILE SYSTEM(S) HAD AN UNEXPECTED INCONSISTENCY:
============================================================
At boot time the /etc/rcS script runs the fsck(1M) command to
check the integrity of filesystems marked "fsck" in /etc/vfstab.
If fsck cannot repair a filesystem automatically, it interrupts
the boot procedure and produces this message. When fsck gets into
this state, it cannot repair filesystems without losing one or
more files, so it wants to defer this responsibility to you, the
administrator. Data corruption has probably already occurred.
First run fsck -n on the filesystem, to see how many and what
type of problems exist. Then run fsck again to repair the
filesystem. If you have a backup of the filesystem, you can
generally answer "y" to all the fsck questions. It's a good idea
to keep a record of all problematic files and inode numbers for
later reference. To run fsck yourself, specify options as
recommended by the boot script. For example:
# fsck /dev/rdsk/c0t4d0s0
Usually, files lost during fsck repair were created just before a
crash or power outage, and cannot be recovered. If important
files are lost, you can recover them from backup tapes.
Chapter 6
Checking and Repairing File system with fsck
fsck is a Unix utility for checking and repairing file system inconsistencies . File system can become inconsistent due to several reasons and the most common is abnormal shutdown due to hardware failure , power failure or switching off the system without proper shutdown . Due to these reasons the superblock in a file system is not updated and has mismatched information relating to system data blocks, free blocks and inodes .
Modes of operation :
fsck operates in two modes interactive and non interactive :
interactive : the fsck examines the file system and stops at each error it finds in the file system and gives the problem description and ask for user response usually whether to correct the problem or continue without making any change to the file system.
noninteractive :fsck tries to repair all the problems it finds in a file system without stopping for user response useful in case of a large number of inconsistencies in a file system but has the disadvantage of removing some useful files which are detected to be corrupt .
If file system is found to have problem at the booting time non interactive fsck fsck is run and all errors which are considered safe to correct are corrected. But if still file system has problems the system boots in single user mode asking for user to manually run the fsck to correct the problems in file system
Running fsck :
fsck should always be run in a single user mode which ensures proper repair of file system . If it is run in a busy system where the file system is changing constantly fsck may see the changes as inconsistencies and may corrupt the file system .
if the system can not be brought in a single user mode fsck should be run on the partitions ,other than root & usr , after unmounting them . Root & usr partitions can not be unmounted . If the system fails to come up due to root/usr files system corruption the system can booted with CD and root/usr partitions can be repaired using fsck.
command syntax:
fsck [ -F fstype] [-V] [-yY] [-o options] special
-F fstype type of file system to be repaired ( ufs , vxfs etc)
-V verify the command line syntax but do not run the command
-y or -Y Run the command in non interactive mode - repair all errors encountered without waiting for user response.
-o options Three options can be specified with -o flag
b=n where n is the number of next super block if primary super block is corrupted in a file system .
p option used to make safe repair options during the booting process.
f force the file system check regardless of its clean flag.
special - Block or character device name of the file system to be checked/repaired - for example /dev/rdsk/c0t3d0s4 .Character device should be used for consistencies check & repair
phases:
fsck checks the file system in a series of 5 pages and checks a specific functionality of file system in each phase.
** phase 1 - Check Blocks and Sizes
** phase 2 - Check Pathnames
** phase 3 - Check Connectivity
** phase 4 - Check Reference Counts
** phase 5 - Check Cylinder Groups
Error messages & Corrective action :
1.Corrupted superblock - fsck fails to run
If the superblock is corrupted the file system still can be repaired using alternate superblock which are formed while making new file system .
the first alternate superblock number is 32 and others superblock numbers can be found using the following command :
newfs -N /dev/rdsk/c0t0d0s6
for example to run fsck using first alternate superblock following command is used
fsck -F ufs -o b=32 /dev/rdsk/c0t0d0s6
2.Link counter adjustment : fsck finds mismatch between directory inode link counts and actual directory links and prompts for adjustment in case of interactive operation .Link count adjustments are considered to be a safe operation in a file system and should be repaired by giving 'y' response to the adjust ? prompt during fsck.
3.Free Block count salvage : During fsck the number of free blocks listed in a superblock and actual unallocated free blocks count does not match .fsck inform this mismatch and asks to salvage free block count to synchronize the superblock count. This error can be corrected without any potential problem to the file system or files.
4.Unreferenced file reconnection : While checking connectivity fsck finds some inodes which are allocated but not referenced -not attached to any directory . Answering y to reconnect message by fsck links these files to the lost+found directory with their inode number as their name .
To get more info about the files in lost+found 'file' command can be used to see the type of files and subsequently they can be opened in their applications or text editors to find out about their contents. If the file is found to be correct it can be used after copying to some other directory and renaming it.
Chapter 7
Crontab
Setting up cronjobs in Unix and Solaris
cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris. Following points sum up the crontab functionality : 1. Crontab Restrictions
3. Crontab file
* in the value field above means all legal values as in braces for that column. 4. Crontab Example 30 18 * * * rm /home/someuser/tmp/* Changing the parameter values as below will cause this command to run at different time schedule below :
Note : If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with Control-d. This removes all entries in your crontab file. Instead, exit with Control-c. 5. Crontab Environment By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line . |
Chapter 8
Managing Disks and FileSystem
Format Command
The format utility's main menu items allow you to do the following tasks:
analyze
Run read, write, and compare tests.
backup
Search for backup labels.
current
Display the device name, manufacturer and model of the current disk.
defect
Retrieve and print defect lists.
disk
Choose the disk that will be used in subsequent operations (known as the current disk.)
fdisk
(x86 systems only.) Run the fdisk(1M) program to create a Solaris fdisk partition.
format
Format and verify the current disk.
inquiry
Display the vendor, product name, and revision level of the current drive.
label
Write a new label to the current disk.
partition
Create and modify slices.
quit
Exit the format menu.
repair
Repair a specific block on the disk.
save
Save new disk and slice information.
type
Identify the manufacturer and model of the current disk.
verify
Print the following information about the disk: manufacturer and model, number of cylinders, alternate cylinders, heads and sectors, and partition table.
volname
Label the disk with a new eight character volume name.
PRVTOC
The prtvtoc command allows the contents of the VTOC (volume table of contents) to be viewed. The command can be used only by the super-user.
The device name can be the file name of a raw device in the form of /dev/rdsk/c?t?d?s2 or can be the file name of a block device in the form of /dev/dsk/c?t?d?s2
example# prtvtoc /dev/rdsk/c0t3d0s2
* /dev/rdsk/c0t3d0s2 partition map
*
* Dimension:
* 512 bytes/sector
* 80 sectors/track
* 9 tracks/cylinder
* 720 sectors/cylinder
* 2500 cylinders
* 1151 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 0 76320 76319 /
1 3 01 76320 132480 208799
2 5 00 0 828720 828719
5 6 00 208800 131760 340559 /opt
6 4 00 340560 447120 787679 /usr
7 8 00 787680 41040 828719 /export/home
example#
Adding Disks under Solaris
Once the disk has been physically installed, the system should recognize a new device on the SCSI bus. After powering up the system, hold down the Stop key (on some Suns, this is labeled L1), and hit the A key to enter the boot monitor.
At the boot monitor, probe-scsi can be used to list the SCSI devices the system recognizes:
Type 'go' to resume
Type help for more information
ok probe-scsi
.
.
Target 5
Unit 0 Disk HP C37245 5153
.
.
Note: on some older Suns, it may be necessary to enter "n" at the boot monitor to enter the newer command mode before probing for disks.
After verifying that the new disk is recognized by the system, reboot the machine by issuing "boot -r" from the boot monitor. The -r option tells the system to reconfigure for the new device.
During the boot process, the new disk should be recognized and a message should be printed to the console. (On some Suns, it may not be printed to the screen, but will be written to the system log -- in this case, the dmesg command should be used to review the boot messages). The messages should be similar to this:
sd5 at esp0: target 5 lun 0
sd5 is /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@5,0
WARNING: /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@5,0 (sd5):
corrupt label - wrong magic number
Vendor 'HP', product 'C3724S', 2354660 512 byte blocks
In this example, the disk is located on controller 0, SCSI ID 5. The "corrupt label" warning means that the disk doesn't have a Solaris label on it yet.
Device nodes
The correct device nodes for the disk are automatically added when a "boot -r" is issued. If the system hasn't been rebooted using the -r option, here is a script that will configure the system for the new disk.
Formatting, Partitioning and Labeling
The format utility is used to format, partition, and label disks. It is menu driven. The raw disk device is given as an argument; if no argument is given, format will print a list of available disks and ask the user to pick one.
# format /dev/rdsk/c0t5d0s2
selecting /dev/rdsk/c0t5d0s2
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
quit
Typing format at the prompt will perform a low-level format on the disk. This is usually not necessary with a new disk, since they generally come pre-formatted, but may help to map out any additional defects the drive may have developed.
The next step is to partition the drive. Type partition at the prompt to switch to the partition menu:
format> partition
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
quit
Type in print to get a listing of the current partition table. Note that the second partition represents the entire disk:
partition> print
Current partition table (original):
Total disk cylinders available: 3361 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0-3360 1.12GB (3361/0/0) 2352700
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
We will be splitting the disk up into two equal partitions, numbers 3 and 4. The first partition will span cylinders 0 through 1680, the second will span cylinders 1681 through 3360. The partition size can be specified in blocks, cylinders, or megabytes by using the b, c, and mb suffixes when entering the size.
partition> 3
Part Tag Flag Cylinders Size Blocks
3 unassigned wm 0 0 (0/0/0) 0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 0
Enter partition size[0b, 0c, 0.00mb]: 1680c
partition> 4
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 1681
Enter partition size[0b, 0c, 0.00mb]: 1680c
Once the disk has been partitioned, the label should be written to the disk:
partition> label
Ready to label disk, continue? y
The new partition table can be printed from the format utility, or may be viewed using the prtvtoc command:
# prtvtoc /dev/rdsk/s0t5d0s2
* /dev/rdsk/c0t5d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 140 sectors/track
* 5 tracks/cylinder
* 700 sectors/cylinder
* 3363 cylinders
* 3361 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 1176000 700 1176699
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
2 5 01 0 2352700 2352699
3 0 00 0 1176000 1175999
4 0 00 1176700 1176000 2352699
Creating new filesystems
Finally, new filesystems can be created on the disk using the newfs command, and each filesystem is checked for integrity using fsck:
# newfs /dev/rdsk/c0t5d0s3
newfs: construct a new file system /dev/rdsk/c0t5d0s3: (y/n)? y
/dev/rdsk/c0t5d0s3: 1176000 sectors in 1680 cylinders of 5 tracks, 140 sectors
574.2MB in 105 cyl groups (16 c/g, 5.47MB/g, 2624 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 11376, 22720, 34064, 45408, 56752, 68096, 79440, 89632, 100976, 112320,
123664, 135008, 146352, 157696, 169040, 179232, 190576, 201920, 213264,
224608, 235952, 247296, 258640, 268832, 280176, 291520, 302864, 314208,
325552, 336896, 348240, 358432, 369776, 381120, 392464, 403808, 415152,
426496, 437840, 448032, 459376, 470720, 482064, 493408, 504752, 516096,
527440, 537632, 548976, 560320, 571664, 583008, 594352, 605696, 617040,
627232, 638576, 649920, 661264, 672608, 683952, 695296, 706640, 716832,
728176, 739520, 750864, 762208, 773552, 784896, 796240, 806432, 817776,
829120, 840464, 851808, 863152, 874496, 885840, 896032, 907376, 918720,
930064, 941408, 952752, 964096, 975440, 985632, 996976, 1008320, 1019664,
1031008, 1042352, 1053696, 1065040, 1075232, 1086576, 1097920, 1109264,
1120608, 1131952, 1143296, 1154640, 1164832,
# fsck -y /dev/rdsk/c0t5d0s3
** /dev/rdsk/c0t5d0s3
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
2 files, 9 used, 551853 free (13 frags, 68980 blocks, 0.0% fragmentation)
Chapter 9
Admin's Guide to Solstice Disk Suite
Understanding and setting up Solstice DiskSuite in Solaris
1. Advantages of Disksuite Solstice disk suite provides three major functionalities : 1. Over come the disk size limitation by providing for joining of multiple disk slices to form a bigger volume. 2. Fault Tolerance by allowing mirroring of data from one disk to another and keeping parity information in RAID5. 3. Performance enhancement by allowing spreading the data space over multiple disks . 2. Disksuite terms Metadevice :A virtual device composed of several physical devices - slices/disks . All the operations are carried out using metadevice name and transparently implemented on the individual device. RAID : A group of disks used for creating a virtual volume is called array and depending on disk/slice arrangement these are called various types of RAID (Redundant Array of Independent Disk ). RAID 0 Concatenation/Striping RAID 1 Mirroring RAID 5 Striped array with rotating parity. Concatenation :Concatenation is joining of two or more disk slices to add up the disk space . Concatenation is serial in nature i.e. sequential data operation are performed serially on first disk then second disk and so on . Due to serial nature new slices can be added up without having to take the backup of entire concatenated volume ,adding slice and restoring backup . Striping :Spreading of data over multiple disk drives mainly to enhance the performance by distributing data in alternating chunks - 16 k interleave across the stripes . Sequential data operations are performed in parallel on all the stripes by reading/writing 16k data blocks alternatively form the disk stripes. Mirroring : Mirroring provides data redundancy by simultaneously writing data on to two sub mirrors of a mirrored device . A submirror can be a stripe or concatenated volume and a mirror can have three mirrors . Main concern here is that a mirror needs as much as the volume to be mirrored. RAID 5 : RAID 5 provides data redundancy and advantage of striping and uses less space than mirroring . A RAID 5 is made up of at least three disk which are striped with parity information written alternately on all the disks . In case of a single disk failure the data can be rebuild using the parity information from the remaining disks . | |
3. Disksuite Packages :
Solstice disk suite is a part of server edition of the Solaris OS and is not included with desktop edition . The software is in pkgadd format & can be found in following locations in CD :
Solaris 2.6 - “Solaris Server Intranet Extensions 1.0” CD.
Solaris 7 - “Solaris Easy Access Server 3.0”
Solaris 8 - “Solaris 8 Software 2 of 2”
Solaris 2.6 & 2.7 Solstice Disk suite version is 4.2 . Following packages are part of it but only the "SUNWmd" is the minimum required package and a patch.
SUNWmd - Solstice DiskSuite
SUNWmdg - Solstice DiskSuite Tool
SUNWmdn - Solstice DiskSuite Log Daemon
Patch No. 106627-04 (obtain latest revision)
Solaris 8 DiskSuite version is 4.2.1 .Following are the minimum required packages ..
SUNWmdr Solstice DiskSuite Drivers (root)
SUNWmdu Solstice DiskSuite Commands
SUNWmdx Solstice DiskSuite Drivers (64-bit)
4. Installing DiskSuite 4.2.1 in Solaris 8
# cd /cdrom/sol_8_401_sparc_2/Solaris_8/EA/products/DiskSuite_4.2.1/sparc/Packages
# pkgadd -d .
The following packages are available:
1 SUNWmdg Solstice DiskSuite Tool
(sparc) 4.2.1,REV=1999.11.04.18.29
2 SUNWmdja Solstice DiskSuite Japanese localization
(sparc) 4.2.1,REV=1999.12.09.15.37
3 SUNWmdnr Solstice DiskSuite Log Daemon Configuration Files
(sparc) 4.2.1,REV=1999.11.04.18.29
4 SUNWmdnu Solstice DiskSuite Log Daemon
(sparc) 4.2.1,REV=1999.11.04.18.29
5 SUNWmdr Solstice DiskSuite Drivers
(sparc) 4.2.1,REV=1999.12.03.10.00
6 SUNWmdu Solstice DiskSuite Commands
(sparc) 4.2.1,REV=1999.11.04.18.29
7 SUNWmdx Solstice DiskSuite Drivers(64-bit)
(sparc) 4.2.1,REV=1999.11.04.18.29
Select 1,3,4,5,6,7 packages .
Enter ‘yes’ for the questions asked during installation and reboot the system after installation .
Put /usr/opt/SUNWmd/bin in root PATH as the DISKSUITE commands are located in this directory
5. Creating State Database :
State meta database , metadb , keeps information of the metadevices and is needed for Disksuite operation . Disksuite can not function without metadb so a copy of replica databases is placed on different disks to ensure that a copy is available in case of a complete disk failure .
Metadb needs a dedicated disk slice so create partitions of about 5 Meg. on the disks for metadb. If there is no space available for metadb then it can be taken from swap . Having metadb on two disks can create problems as DISKSUITE looks for database replica number > 50% of total replicas and if one of the two disks crashes the replica falls at 50% . On next reboot system will go to single user mode and one has to recreate additional replicas to correct the metadb errors.
The following command creates three replicas of metadb on three disk slices.
#metadb -a -f -c 3 /dev/dsk/c0t1d0s6 /dev/dsk/c0t2d0s6 /dev/dsk/c0t3d0s6
6. Creating MetaDevices :
Metadevices can be created in two ways
1. Directly from the command line
2. Editing the /etc/opt/SUNWmd/
initializing devices on command line using metainit
6.1 ) Creating a concatenated Metadevice :
#metainit d0 3 1 /dev/dsk/c0t0d0s4 1 /dev/dsk/c0t0d0s4 1 /dev/dsk/c0t0d0s4
d0 - metadevice name
3 - Total Number of Slices
1 - Number of Slices to be added followed by slice name.
6.2 ) Creating a stripe of 32k interleave
# metainit d10 1 2 c0t1d0s2 c0t2d0s2 -i 32k
d0 - metadevice name
1 - Total Number of Stripe
2- Number of Slices to be added to stripe followed by slice name .
-i chunks of data written alternatively on stripes.
6.3 ) Creating a Mirror :
A mirror is a metadevice composed of one or more submirrors. A submirror is made of one or more striped or concatenated metadevices. Mirroring data provides you with maximum data availability by maintaining multiple copies of your data. The system must contain at least three state database replicas before you can create mirrors. Any file system including root (/), swap, and /usr, or any application such as a database, can use a mirror.
6.3.1 ) Creating a simple mirror from new partitions
1.Create two stripes for two submirors as d21 & d22
# metainit d21 1 1 c0t0d0s2
d21: Concat/Stripe is setup
# metainit t d22 1 1 c1t0d0s2
d22: Concat/Stripe is setup
2. Create a mirror device (d20) using one of the submirror (d21)
# metainit d20 -m d21
d20: Mirror is setup
3. Attach the second submirror (D21) to the main mirror device (D20)
# metattach d20 d22
d50: Submirror d52 is attached.
4. Make file system on new metadevice
#newfs /dev/md/rdsk/d20
edit /etc/vfstab to mount the /dev/dsk/d20 on a mount point.
6.3.2.) Mirroring a Partitions with data which can be unmounted
# metainit f d1 1 1 c1t0d0s0
d1: Concat/Stripe is setup
# metainit d2 1 1 c2t0d0s0
d2: Concat/Stripe is setup
# metainit d0 -m d1
d0: Mirror is setup
# umount /local
(Edit the /etc/vfstab file so that the file system references the mirror)
#mount /local
#metattach d0 d2
d0: Submirror d2 is attached
6.3.3 ) Mirroring a Partitions with data which can not be unmounted - root and /usr
· /usr mirroring
# metainit -f d12 1 1 c0t3d0s6
d12: Concat/Stripe is setup
# metainit d22 1 1 c1t0d0s6
d22: Concat/Stripe is setup
# metainit d2 -m d12
d2: Mirror is setup
(Edit the /etc/vfstab file so that /usr references the mirror)
# reboot
...
...
# metattach d2 d22
d2: Submirror d22 is attached
· root mirroring
# metainit -f d11 1 1 c0t3d0s0
d11: Concat/Stripe is setup
# metainit d12 1 1 c1t3d0s0
d12: Concat/Stripe is setup
# metainit d10 -m d11
d10: Mirror is setup
# metaroot d10
# lockfs -fa
# reboot
…
…
# metattach d10 d12
d10: Submirror d12 is attached
6.3.4 ) Making Mirrored disk bootable
a.) # installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
6.3.5 ) Creating alternate name for Mirrored boot disk
a.) Find physical path name for the second boot disk
# ls -l /dev/rdsk/c1t3d0s0
lrwxrwxrwx 1 root root 55 Sep 12 11:19 /dev/rdsk/c1t3d0s0 ->../../devices/sbus@1,f8000000/esp@1,200000/sd@3,0:a
b.) Create an alias for booting from disk2
ok> nvalias bootdisk2 /sbus@1,f8000000/esp@1,200000/sd@3,0:a
ok> boot bootdisk2
6.4 ) Creating a RAID 5 volume :
The system must contain at least three state database replicas before you can create RAID5 metadevices.
A RAID5 metadevice can only handle a single slice failure.A RAID5 metadevice can be grown by concatenating additional slices to the metadevice. The new slices do not store parity information, however they are parity protected. The resulting RAID5 metadevice continues to handle a single slice failure. Create a RAID5 metadevice from a slice that contains an existing file system.will erase the data during the RAID5 initialization process .The interlace value is key to RAID5 performance. It is configurable at the time the metadevice is created; thereafter, the value cannot be modified. The default interlace value is 16 Kbytes which is reasonable for most of the applications.
6.4.1.) To setup raid5 on three slices of different disks .
# metainit d45 -r c2t3d0s2 c3t0d0s2 c4t0d0s2
d45: RAID is setup
6.5.) Creating a Trans Meta Device :
Trans meta devices enables ufs logging . There is one logging device and a master device and all file system changes are written into logging device and posted on to master device . This greatly reduces the fsck time for very large file systems as fsck has to check only the logging device which is usually of 64 M. maximum size.Logging device preferably should be mirrored and located on a different drive and controller than the master device .
Ufs logging can not be done for root partition.
6.5.1) Trans Metadevice for a File System That Can Be Unmounted
· /home2
1. Setup metadevice
# umount /home2
# metainit d63 -t c0t2d0s2 c2t2d0s1
d63: Trans is setup
Logging becomes effective for the file system when it is remounted
2. Change vfstab entry & reboot
from
/dev/md/dsk/d2 /dev/md/rdsk/d2 /home2 ufs 2 yes -
to
/dev/md/dsk/d63 /dev/md/rdsk/d63 /home2 ufs 2 yes -
# mount /home2
Next reboot displays the following message for logging device
# reboot
...
/dev/md/rdsk/d63: is logging
6.5.2 ) Trans Metadevice for a File System That Cannot Be Unmounted
· /usr
1.) Setup metadevice
# metainit -f d20 -t c0t3d0s6 c1t2d0s1
d20: Trans is setup
2.) Change vfstab entry & reboot:
from
/dev/dsk/c0t3d0s6 /dev/rdsk/c0t3d0s6 /usr ufs 1 no -
to
/dev/md/dsk/d20 /dev/md/rdsk/d20 /usr ufs 1 no -
# reboot
6.5.3 ) TransMeta device using Mirrors
1.) Setup metadevice
#umount /home2
#metainit d64 -t d30 d12
d64 trans is setup
2.) Change vfstab entry & reboot:
from
/dev/md/dsk/d30 /dev/md/rdsk/d30 /home2 ufs 2 yes
to
/dev/md/dsk/d64 /dev/md/rdsk/d64 /home2 ufs 2 yes
6.6 ) HotSpare Pool
A hot spare pool is a collection of slices reserved by DiskSuite to be automatically substituted in case of a slice failure in either a submirror or RAID5 metadevice . A hot spare cannot be a metadevice and it can be associated with multiple submirrors or RAID5 metadevices. However, a submirror or RAID5 metadevice can only be asociated with one hot spare pool. .Replacement is based on a first fit for the failed slice and they need to be replaced with repaired or new slices. Hot spare pools may be allocated, deallocated, or reassigned at any time unless a slice in the hot spare pool is being used to replace damaged slice of its associated metadevice.
6.6.1) Associating a Hot Spare Pool with Submirrors
# metaparam -h hsp100 d10
# metaparam -h hsp100 d11
# metastat d0
d0: Mirror
Submirror 0: d10
State: Okay
Submirror 1: d11
State: Okay
...
d10: Submirror of d0
State: Okay
Hot spare pool: hsp100
...
d11: Submirror of d0
State: Okay
Hot spare pool: hsp100
6.6.2 ) Associating or changing a Hot Spare Pool with a RAID5 Metadevice
#metaparam -h hsp001 d10
#metastat d10
d10:RAID
State: Okay
Hot spare Pool: hsp001
6.6.3 ) Adding a Hot Spare Slice to All Hot Spare Pools
# metahs -a -all /dev/dsk/c3t0d0s2
hsp001: Hotspare is added
hsp002: Hotspare is added
hsp003: Hotspare is added
6.7 ) Disksets
Few important points about disksets :
- A diskset is a set of shared disk drives containing DiskSuite objects that can be shared exclusively (but not concurrently) by one or two hosts. Disksets are used in high availability failover situations where the ownership of the failed machine’s diskset is transferred to other machine . Disksets are connected to two hosts for sharing and must have same attributes , controller/target/drive , in both machines except for the ownership .
- DiskSuite must be installed on each host that will be connected to the diskset.There is one metadevice state database per shared diskset and one on the "local" diskset. Each host must have its local metadevice state database set up before you can create disksets. Each host in a diskset must have a local diskset besides a shared diskset.A diskset can be created seprately on one host & then added to the second host later.
- Drive should not be in use by a file system, database, or any other application for adding in diskset .
- When a drive is added to disksuite it is repartitioned so that the metadevice state database replica for the diskset can be placed on the drive. Drives are repartitioned when they are added to a diskset only if Slice 7 is not set up correctly. A small portion of each drive is reserved in Slice 7 for use by DiskSuite. The remainder of the space on each drive is placed into Slice 0.. After adding a drive to a diskset, it may be repartitioned as necessary, provided that no changes are made to Slice 7 . If Slice 7 starts at cylinder 0, and is large enough to contain a state database replica, the disk is not repartitioned.
- When drives are added to a diskset, DiskSuite re-balances the state database replicas across the remaining drives. Later, if necessary, you can change the replica layout with the metadb(1M) command.
- To create a diskset, root must be a member of Group 14, or the ./rhosts file must contain an entry for each host.
6.7.1 ) Creating Two Disksets
host1# metaset -s diskset0 -a -h host1 host2
host1# metaset -s diskset1 -a -h host1 host2
host1# metaset
Set name = diskset0, Set number = 1
Host Owner
host1
host2
Set name = diskset1, Set number = 2
Host Owner
host1
host2
6.7.2 ) Adding Drives to a Diskset
host1# metaset -s diskset0 -a c1t2d0 c1t3d0 c2t2d0 c2t3d0 c2t4d0 c2t5d0
host1# metaset
Set name = diskset0, Set number = 1
Host Owner
host1 Yes
host2
Drive Dbase
c1t2d0 Yes
c1t3d0 Yes
c2t2d0 Yes
c2t3d0 Yes
c2t4d0 Yes
c2t5d0 Yes
Set name = diskset1, Set number = 2
Host Owner
host1
host2
6.7.3 ) Creating a Mirror in a Diskset
# metainit -s diskset0 d51 1 1 /dev/dsk/c0t0d0s2
diskset0/d51: Concat/Stripe is setup
# metainit -s diskset0 d52 1 1 /dev/dsk/c1t0d0s2
diskset0/d52: Concat/Stripe is setup
# metainit -s diskset0 d50 -m d51
diskset0/d50: mirror is setup
# metattach -s diskset0 d50 d52
diskset0/d50: Submirror d52 is attached
7.0 Trouble Shooting
7.1 ) Recovering from Stale State Database Replicas
Problem : State database corrupted or unavailable .
Causes : Disk failure , Disk I/O error.
Symptoms : Error message at the booting time if databases are <= 50% of total database. System comes to Single user mode.
ok boot
...
Hostname: host1
metainit: Host1: stale databases
Insufficient metadevice database replicas located.
Use metadb to delete databases which are broken.
Ignore any "Read-only file system" error messages.
Reboot the system when finished to reload the metadevice
database.
After reboot, repair any broken database replicas which were
deleted.
Type Ctrl-d to proceed with normal startup,
(or give root password for system maintenance): <root-password>
Entering System Maintenance Mode.
1.) Use the metadb command to look at the metadevice state database and see which state database replicas are not available. Marked by unknown and M flag.
# /usr/opt/SUNWmd/metadb -i
flags first blk block count
a m p lu 16 1034 /dev/dsk/c0t3d0s3
a p l 1050 1034 /dev/dsk/c0t3d0s3
M p unknown unknown /dev/dsk/c1t2d0s3
M p unknown unknown
2.) Delete the state database replicas on the bad disk using the -d option to the metadb(1M) command.
At this point, the root (/) file system is read-only. You can ignore the mddb.cf error messages:
# /usr/opt/SUNWmd/metadb -d -f c1t2d0s3
metadb: demo: /etc/opt/SUNWmd/mddb.cf.new: Read-only file system .
Verify deletion
# /usr/opt/SUNWmd/metadb -i
flags first blk block count
a m p lu 16 1034 /dev/dsk/c0t3d0s3
a p l 1050 1034 /dev/dsk/c0t3d0s3
3.) Reboot.
4.) Use the metadb command to add back the state database replicas and to see that the state database replicas are correct.
# /usr/opt/SUNWmd/metadb -a -c 2 c1t2d0s3
# /usr/opt/SUNWmd/metadb
flags first blk block count
a m p luo 16 1034 dev/dsk/c0t3d0s3
a p luo 1050 1034 dev/dsk/c0t3d0s3
a u 16 1034 dev/dsk/c1t2d0s3
a u 1050 1034 dev/dsk/c1t2d0s3
7.2 ) Metadevice Errors :
Problem : Sub Mirrors out of sync in "Needs maintainence" state ,
Causes : Disk problem / failure , improper shutdown , communication problems between two mirrored disks .
symptoms : "Needs maintainence" errors in metastat output
# /usr/opt/SUNWmd/metastat |
Solution :
1.) If disk is all right - enable the failed metadevice with metareplace command .
If disk is failed - Replace disk create similar partitions as in failed disk and enable new device with metareplace command.
# /usr/opt/SUNWmd/metareplace -e d0 c0t3d0s0
Device /dev/dsk/c0t3d0s0 is enabled
2.) If disk has failed and you want to move the failed devices to new disk with different id (CnTnDn) - add new disk ,
format to create a similar partition scheme as in failed disk and use metarepalce command
# /usr/opt/SUNWmd/metareplace d0 c0t3d0s0
The metareplace command above can also be used for concate or strip replacement in a volme but that would involve restoring the backup if it is not mirrored.