Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts

Wednesday, December 19, 2012

solaris some useful commands-1



    Explain the boot process?
    Boot process dived into 4 phases.
    1. POST
    2. OBPROM
    3. KERNEL INITIALIZATION
    4. INIT PHASES
    5.SVC statd
    POST: Power on self test, It will detect hardware, machine host ID,serial No, architecture type, memory and Ethernet address and it will load the primary program called bootblk.
    OBP: Open boot programmable,
                1.Diagnosing all the system hardware and memory.
                2.Initializing the boot parameter.
                3.Creating device trees and load the boot block from (0-15 sector), it is called as
                   secondary boot programmable ufsboot.
    KERNEL
    INITIALIZATION: ufsboot load the kernel (generic unix), kernel will load all the necessary
                             devices modules to mount the root partition to continue the booting process.

    Init Phase : It will started by executing of /etc/init program and start other process reading the
                       /etc/inittab files, as the directory in the /etc/inittab files.
    Svc startd : It will read the rcp data and start the services
    What is the difference between init 1 and init s ?
    If you switch from multiuser mode to init s and switch it back to multiuser mode.then remote useres automatically reconnects to the system.
    where as in the case of init 1. they have to reconnect manully means they have to relogin
    Explain about init phases
    There are 8 run level.
    Init0: Shutting down the system and bring back the system to OBP prompt (OK)
    Init1: Single user mode for administrative
    Init2: Multi user mode without resource sharing
    Init3: Multi user mode with resource sharing
    Init4: Not in use
    Init5: Shutdown and power off the system
    Init6: Reboot the system to default run level
    Inits: Single user mode but user login are disabled

    Explain rc script and run level
    Rc script : check and mount the file system, start and stop the various process.
    Run level: Base on the init phases 8 run level
    Which file will take place while booting.
    # /etc/inittab
    How many file to modify the host name to be changed without rebooting the system.
    There are 6 files.
    #vi /etc/hosts
    #vi /etc/nodename
    #vi /etc/hostname.hme
    #vi /etc/net/ticlts/hosts
    #vi /etc/net/ticosts/hosts
    #vi /etc/net/ticotsord/hosts
    Where the ip address will be stored
    # /etc/hosts
    # /etc/hosts.equi
    # /etc/hosts.hme
    How to configure the network card
    # ifconfig hme0 plumb
    # ifconfig hme0 192.9.200.10 netmask 255.255.255.0 up
    # vi /etc/hosts ( update the ip address )
    # vi /etc/hosts.hme0 ( update the ip address ) --> to bring the interface along with the ipaddress during boot time.

    How to configure the virtual ip address
    Infinity virtual ip address can be created.
    # ifconfig hme0:1 plumb
    # ifconfig hme0:1 192.9.200.10 netmask 255.255.255.0 up
    # vi /etc/hosts ( update the ip address )
    # vi /etc/hosts.hme0:1 ( update the ip address ) --> to bring the interface along with the ipaddress during boot time.

    How to find the network card speed
    # ndd –get /dev/hme link_speed          
    1 = 100mbps
    0 = 10mbps

    How to modify network card speed
    # ndd –set /dev/hme instance 0
    # ndd –get /dev/hme link_status
    # ndd –get /dev/hme link_mode
                 To modify
    # ndd –set /dev/eri instance 0
    # ndd –set /dev/eri adv_100T4_cap0
    # ndd –set /dev/eri adv_100fdx_cap1
    # ndd –set /dev/eri adv_100hdx_cap0
    # ndd –set /dev/eri adv_10fdx_cap0
    # ndd –set /dev/eri adv_10hdx_cap0
    # ndd –set /dev/eri adv_autoneg_cap0
    How to find the hardware configuration
    OK banner --> from the open boot prompt
    # prtconf
    # sysdef
    # /use/platform/sun4u/sbin/prtdiag

   How will you find the number of hard disk
    # format
    #dmesg  --> this will not give the correct answer
    #sysdef
    #iostat –En  --> it wont show the Fibre channel
    OK show-devs --> it will show the device scsi bus channel
    OK probe-scsi-all --> This will deteck all the scsi bus channel, it will show CD-ROM/DVD-ROM also
    Difference between probe-scsi-all and probe-scsi
    OK probe-scsi-all: it will show all the scsi devices connected internal and external
    OK probe-scsi: it will show only internal scsi devices connected
    How to create core dump and crash dump
    #coreadm
    Procedure for Firmware upgrade Shutdown root cron on csslu377 servers  #./etc/init.d/cron stop
    Reset the system controller from the console.# resetsc -y Upgrade the firmware on the system controller  > cd /114527-04 > lom -G ./sgrtos.flash> lom -G ./sgsc.flash Escape to lom> and reset the SC:  lom> resetsc -y Upgrade the firmware on the system boards:> lom -G ./lw8cpu.flash> lom -G ./lw8pci.flash Shutdown the Operating System. #shutdown –i0 –g0 –y
    This may take a while for the server to come up
    > poweroff> poweron
    Which file to be configuring the logs messages (like: /var/adm/message etc…)
    #/etc/syslog.conf
  Which file maintain the kernel
    # /etc/path_to_inst
  This will be quite complicative, because kernel is the core of the operating system, its an image of the OS. whereas /etc/path_to_inst are the drivers are stored for the enabled hardware.
    How will see the kernel version
    Ok banner --> This will not show the Kernel
    Ok .version  --> This will tell the open boot prompt version otherwords, FIRMWARE
    # prtconf –V
    # showrev --> will show the installed patches
    # uname –x

Tuesday, September 25, 2012

List LUNs attached to HBA / Disk controllers in Solaris 10

As a system administrator you may come across situations where in your SAN admin presents you some storage (LUNS) and you can’t find where the hell has it gone. The following are some of the ways to list the LUNS presented on a controller or all the controllers on the server.

1. Using fcinfo

In Solaris 10, you can use the “fcinfo” utility which is a 2 step process to identify the Luns presented to the server.

1. Find the HBA port WWN number on the server:
# fcinfo hba-port
This command will show the HBA Port WWN (world wide Node ) among other information like the Node WWN, Device name, manufacturer, firmware, driver details etc.
root@myserver:/root # fcinfo hba-port
HBA Port WWN: 21000022ff0553e9
OS Device Name: /dev/cfg/c5
Manufacturer: QLogic Corp.
Model: 371-4324-02
Firmware Version: 05.03.02
FCode/BIOS Version: BIOS: 2.02; fcode: 2.03; EFI: 2.01;
Serial Number: 0402R00-1102885753
Driver Name: qlc
Driver Version: 3.00p
Type: L-port
State: online
Supported Speeds: 2Gb 4Gb 8Gb
Current Speed: 4Gb
Node WWN: 20000022ff0553e9
Here 21000022ff0553e9 is the WWN number for the HBA port.

2. List SCSI targets for the remote port attached to the HBA port attached to the above.
# fcinfo -sl -p HBA-Port-WWN
root@myserver:/root # fcinfo remote-port -sl -p 21000022ff0553e9
Remote Port WWN: 202400a0b8744072
Active FC4 Types:
SCSI Target: yes
Node WWN: 200400a0b8744072
Link Error Statistics:
Link Failure Count: 1
Loss of Sync Count: 2
Loss of Signal Count: 72
Primitive Seq Protocol Error Count: 0
Invalid Tx Word Count: 0
Invalid CRC Count: 0
LUN: 0
Vendor: SUN
Product: LCSM100_F
OS Device Name: /dev/rdsk/c5t202400A0B8744072d0s2
LUN: 2 Vendor: SUN
Product: LCSM100_F
OS Device Name: /dev/rdsk/c5t202400A0B8744072d2s2
LUN: 31 Vendor: SUN
Product: Universal Xport
OS Device Name: /dev/rdsk/c5t202400A0B8744072d31s2
Here, LUN0 and LUN2 are the actual disks and LUN31 is the Command device for the Storage controller
2. Using cfgadm

You can also find the above information using the “cfgadm” utility. One of the following commands should reveal the LUNS attached to the controller. Although the later works only on Solaris 10.
# cfgadm -al -o show_FCP_dev c5
 
or
 
# cfgadm -al -o show_SCSI_LUNS c5
where c5 is the controller. If you do not mentioned the controller, it then displays for every single disk controller on the server.
root@myserver:/root # cfgadm -al -o show_FCP_dev c5
Ap_Id Type Receptacle Occupant Condition
c5 fc-private connected configured unknown
c5::202400a0b8744072,0 disk connected configured unknown
c5::202400a0b8744072,2 disk connected configured unknown
c5::202400a0b8744072,31 disk connected configured unknown
root@myserver:/root # cfgadm -al -o show_SCSI_LUN c5
Ap_Id Type Receptacle Occupant Condition
c5 fc-private connected configured unknown
c5::202400a0b8744072,0 disk connected configured unknown
c5::202400a0b8744072,2 disk connected configured unknown
c5::202400a0b8744072,31 disk connected configured unknown
 
                      thanks for Reading.. 

Friday, September 21, 2012

DISK QUOTA PERMISSIONS IN SOLARIS 10

verify before prceeding.

SUN#df -k or df -h
sun#format

follow the below screen shots.



next create a filesystem on partition.
#newfs /dev/rdsk/c0t0d0s(enter the slice no you have selected)


1.create a user account with home directory and assign password to the user.
sun#useradd -d /export/home/<home dir> -m sun<username>
sun#passwd <username>
password:
confirm password :

2.mount the partition on user home directory.
sun#mount /dev/dsk/c0t0d0s<no> /export/home/<user home dir>

quota permissions:
sun#cd /export/home
sun#touch quotas
sun#quotaon -v /export/home
sun#edquota <username>
new window will appear
fs /export/home   blocks(soft=4,hard=8)
                inodes (soft=4,hard=8)
then save the file.

To copy the quota permissions from one user to another user.
sun#edquota -p <old user> <new user>

To verify-
sun#repquota -v /export/home

To turnoff quota
sun#quotaoff -v /export/home.

                                                Thank you for Reading.

  

Tuesday, March 6, 2012

User Creation and Remove commands in solaris 10

Hi,
Creating User Accounts

To create a user account:

# useradd -u 100 -g other -d /export/home/newuser1 -m -s /bin/ksh -c
"Regular User Account" newuser1

# passwd newuser1


# /usr/sadm/bin/smuser add -- -n newuser2 -u 500 -g other -d

/export/home/newuser2 -c "Regular User Account 2" -s /bin/ksh -x
autohome=N

# passwd newuser2


Modifying User Accounts


To change the login name and home directory for newuser1 to usera.


# usermod -m -d /export/home/usera -l usera newuser1


To change the login name and home directory for newuser2 to userb.


# /usr/sadm/bin/smuser modify -- -n newuser2 -N userb -d /export/home/userb


Deleting User Accounts

# userdel usera        ==> to remove the user account

# userdel -r usera    ==> to remove both the users account & home directory



# /usr/sadm/bin/smuser delete -- -n userb    ==> the users home directory                             should be deleted manually


Creating a Group Entry

# groupadd -g 301 class1

# /usr/sadm/bin/smgroup add -- -n workgroup -g 123 -m usera



Modifying a Group Entry

# groupmod -g 400 class1    ==> to change group ID

To change group name

# /usr/sadm/bin/smgroup modify -- -n workgroup -N schoolgroup


Deleting a Group Entry

# groupdel class1

# /usr/sadm/bin/smgroup delete -- -n schoolgroup



# vi /etc/default/passwd    ==> to control the properties for all users’

                    passwords on the system:


# ls -l /usr/sadm/defadduser    ==> to display default values for useradd

                    command

# useradd -D


# cat /usr/sadm/defadduser 

                                        Thanks for Reading. 

Saturday, January 8, 2011

How to backup data on UNIX ?

Hi All,
Backups are one of the major tasks that a Systems Administrator do. Here are few hints for the beginners. You will have to replace the tape device name with the one you are using. See some scripts here.
If you are in hurry and want to use ufsdump and ufsrestore, see example below.

Using cpio

Using cpio to create a file archive on a tape device:
   # find . -print |cpio -ocBv  /dev/rmt0
  Using cpio to list the entries in a file archive on a tape device:
   # cpio -itcvB < /dev/rmt0
  Using cpio to retrieve a file from a tape device:
   # cpio -icvdBum file.name < /dev/rmt0
  You can also use cpio to copy directory structure. For example copy
  Directory structure from current path to /export/home/tariq

   # find . -print|cpio -pmdv /export/home/tariq

Using tar


Using tar to create a file archive on a tape device:
   # tar -cvf /dev/rmt0 file.name   or
   # tar -cvf /dev/rmt0 .  
  or for multiple directory hierarchies
   # tar -crvf my.tar  `find /tmp/junk -type f` `find /var/tmp -type f`
  using tar to list the entries in a file archive on a tape device:
   # tar -tvf /dev/rmt0
  using tar to retrieve a file from a tape device:
   # tar -xvf /dev/rmt0 file.name
  there is more than one way to skin these cats, this being no comprehensive
  look at these utilities.

Using dump and restore (ufsdump, ufsrestore)

dump ( in solaris and others called ufsdump )is said to be the most reliable
  way to backup the whole   filesystem. restore is the utility for restoring 
  data from a dump. We can use restore interactively to restore certain files
  or directories.

  To make a dump of root filesystem on tape device /dev/nrsa0. Note
  that this is a non-rewinding device. See example below.
   # /sbin/dump -0ua -f /dev/nrsa0 /   
   or for solaris
  
   # /usr/sbin/ufsdump 0f /dev/rmt/0cn /
   To interactively restore a backup

   # /sbin/restore -i -f /dev/nrsa0  

   or for solaris

   # /usr/sbin/ufsrestore -xvf /dev/rmt/0cn

   Every thing will be restored in current directory.

Using mt command with dump and restore


mt (magnetic tape manipulating program) is a very useful command
  specialy if you are using dump and restore combination. 

  
  Following are some useful options of mt command.

  # mt status    Print status information about the tape unit.

  # mt rewind    Rewind the tape.

  # mt erase     Erase the tape.

  # mt retension Re-tension the tape (one full wind forth and back.

  # mt fsf 1     Forward space count by one file. One can be any number.

  -f option can be used with mt to specify the different device. For
  solaris /dev/rmt/0 is the default device.

  # mt -f /dev/rmt/1n fsf 3


Example

If you are backing up three filesystems /, /var and /usr on a solaris
    Box to a tape device:
    
     # /usr/sbin/ufsdump 0uf /dev/rmt/0n /      # /usr/sbin/ufsdump 0uf /dev/rmt/0n /var      # /usr/sbin/ufsdump 0uf /dev/rmt/0n /usr 
    This will take three file spaces, one for each filesystem. Filesystem / will
    be on file count 0 of tape and /var will be on file count 1 and /usr will be
    on file space 2. Option 0 specify full backup,u will update the dump record in
    /etc/dumpdates file and f to specify file or device. You can use following 
    command sequence to restore /var filesystem.

    # mt status
    This will show you the current status of tape. After the backup
    on a non-rewinding device, tape will show file number 2
   
    # mt rewind   
    This will rewind the tape to beginning.

    # mt status    
    Tape will be on file count 0

    # mt fsf 1 
    Tape will move to file count number 1 where /var is dumped.

    # /usr/sbin/ufsrestore -xvf /dev/rmt/0n
    /var will be restored in current. This will over-write the current contents.
    Use /dev/rmt/0cn for compression, no rewind device.

Commands for remote tape backup
It is often neccesary to backup into a remote machine's tape drive. Here are the commands that can be used to achieve this. Execute this command on the machine you want to backup.
$ tar cvf - $DIRNAME | rsh $SYS dd of=$TAPEDEV
Substitute
$DIRNAME with the directory to backup,
$SYS with the machine name with the tape drive,
$TAPEDEV with the tape device.
Note: You must be able to rlogin into the remote machine without a password. To do this add the name of your local machine with your user name in the .rhost file in your home directory on the remote machine.
To retrieve the backed up info...
rsh $REM dd if=$TAPEDEV | tar xvf -

Now some small scripts



#!/bin/sh
tar -cvf my.tar $(for i in `cat list`
   do
       echo $i
   done)
exit

This script is backing up to tape using dump command. Logging date and all the messages 
to a log file. 

#!/bin/sh
#
echo "$DATE"backup.log
filenumber=`/usr/bin/mt stat|/usr/bin/grep "File Number"|/usr/bin/awk '{print $3}'`
echo "Backing up / to tape location: $filenumber"backup.log
/sbin/dump -0ua -f /dev/nrsa0 / &2backup.log
if [ $? -eq 0 ];then
   echo "/ backup successful"$HOME/log/backup.log
fi

Copy files ( even complete filesystem) from remote to local system

Note: You must be able to rlogin into the remote machine without a password. To do this add the name of your local machine with your user name in the .rhost file in your home directory on the remote machine.


#!/bin/sh                                                       
#                                                              
# Copies files from Remote System to the local current directory 
#       
name=`basename $0`                  
if [ $# -ne 2 ];then
echo "Usage: $name <remote-system> <dir-to-copy>"
exit                                                            
fi                                                               
system=$1                                                   
dir_to_cp=$2                                                 
rsh $system "cd $dir_to_cp; find . -print|cpio -ocB"|dd ibs=5k obs=5k|cpio -iducmvB

Wednesday, January 5, 2011

Solaris Backup and Restore with ufsdump :- Some useful options

Hi All,

1. Backing up to a file:

root@host #  ufsdump -0f /admin/backup/etc.dump /etc
  DUMP: Date of this level 0 dump: Mon Jul 05 16:41:36 2010
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c1t0d0s0 (cat:/) to /admin/backup/etc.dump.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 32 Kilobyte records
  DUMP: Estimated 148290 blocks (72.41MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 147902 blocks (72.22MB) on 1 volume at 8136 KB/sec
  DUMP: DUMP IS DONE


2. Restoring data from backup file.

For non interactive (this will restore everything) restore:-

ufsrestore -xvf /admin/backup/etc.dump
for interactive restore:-
ufsrestore -ivf /admin/backup/etc.dump
Here is the proceedure to restore single file named hosts.090610 only.
 ufsrestore -ivf /admin/backup/etc.dump

root@host # ufsrestore -ivf etc.dump
Verify volume and initialize maps
Media block size is 126
Dump   date: Mon Jul 05 16:41:36 2010
Dumped from: the epoch
Level 0 dump of a partial file system on cat:/etc
Label: none
Extract directories from tape
Initialize symbol table.
ufsrestore >
ufsrestore > cd /etc
ufsrestore > ls hosts*
   1378  hosts
   5795  hosts.090610
ufsrestore >
ufsrestore > add hosts.090610
Warning: ./etc: File exists
ufsrestore > extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./etc/hosts.090610
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] y
Directories already exist, set modes anyway? [yn] y

3. Copying the contents of a directory to another directory including symbolic links. This is useful when you want to migrate data to new mount point or different path.

Here, all the data /etc will be copied to /admin/backup/etc.

root@host #mkdir /admin/backup/etc
root@host# ufsdump -0f  - /etc|(cd /admin/backup/etc;ufsrestore -xvf -).

Just before this command finish, it may prompt for setting ownership, it must be answered as yes.

After complete above command, if  you found that its restored using relative path, you can just use mv command to move the data.

For instance, if the restoration happend /admin/backup/etc/etc, you do a mv *  /admin/backup/etc/etc/* /admin/backup/etc.

Popular Posts

Followers

Disclaimer

All Data and Information Provided on This BLOG is only for Education purposes only.If you done any thing else these in real time the blog is not Responsible.Try all those on your own risk.
IF you find any thing else here as per in violation of copyright law .mail me on srinathceh@gmail.com as soon as possible action will be taken.