Friday, March 21, 2014

How to create and install whole root zone on Solaris10

A whole root zone contains a read/write copy of the file system . When a whole root zone is created, from GLOBAL all packages are copied onto the whole root zone, it will create a dedicated copy of all files.

Steps to create Whole root zone with exclusive IP-address:

Some of the pre-request tasks.

1). Collect global server network details. 
2). Decide zone name what you want to create it 
3). Create zone directory with absolute path 
4). Change zone patch permission to 700 
5). Decide NIC/IP-address which you want to use for zone 

My GLOBAL zone network details:
[root@ivm01~]# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843 mtu 1500 index 2
        inet 192.168.10.21 netmask ffffff00 broadcast 192.168.10.255
        ether 0:c:29:1d:c0:ff
[root@ivm01~]#dladm show-dev
e1000g0         link: up        speed: 1000  Mbps       duplex: full
e1000g1         link: unknown   speed: 0     Mbps       duplex: half
[root@ivm01~]#

To create simple whole root zone with exclusive IP, screenshot for same.

Note : For exclusive IP setup, we should not provide IP address while creating zone we have to configure IP address in OS level.

Create zone path and change permission:
[root@ivm01~]# mkdir /zonepool/tpt02
[root@ivm01~]# chmod 700 /zonepool/tpt02
[root@ivm01~]# ls -ld /zonepool/tpt02
drwx------   2 root     root           2 Mar 12 00:52 /zonepool/tpt02
[root@ivm01~]#
Procedure to create whole root zone: 
Note: To create whole root zone we must & should use -b option along with create command, else it will be a spare root zone.
[root@ivm01~]# zonecfg -z tpt02
tpt02: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:tpt02> create -b
zonecfg:tpt02> set zonepath=/zonepool/tpt012
zonecfg:tpt02> set zonename=tpt02
zonecfg:tpt02> set ip-type=exclusive
zonecfg:tpt02> add net
zonecfg:tpt02:net> set physical=e1000g1
zonecfg:tpt02:net> end
zonecfg:tpt02> info
zonename: tpt02
zonepath: /zonepool/tpt012
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: exclusive
hostid:
net:
        address not specified
        physical: e1000g1
        defrouter not specified
zonecfg:tpt02> commit
zonecfg:tpt02> verify
zonecfg:tpt02> exit
[root@ivm01~]#
Installation of whole root zone:
[root@ivm01~]# zoneadm -z tpt02 install
A ZFS file system has been created for this zone.
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <189370> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <\> packages on the zone.
Initializing package <0> of <1466>: percent complete: 0%         
Initializing package <1> of <1466>: percent complete: 0%
Initializing package <1463> of <1466>: percent complete: 99%         
Initializing package <1464> of <1466>: percent complete: 99%         
Initializing package <1465> of <1466>: percent complete: 99%         
Initialized <1466> packages on zone.                                
Zone  is initialized.
The file (/zonepool/tpt02/root/var/sadm/system/logs/install_log) contains a log of the zone installation.
[root@ivm01~]#
To check zone status:
[root@ivm01~]# zoneadm list -cv
ID NAME          STATUS     PATH                        BRAND    IP    
0 global        running    /                              native   shared
- tpt02         installed  /zonepool/tpt02                native   excl  
[root@ivm01~]#
Boot the zone and login to the zone console, provide all the details to complete the zone installation:
[root@ivm01~]# zoneadm -z tpt02 boot
[root@ivm01~]# zlogin -C tpt02
[Connected to zone 'tpt02' console]
Select a Language

  0. English
  1. Japanese
  2. Korean
  3. Simplified Chinese
  4. Traditional Chinese

Please make a choice (0 - 4), or press h or ? for help: 0
rebooting system due to change(s) in /etc/default/init


[NOTICE: Zone rebooting]


SunOS Release 5.10 Version Generic_147441-01 64-bit
Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved.
Hostname: tpt02
tpt02 console login: root
Password: Mar  5 23:08:59 tpt02 sendmail[13000]: My unqualified host name (tpt02) unknown; sleeping for retry Mar  5 23:08:59 tpt02 sendmail[13012]: My unqualified host name (tpt02) unknown; sleeping for retry 
Mar  5 23:09:00 tpt02 login: ROOT LOGIN /dev/console Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# bash
[root@ivm01~]#
Login to the zone:
[root@ivm01~]# zlogin tpt02
[Connected to zone 'tpt02' pts/4]
Last login: Wed Mar  5 00:45:10 on pts/4
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# bash
[root@tpt02~]# df -h
Filesystem             size   used  avail capacity  Mounted on
/                       19G   4.6G    14G    25%    /
/dev                    19G   4.6G    14G    25%    /dev
proc                     0K     0K     0K     0%    /proc
ctfs                     0K     0K     0K     0%    /system/contract
mnttab                   0K     0K     0K     0%    /etc/mnttab
objfs                    0K     0K     0K     0%    /system/object
swap                   601M   316K   601M     1%    /etc/svc/volatile
/usr/lib/libc/libc_hwcap1.so.1
                        19G   4.6G    14G    25%    /lib/libc.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                   601M    36K   601M     1%    /tmp
swap                   601M    20K   601M     1%    /var/run
[root@tpt02~]#

Thursday, March 20, 2014

How to Add / Change / Delete route in solaris10 on different methods

This article will explain about to add type of routes in Solaris10 .

Static and Dynamic routes:

The static routes are added by using the route command either by a script or by using command line. Dynamic routes are added by default routing daemons.These are the deamons /usr/sbin/in.routed (Routing Information Protocol(RIP) and /usr/sbin/in.rdisc (Router Network Discovery Protocol) which are responsible for adding dynamic routes that are inbuilt with Solaris OS it self. 

Pre-request tasks:
1). Take backup of current configuration file as well as screenshot
2). Check whether your able to ping and trace route IP which your going to add or change
3). Take console access before changing default router, it may cause to not allow ssh some time

The various flags in routes :

U – The route is up.
G – The route uses a gateway.
H – The target is a host route.
D – The route was added dynamically by ICMP redirect.
M - The flag signifies that this route is modified by a redirect.

My Server Current Setup:
bash-3.2# netstat -rn
Routing Table: IPv4
Destination        Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- -- ---------- ---------
192.168.10.0      192.168.10.21        U         1         25 e1000g0
224.0.0.0         192.168.10.21        U         1          0 e1000g0
127.0.0.1         127.0.0.1            UH        6         67 lo0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
bash-3.2#
Here I am adding, changing and deleting route aka default gateway in two method.
1). Generally adding, changing and deleting default route without specifying interface
2). Adding , changing and deleting default route with specifying interface

To add default router persistently : (if your using route command with -p option then not require to put entry to /etc/defaultrouter file, instead it will add entry 
automatically to /etc/inet/static_routes file which will take care across reboot. 
bash-3.2# route -p add default 192.168.10.1
add net default: gateway 192.168.10.1
add persistent net default: gateway 192.168.10.1
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
default 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
Destination           Gateway         Flags  Ref     Use     Interface
-------------------- ----------------- ----- ----- ---------- ---------
default              192.168.10.1         UG        1          0
192.168.10.0         192.168.10.21        U         1         57 e1000g0
224.0.0.0            192.168.10.21        U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        4        133 lo0
bash-3.2#
Note - We can't change persistent route using -p , we have to delete it and add it.
bash-3.2# route -p change default 192.168.10.10
change net default: gateway 192.168.10.10
route: change command not supported with -p
bash-3.2#
To delete persistent default route:
bash-3.2# route -p delete default 192.168.10.1
delete net default: gateway 192.168.10.1
delete persistent net default: gateway 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
Destination         Gateway           Flags  Ref     Use     Interface
----------------- -------------------- ----- ----- ---------- ---------
192.168.10.0         192.168.10.21        U         1         25 e1000g0
224.0.0.0            192.168.10.21        U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        4        131 lo0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
bash-3.2#
To add "default" router without and with specifying interface:
bash-3.2# route add default 192.168.10.10
add net default: gateway 192.168.10.10
bash-3.2# route add default 192.168.10.1 -ifp e1000g0
add net default: gateway 192.168.10.1
bash-3.2# netstat -rn
Routing Table: IPv4
  Destination           Gateway        Flags  Ref     Use     Interface
-------------------- ----------------- ----- ----- ---------- ---------
default              192.168.10.10        UG        1          0
default              192.168.10.1         UG        1          0 e1000g0
192.168.10.0         192.168.10.21        U         1         32 e1000g0
224.0.0.0            192.168.10.21        U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        4        133 lo0
bash-3.2#
To change "default" router without and with specifying interface:
bash-3.2# route change default 192.168.10.5
change net default: gateway 192.168.10.5
bash-3.2# route change default 192.168.10.21 -ifp e1000g0
change net default: gateway 192.168.10.21
bash-3.2# netstat -rn
Routing Table: IPv4
  Destination           Gateway       Flags  Ref     Use     Interface
-------------------- ----------------- ----- ----- ---------- ---------
default              192.168.10.5         UG        1          0
default              192.168.10.21        UG        1          0 e1000g0
192.168.10.0         192.168.10.21        U         1         32 e1000g0
224.0.0.0            192.168.10.21        U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        4        133 lo0
bash-3.2# 
To delete"default" router without and with specifying interface:
bash-3.2# route delete default 192.168.10.5
delete net default: gateway 192.168.10.5
bash-3.2# route delete default 192.168.10.21 -ifp e1000g0
delete net default: gateway 192.168.10.21
bash-3.2# netstat -rn
Routing Table: IPv4
  Destination           Gateway        Flags  Ref     Use     Interface
-------------------- ----------------- ----- ----- ---------- ---------
192.168.10.0         192.168.10.21        U         1         32 e1000g0
224.0.0.0            192.168.10.21        U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        4        133 lo0
bash-3.2#
To make this changes effect across reboot we have put entry to /etc/defaultrouter file.Usually and by Default /etc/defaultrouter file will not be there , we have to create it manually. 

To set static routes: Use route command to add static route on fly (dynamic modification of routing table). We have two option to add static routes, persistent and non-persistent. To add static routes persistent: we have to use -p option with route command or we can create rc script and put the entry to the script which will add it across reboot. 

Adding route using -p option(/etc/inet/static_routes):
bash-3.2#route -p add net 192.168.10.0/24 gateway 192.168.10.10
add persistent net 192.168.10.0/24: gateway 192.168.10.10
bash-3.2# route -p add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
add net 192.168.10.0: gateway 192.168.10.1
add persistent net 192.168.10.0: gateway 192.168.10.1
bash-3.2# netstat -rnv
IRE Table: IPv4
  Destination             Mask           Gateway          Device Mxfrg Rtt   Ref Flg  Out  In/Fwd
-------------------- --------------- -------------------- ------ ----- ----- --- --- ----- ------
192.168.10.0         255.255.255.0   192.168.10.21      e1000g0  1500*    0   1 U       51      0
192.168.10.0         255.255.255.0   192.168.10.10              1500*    0   1 UG       0      0
192.168.10.0         255.255.255.0   192.168.10.1               1500*    0   1 UG       0      0
224.0.0.0            240.0.0.0       192.168.10.21      e1000g0  1500*    0   1 U        0      0
127.0.0.1            255.255.255.255 127.0.0.1          lo0     8232*    0   4 UH     133      0
bash-3.2# cat /etc/inet/static_routes
# File generated by route(1M) - do not edit.
192.168.10.0/24 192.168.10.10
192.168.10.0 -netmask 255.255.255.0 192.168.10.1
bash-3.2#
To add non-persistent route which will flushed if you reboot:
bash-3.2# route add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
add net 192.168.10.0: gateway 192.168.10.1
bash-3.2# route add 192.168.10.0/24 192.168.10.10
add net 192.168.10.0/24: gateway 192.168.10.10
bash-3.2# netstat -rnv
IRE Table: IPv4
  Destination             Mask           Gateway          Device Mxfrg Rtt   Ref Flg  Out  In/Fwd
-------------------- --------------- -------------------- ------ ----- ----- --- --- ----- ------
192.168.10.0         255.255.255.0   192.168.10.21      e1000g0  1500*    0   1 U       49      0
192.168.10.0         255.255.255.0   192.168.10.1               1500*    0   1 UG       0      0
192.168.10.0         255.255.255.0   192.168.10.10              1500*    0   1 UG       0      0
224.0.0.0            240.0.0.0       192.168.10.21      e1000g0  1500*    0   1 U        0      0
127.0.0.1            255.255.255.255 127.0.0.1          lo0     8232*    0   4 UH     133      0
bash-3.2#
To get information about a specific route :
bash-3.2# route -p get 192.168.10.10
   route to: 192.168.10.10
destination: 192.168.10.0
       mask: 255.255.255.0
  interface: e1000g0
      flags: 
recvpipe  sendpipe  ssthresh  rtt,ms rttvar,ms  hopcount   mtu     expire
       0      0      0      0      0         0      1500         0
get persistent host 192.168.10.10: not in file
bash-3.2# 
To see the persistent routes added in the system :
bash-3.2# route -p show
persistent: route add default 192.168.10.1
bash-3.2#
To use rc script to add route: 
The -p option will not work earlier solaris verion as well as some earlier patch level of solaris 10. To avoid this we have a another optin to create a rc script under /etc/rc2.d/. 

Add the route add command in this script :
i.e /etc/rc2.d/S90route
bash-3.2# cat /etc/rc2.d/S90route
/usr/sbin/route add 192.168.10.0 -netmask 255.255.255.0 192.168.10.1
bash-3.2#
To flush (remove) the routing table of all gateway entries, use the route flush command:
bash-3.2# route flush
default              192.168.10.10        done
bash-3.2#
To add a route manually to the multicast address for range of 192-254:
bash-3.2# route add 224.0/24 `uname -n`
add net 224.0/24: gateway techpanel
bash-3.2# netstat -rn
Routing Table: IPv4
Destination           Gateway           Flags  Ref     Use     Interface
----------------- -------------------- ----- ----- ---------- ---------
192.168.10.0         192.168.10.21        U         1         26 e1000g0
224.0.0.0            192.168.10.21        UG        1          0
224.0.0.0            192.168.10.21        UG        1          0
127.0.0.1            127.0.0.1            UH        4        131 lo0
bash-3.2#
You can refer multicast address range here as well as in this link Netmask:

Net ClassAddr RangeNetMaskNet Addr BitsHost Addr BitsTotal Number of hostsExample Range
A0-127255.0.0.082416777216(i.e. 114.0.0.0)
B128-191255.255.0.0161665536(i.e. 150.0.0.0)
C192-254255.255.255.0248256(i.e. 199.0.0.0)
D224-239(multicast)
E240-255(reserved)
F208-215255.255.255.24028416
G216/8ARIN North America
G217/8RIPE NCC Europe
G218-219/8APNIC
H220-221255.255.255.2482938(reserved)
K222-223255.255.255.2543112(reserved)
We can also use /etc/gateways file to add static routes. The /etc/gateways file is used by the routing daemon in.routed when the daemon starts,it reads /etc/gateways to find such distant gateways. The /etc/gateways file consists of a series of lines. i.e Blank lines and lines starting with "#" are treated as comments. Generally /etc/gateways files not there, we need to create it manually.
bash-3.2# cat /etc/gateways
net 192.168.10.0 gateway 192.168.10.1
bash-3.2#
Thanks for reading this article...

Tuesday, March 18, 2014

Solaris 10 OS patching using LU (Live upgrade method)

Using Solaris Live Upgrade (LU) to patch CPU patch cluster.
Generally CPU OS patch cluster will take more time to complete the patching activity dependence on the running kernel patch level. Coz this server might patch very long back so it will increase server maintenance downtime. To avoid this situation SUN / Oracle has released new feature, that is called  "LIVE UPGRADE (LU)" from Solaris 10 onward.

The main advantages of Live upgrade is minimizing the downtime of server outage and easy to rollback the changes. As well as we can patch the server with out booting server in to single user mode aka maintenance mode , because we are patching the server in alternate boot environment usually call as  (ABE), also while create ABE it will take backup of OS as well, which will help you when rollback is demand.

--> Already I have posted for LU creation producer  , please refer this  LU Creation link for same.

Solaris Live Upgrade Procedure for Patching:
As per below output we have two boot environment:
bash-3.2# lustatus 
Boot Environment      Is       Active Active    Can    Copy 
Name                  Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ -----
s10x_u10wos_17b            yes      yes    yes       no     -       
SOL10-MARCH-2014           yes      no     no        yes    -         
bash-3.2# 
Now we will start our installation of CPU patch cluster activity (Patching Activity):
bash-3.2# ./installcluster --s10patchset -B SOL10-MARCH-2014
Installing this patch set to an alternate boot environment first requiresthe live boot environment to have patch utilities and other prerequisite patches at the same (or higher) patch revisions as those delivered by    this patch set.
The required prerequisite patches can be applied to the live bootenvironment by invoking this script with the '--apply-prereq' option, ie.

 ./installcluster --apply-prereq --s10patchset
bash-3.2#
As per above output installing prerequisite patches:
bash-3.2# ./installcluster --apply-prereq --s10patchset

Setup ........................................

CPU OS Patchset 2013/04 Solaris 10 x86 (2013.03.29)

Application of patches started : 2014.03.05 01:43:24

Application of patches finished : 2014.03.05 01:43:25

Insufficient free swap available to complete installation of thispatch   set.Additional free swap is required to proceed applying further patches.To increase the available free swap, either add new storage resources to swap pool, or reboot the system. This    script may then be rerun to continue installation of the patch set.

Install log files written :
 /var/sadm/install_data/s10x_rec_patchset_short_2014.03.05_01.43.24.log
 /var/sadm/install_data/s10x_rec_patchset_verbose_2014.03.05_01.43.24.log
bash-3.2#
The prerequisite patches installation got failed due to insufficient swap size. Let me create swap space and start patching activity again.
Check the current swap size and add more swap space:
1st creating 4GB zfs volume (emulated volume). Note - It is not a dataset
2nd adding swap volume size by swap -a command
3rd checking the size of whole swap space  
bash-3.2# swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 181,1       8 1572856 1535752
bash-3.2#zfs create -v 4g rpool/swap1
bash-3.2#swap -a /dev/zvol/dsk/rpool/swap1
bash-3.2#swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 181,1       8 1572856 1533880
/dev/zvol/dsk/rpool/swap1 181,3       8 8388600 8388600
bash-3.2#
After added swap space now let me install prerequisite patches first then will go for OS patch bundle installation:
bash-3.2#./installpatchset --apply-prereq --s10patchset

Setup .................................

CPU OS Patchset 2013/04 Solaris 10 x86 (2013.03.29)

Application of patches started : 2014.03.06 20:32:13

Applying 120901-03 ( 1 of 11) ... skipped
Applying 121334-04 ( 2 of 11) ... skipped
Applying 119255-88 ( 3 of 11) ... success
Applying 119318-01 ( 4 of 11) ... skipped
Applying 121297-01 ( 5 of 11) ... skipped
Applying 138216-01 ( 6 of 11) ... skipped
Applying 147062-01 ( 7 of 11) ... skipped
Applying 148337-01 ( 8 of 11) ... success
Applying 146055-07 ( 9 of 11) ... success
Applying 142252-02 (10 of 11) ... skipped
Applying 125556-12 (11 of 11) ... success

Application of patches finished : 2014.03.06 21:01:19

Following patches were applied :
 119255-88     148337-01     146055-07     125556-12

Following patches were skipped :
 Patches already applied
 120901-03     119318-01     138216-01     147062-01     142252-02
 121334-04     121297-01

Installation of prerequisite patches complete.

Install log files written :
 /var/sadm/install_data/s10x_rec_patchset_short_2014.03.06_20.32.13.log
 /var/sadm/install_data/s10x_rec_patchset_verbose_2014.03.06_20.32.13.log
bash-3.2#
Prerequisite patches installed successfully, now we good to go for patch cluster installation :
bash-3.2# ./installpatchset --s10patchset -B SOL_2012Q1SOL10-MARCH-2014

Setup ........................................................

CPU OS Patchset 2013/04 Solaris 10 x86 (2013.03.29)

Application of patches started : 2014.03.06 21:25:52

Applying 120901-03 (  1 of 332) ... skipped
Applying 121334-04 (  2 of 332) ... skipped
Applying 119255-88 (  3 of 332) ... success
Applying 119318-01 (  4 of 332) ... skipped
Applying 121297-01 (  5 of 332) ... skipped
Applying 138216-01 (  6 of 332) ... skipped
Applying 147062-01 (  7 of 332) ... skipped
Applying 148337-01 (  8 of 332) ... success
Applying 121082-08 (326 of 332) ... success
Applying 149454-02 (327 of 332) ... success
Applying 149484-01 (328 of 332) ... success
Applying 149637-02 (329 of 332) ... success
Applying 150118-01 (330 of 332) ... success
Applying 150124-01 (331 of 332) ... success
Applying 150158-01 (332 of 332) ... success

Application of patches finished : 2014.03.07 08:51:42

Following patches were applied :
 119255-88     122213-46     139290-02     146684-01     148564-05
 148337-01     122260-06     141105-04     146695-02     148566-01
 146055-07     122912-31     142934-05     146835-02     148626-01
 125556-12     123614-02     143507-06     147160-01     148658-01
 118668-43     124939-04     144527-02     147274-01     148769-01
 118669-43     125138-46     143644-08     147435-01     148871-01
 121119-19     125139-46     144910-03     147674-04     148889-01
 119060-60     125333-23     145007-04     147716-04     148949-01
 119214-27     125534-17     147218-02     147806-01     148955-01
 119535-29     125720-52     145081-11     148003-01     148976-01
 119758-24     125732-09     145201-12     148005-01     149109-01
 119765-07     126120-02     145900-08     148007-01     149113-01
 119784-25     126207-10     145930-08     148028-03     149150-01
 119811-07     126547-04     146033-05     148082-02     149164-01
 120461-20     127873-02     147443-01     148113-02     149166-01
 119813-18     136883-03     147148-26     148136-01     121082-08
 119901-15     137081-07     146233-20     148166-02     149454-02
 119907-18     137098-02     146471-08     148170-02     149484-01
 120544-30     137148-07     146490-06     148384-01     149637-02
 120720-03     137322-02     146672-10     148404-01     150118-01
 120740-08     138823-12     146680-01     148408-01     150124-01
 120754-09     138827-12     146682-02     148424-01     150158-01
 121096-03

Following patches were skipped :
 Patches already applied
 120901-03     120273-33     125216-04     138248-01     142530-01
 121334-04     122641-06     125280-05     138633-01     142544-01
 119318-01     127756-01     125726-02     138648-01     142912-01
 121297-01     125504-02     125907-01     138650-01     142910-17
 138216-01     125548-02     126364-08     138767-01     143126-02
 147062-01     126424-03     126426-01     138853-01     143503-01
 142252-02     120012-14     126441-01     138883-01     143514-02
 140797-01     139521-02     126869-05     141017-01     143610-03
 113000-07     119904-02     127128-11     139556-08     144501-19
 117435-02     119964-24     127725-02     139616-01     143726-01
 118344-14     119967-01     127764-01     139997-03     143732-01
 118368-04     119987-03     128293-01     140102-01     143740-01
 121264-01     120102-01     128311-01     140913-01     143913-01
 123840-04     120202-06     128333-01     141033-01     143955-04
 138218-01     120236-01     128339-01     142293-01     144048-01
 140861-02     120285-07     128412-01     141445-09     144107-01
 121454-02     121976-01     136715-01     141497-01     144189-02
 121454-02     120536-17     136999-10     141549-01     144328-02
 118855-36     120733-01     137001-08     141559-01     144456-01
 118919-21     120831-06     137033-01     141587-01     144461-02
 119064-01     121300-03     137094-01     141873-01     144493-01
 119082-25     121429-15     137103-01     141901-01     144570-01
 119116-35     121607-04     137116-01     142050-01     144751-01
 119131-33     122655-05     138867-02     142059-01     144912-02
 123612-05     122755-01     138884-01     142089-02     145020-01
 119281-25     123004-04     137138-09     142235-01     145097-03
 119283-01     123527-01     137283-01     142241-01     145121-01
 140900-01     123591-12     137872-02     142248-01     145954-06
 119314-43     123939-02     138088-01     142341-02     146335-01
 124189-03     124326-01     138097-02     142395-01     146674-01
 119539-19     124394-11     138182-01     142398-01     146955-03
 120100-08     124398-02     138194-04     142429-02     147228-01
 119547-08     124998-01     138246-01     142431-01     147379-01
 119649-03     125076-01
 Patches obsoleted by one or more patches already applied
 118778-14     124205-05     120413-11     124458-02     139621-01
 118844-20     122661-08     120415-27     124631-42     140160-03
 119118-52     119956-04     121309-20     126366-16     140456-01
 119247-36     120095-30     122471-03     138266-01     141533-04
 124629-12     119369-04     124187-07     138362-01     143734-01
 119253-32     120287-03     123631-03     138855-01     144326-01
 119279-39     120293-02     123006-07     138877-01     144487-05
 119316-19     120349-03     123896-22     139100-04     144557-03
 120200-15     120411-33
 Patches not applicable to packages on the system
 121182-05     125671-04     138825-12     143318-03     147694-17
 119549-14     137005-09     139292-02     143728-01     147695-17
 121212-02
 Patches canceled due to prepatch termination
 147993-05

Installation of patch set to alternate boot environment complete.

Please remember to activate boot environment SOL10-MARCH-2014    with    luactivate(1M)before rebooting.

Install log files written :
  /.alt.SOL10-MARCH-2014/var/sadm/install_data/s10x_rec_patchset_short_2014.03.06_21.25.52.log
  /.alt.SOL10-MARCH-2014/var/sadm/install_data/s10x_rec_patchset_verbose_2014.03.06_21.25.52.log
bash-3.2# 
Installation of patch set to alternate boot environment completed successfully, before rebooting just checking my current OS kernel patch level to compare after luactive / reboot.
bash-3.2# zoneadm list -cv
  ID NAME        STATUS     PATH             BRAND    IP    
   0 global      running    /                native   shared
   2 tpt02       running    /zonepool/tpt02  native   excl  
   3 tpt01       running    /zonepool/tpt01  native   shared
bash-3.2# uname -a
SunOS techpanel 5.10 Generic_147441-01 i86pc i386 i86pc
bash-3.2# zlogin tpt02 uname -a
SunOS tpt02 5.10 Generic_147441-01 i86pc i386 i86pc
bash-3.2# zlogin tpt02 uname -a1
SunOS tpt01 5.10 Generic_147441-01 i86pc i386 i86pc
bash-3.2# luactivate lustatus
Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
s10x_u10wos_17b            yes      yes    yes       no     -         
SOL10-MARCH-2014           yes      no     no        yes    -         
bash-3.2#
Activating ABE SOL10-MARCH-2014:
bash-3.2# luactivate SOL10-MARCH-2014
System has findroot enabled GRUB
Generating boot-sign, partition and slice information for PBE 
(s10x_u10wos_17b)Saving existing file (/etc/bootsign) in top level 
dataset for BE (s10x_u10wos_17b)as (mount-point)//etc/bootsign.prev.
A Live Upgrade Sync operation will be performed on startup of boot 
environment(SOL10-MARCH-2014).

Generating boot-sign for ABE (SOL10-MARCH-2014)
Saving existing file (/etc/bootsign) in top level dataset for BE (SOL10-MARCH-2014) as (mount-point)//etc/bootsign.prev.
Generating partition and slice information for ABE (SOL10-MARCH-2014)
Copied boot menu from top level dataset.
Generating multiboot menu entries for PBE.
Generating multiboot menu entries for ABE.
Disabling splashimage
Re-enabling splashimage
No more bootadm entries. Deletion of bootadm entries is complete.
GRUB menu default setting is unaffected
Done eliding bootadm entries.

**********************************************************************

The target boot environment has been activated. It will be used when you 
reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You 
MUST USE either the init or the shutdown command when you reboot. If you 
do not use either init or shutdown, the system will not boot using the 
target BE.

**********************************************************************

In case of a failure while booting to the target BE, the following 
process needs to be followed to fallback to the currently working 
boot environment:

1. Boot from the Solaris failsafe or boot in Single User mode from 
Solaris Install CD or Network.

2. Mount the Parent boot environment root slice to some directory 
(like /mnt). You can use the following commands in sequence to mount the BE:

     zpool import rpool
     zfs inherit -r mountpoint rpool/ROOT/s10x_u10wos_17b
     zfs set mountpoint=(mountpointName) rpool/ROOT/s10x_u10wos_17b 
     zfs mount rpool/ROOT/s10x_u10wos_17b

3. Run (luactivate) utility with out any arguments from the Parent boot  environment root slice, as shown below:

     (mountpointName)/sbin/luactivate

4. luactivate, activates the previous working boot environment and indicates the result.

5. Exit Single User mode and reboot the machine.

**********************************************************************

Modifying boot archive service
Propagating findroot GRUB for menu conversion.
File (/etc/lu/installgrub.findroot) propagation successful
File (/etc/lu/stage1.findroot) propagation successful
File (/etc/lu/stage2.findroot) propagation successful
File (/etc/lu/GRUB_capability) propagation successful
Deleting stale GRUB loader from all BEs.
File (/etc/lu/installgrub.latest) deletion successful
File (/etc/lu/stage1.latest) deletion successful
File (/etc/lu/stage2.latest) deletion successful
Activation of boot environment (SOL10-MARCH-2014) successful.
bash-3.2#
Check status again after activate (luactivate):
bash-3.2# lustatus
Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
s10x_u10wos_17b            yes      yes    no        no     -         
SOL10-MARCH-2014           yes      no     yes       no     -         
bash-3.2# 
Rebooting server to take effect ABE : Note - should not use reboot command instead we should use only "init 6" recommended command.
bash-3.2# init 6
propagating updated GRUB menu
Saving existing file in top level dataset for BE (SOL10-MARCH-2014) 
as (mount-point)//boot/grub/menu.lst.prev.
File (/mount-point)(/SOL10-MARCH-2014) propagation successful
File  propagation successful
File  propagation successful
File  propagation successful
bash-3.2#
Checking status after reboot - Now our kernel version got updated:
bash-3.2# lustatus
Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
s10x_u10wos_17b            yes      no     no        yes    -         
SOL10-MARCH-2014           yes      yes    yes       no     -         
bash-3.2# uname -a
SunOS techpanel 5.10 Generic_148889-01 i86pc i386 i86pc
bash-3.2# zlogin tpt01 uname -a
SunOS tpt01 5.10 Generic_148889-01 i86pc i386 i86pc
bash-3.2# zlogin tpt01 uname -a2
SunOS tpt02 5.10 Generic_148889-01 i86pc i386 i86pc
bash-3.2#
That's all , we have completed our task successfully. 

Thanks for reading this article...

Basic Solaris interview questions and answers for L1 level

Basically this article will help you to make confident in solaris basic level,which will help you in the L1 interview panel. Below I have given some of basic solaris interview question with answer,  these question generally will ask in L1 interview panel for solaris in all the IT company's. Some of the commands are common  for all the UNIX platform . Later I will update some more L1 questions .


1. List the files in current directory sorted by size ?
#ls -l | grep ^- | sort -nr 

2. List the hidden files in current directory ?
#ls -al | grep "^-."

3. Delete blank lines in a file ? 
#cat test | grep -v '^$' > test1

4. Search for a sample string in particular files ?
#grep .Debug. *.confHere grep uses the string .Debug. to search in all files with extension..conf. under current directory.

5. Display the last newly appending lines of a file during appendingdata to the same file by some processes ? 
#tail -f Debug.log Here tail shows the newly appended data into Debug.log by some processes/user.

6. Display the Disk Usage of file sizes under each directory in currentDirectory ?
#du -k * | sort -nr (or) du -k . | sort -nr

7. Change to a directory, which is having very long name ? 
#cd /opreat* Here original directory name is /opreation_application_sap.data....

8. Display the all files recursively with path under current directory ? 
#find . -depth -print

9. Set the Display automatically for the current new user ? 
#export DISPLAY=`eval 'who am i | cut -d"(" -f2 | cut -d")" -f1'` Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.

10. Display the processes, which are running under yourusername ?
#ps -aef | grep user1 Here user1 is the username.

11. List some Hot Keys for bash shell ?
Ctrl+l . Clears the Screen. Ctrl+r . Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a . Places cursor at the beginning of the command at shell. Ctrl+e . Places cursor at the end of the command at shell. Ctrl+d . Kills the shell. Ctrl+z . Places the currently running process into background.

12. Display the files in the directory by file size ?
#ls -ltr | sort -nrk 5

13. How to save man pages to a file ?
# man <command> | col .b > <output-file>Example :  man prstat | col -b > prstat_help.txt

14. How to know the date & time for . when script is executed ? 
Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, .timeinfo.inf. contains date & time details ie., when script is executed and history related to execution.

15. How do you find out drive statistics ? 
#iostat -E

16. Display disk usage in Kilobytes ?
#du -k

17. Display top ten largest files/directories ?
#du -sk * | sort -nr | head

18. How much space is used for users in kilobytes on ufs file system?
#quot -af

19. How to create null file ? 
#cat /dev/null > filename i.e cat /dev/null > messages.0

20. Show non-printing characters 
#cat -v -t -e [file]  i.e cat -v -t -e /etc/vfstab

21. Display the page size of memory ?
#pagesize -a

22. Display Ethernet Address arp table ?
#arp -a

23. Display the no of active established connections to localhost ? 
#netstat -a | grep EST

24. Display the state of interfaces used for TCP/IP traffice ? 
#netstat -i

25. Display the parent/child tree of a process ? 
#ptree <pid> Example: ptree 4563

26. Show the working directory of a process ?
#pwdx <pid> Example: pwdx 4571

27. Display the processes current open files ?
#pfiles <pid> Example: pfiles 6556

28. Display the inter-process communication facility status ? 
#ipcs

29. Display the top most process utilizing most CPU ?
#top -b 1

30. Alternative for top command ?
#prstat -a

31. To view the superfblocks available
#newfs -Nv /dev/rdsk/c0t0d0s2 

32. To view disk geometry and partitioning info
#prtvtoc /dev/rdsk/c0t0d0s2 

33. To copy partition table from one disk to another
#prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

34. To see all IP variables set in the kernel
#ndd /dev/ip \? 

35. To display the Number of lines in a file
#awk ' END {print NR}' /var/adm/messages.old

36. To list files by size
#ls -l | sort +4n 

37. File sizes of current directory
#ls -la | awk '{ print $5," ",$9 }' | sort -rn

38. Remount root to make it writeable
#mount -F ufs -o rw,remount / 

39. To compares files, and shows where they differ
#diff filename1 filename2

40. Tells you how many lines, words, and characters there are in a file
#wc filename

41. Processes that are running from /var
#fuser -uc /var

42. List the current swap devices
#swap -l

43. List the amount of swap space availabl
#swap -s

44. Check /etc/group file syntax
#/usr/sbin/grpck 

45. Check /etc/passwd file syntax
#/usr/sbin/pwck

46. Add a new user to the system
#/usr/sbin/useradd 

47. To see system configuration
#/usr/platform/`/bin/uname -i`/sbin/prtdiag -v
#/usr/sbin/prtconf -vp

48. To checkout if machine is in 32 or 64 bit mode
#isainfo -kv
#isainfo -bv

49. To see the reboot log
#last reboot

50. Display number of processors
#psrinfo | wc -l 

51. Report CPU Utilization
#sar -u 1 3

52. Displays system information
#uname -a 
#uname -X

53. Displays the date of the last system reboot
#who -b 

54. Displays summary of what the system is doing every 10 seconds
#vmstat 10

55. To determine what kind of memory demand was causing a system to page
#vmstat -p 

Monday, March 17, 2014

Basic Linux interview questions


Here some of the basic Linux interview question which will help us to pass L1 interview also will help to improve our basic skill in Linux.


1. How to know which ports are listening from your IP address?
# nmap -sT -O your-ip-address

2. How to grep an exact match?
# grep -w infrafile.txt

3. How to reverse grep matches?
# grep -v infrafile.txt

4. How to know which service name is what port?
Assuming port 443
# cat /etc/services | grep -w 443

5. How to get the first 10 lines of a file?
# head -10 infrafile.txt

6. How to get the last 10 lines of a file?
# tail -10 infrafile.txt

7. How to get the first column of a file?
# awk ‘{print $1}’ infrafile.txt

8. How to get the first and second columd of a file?
# awk ‘{print $1 ” ” $2}’ infrafile.txt

9. How to get the first column of a file having consistent field separator pattern?
Field separator character patterns is /
# awk -F/ ‘{print $1}’ infrafile.txt

10. How to get the second column of a file having consistent field separator pattern?
# awk -F/ ‘{print $2}’ infrafile.txt

11. How to show contents of a text file?
# cat infrafile.txt

12. How to show contents of text file pausing ever page or one screenful at a time?
# more infrafile.txt
# less infrafile.txt

13. What is the big difference between more and less?
less linux command has much more extensive enhancements compared with more.
You can also scroll up interactively via control keystrokes using less while the other one does not allow you to do that.
less does not need to read the entire file to buffer when showing a screenful content of a file and furthermorel less is faster than more on accessing big filesize.

14. How do you delete all numbers and digits from contents of a file?
# tr -d [:digit:] &lt; infrafile.txt

15. How do you sort contents of a text file in descending order?
# sort -r infrafile.txt

16. How do you create a file using touch (without opening it interactively for writing)?
# touch infrafile.txt

17. How do you change the date of all files in one folder?
# touch *

18. How do you create a file using tee?
# tee infrafile.txt
and start typing, press

19. How do you query currently installed package offline from your system?
# rpm -qa sendmail

20. How do you query packages for something-like package ?
# rpm -qa | grep sendmail
# rpm -qa *sendmail*

21. What files comes with a something package?
# rpm -qa postfix*
# rpm -ql postfix-2.4.3-2.fc7

22. What is this something package?
# rpm -qi postfix-2.4.3-2.fc7

23. Where does rpm stores its rpm database?
# cd /var/lib/rpm
# ls -la __*

24. How to mount CD drive after inserting the disk?
# mount /dev/cdrom /mnt/CD

25. How to know if fedora detects your Nokia N70 via USB?
# lsusb

26. How to change system date ?
# date -s “December 25 2007 01:01:01″

27. How to know your free base memory and other memory / swap statistics ?
# free

28. How to show disk space usage of your filesystem in human readable form?
# df -ah

29. How to get the top 10 of your mbox mail users?
# cd /var/spool/mail
# ls -lS | head -10

30. How to find process ID of a running service like httpd?
# pidof httpd

31. How to locate a binary file, command source and its man pages?
# whereis ping

32. How to find the location of a executable file that could have been executed when entered from a prompt?
# which ping

33. How to download ISO or any file from web using command line?
# wget -c www.google.com/infrafile.txt
# wget -c ftp://google.com/google.ISO

34. How to transfer file via ssh?
# scp -c infrafile.txt user@remote-hostname

35. How to transfer files that has been only changed from one host to another without taking comparison?
# rsync -avz remoteserver:/home/remotefolder /home/localfolder

36. How to transfer your identity.pub into a remote machine’s authorized_keys?
# ssh-copy-id -i identity-rsa-dsa.pub user@remote-hostname

37. How to know who you are in a shell?
# whoami

38. How to get more real-time view linux process stats and info?
# top

39. How to issue a continuous trace route to a host?
# mtr host-ip-addres

40. How to trace route without resolving IP address?
# mtr –no-dns hostname

41. What is another text-based alternative to chkconfig?
# ntsysv

42. How to list out current cron jobs?
# crontab -l

43. How to get the CPU time?
# clock

44. How to set date and time from NTP server?
# ntpdate 0.fedora.pool.ntp.org

45. How to show current system path?
# set | grep PATH

46. How to list out currently loaded kernel modules?
# lsmod

47. How to know the total days of your system without reboot?
# uptime

48. How to get a system bootstrapped from redhat network?
# /usr/bin/go-rhn.sh

49. How to see current running user jobs?
# jobs

50. How to edit text files from terminal?
# vi infrafile.txt
# nano infrafile.txt
# joe infrafile.txt
# vim infrafile.txt
# pico infrafile.txt (if pico is installed - Pico is a trademark of the University of Washington)
# tee vv

51. How to you change file ownership and chown files recursively?
# chown user:user folder -R

52. How to view queued mail in sendmail or postfix?
# mailq

53. How to show which alternative binary program does your machine executes first?
# alternatives –display program-name

54. How to create public/private rsa key pair?
# ssh-keygen

55. How to log out from your current shell ssh connection?
# Ctrl+D
If you are using sudo
# exit ; exit

56. How to load a particular kernel modules?
# modprobe modulename

57. How to remove a module from kernel?
# rmmod modulename

58. How to show all loaded kernel modules?
# lsmod

59. What is the configuration file and configuration directory for modprobe?
# cd modprobe.d
# cat /etc/modprobe.conf

60. How to check if cooling mode of your machine is active?
# cat /proc/acpi/thermal_zone/THRM/cooling_mode

61. How to show thermal temperature of a machine based from acpi?
# cat /proc/acpi/thermal_zone/THRM/temperature

62. Alternatively, how to view a JPG image from command line alternatively?
# jiv filename.jpg

63. How to sort a file in reverse mode?
# sort -r file.txt

64. How to close your current windows in one keystroke?
# Ctrl+F4

65. How to list out all detected HAL devices?
# lshal

66. How to extract files from Microsoft’s cabinet archives (.cab)?
# cabextract

67. How do to have two eyes following the mouse from screen?
# xeyes

68. How to lock your screen in Gnome using root?
# yum -y install xlockmore
# xlock -mode swarm -count 1

69. How to probe for the modules needed for your hardware monitoring chips to work?
# sensors-detect

70. How to basically build rpm binary package (.rpm) from spec file?
# rpmbuild –ba specfile
(make sure you have the complete build tools and tar ball package in place)

71. How to follow current growth of a log the same way like tail -f ?
# tailf /dir/log filename

72. How to tail 2 or more file in one shot in a single screen?
# yum -y install multitail
# multitail /var/log/file1 /var/log/file2 /var/log/file3

73. How to make a file immutable?
# chattr +i file1

74. How to suid root a file?
# chmod 4755 file

75. How to manage authentication, firewall, network configuration and system service in single screen interface?
# setup

76. How to check mail for your currently logged in user?
# mail

77. How to cut and paste inside a CLI terminal using the mouse without X?
# service gpm start

78. How to replace / delete a character from a string value?
# cat infrafile.txt
a
b
c
# tr ‘a’ ‘Z’ &lt; infrafile.txt
Z
b
c

70. How to create symbolic link of file named linkme?
cd to desired folder where to put the softlink file
# cd /var/www/html
# ln -s /home/myhome/linkme

80. How to create and update new system users in batch mode?
# newusers inputfile.txt
# cat inputfile.txt
user1:password1:1001:1001::/home/user1:/bin/false
user2:password2:1002:1002::/home/user2:/bin/bash
user3:password2:1003:1003::/home/user3:/sbin/nologin

81. How to show which system group a user belongs to?
# groups username

82. How to create a new group?
# groupadd newgroupname

83. How to delete an existing group?
# groupdel newgroupname
84. How to delete a user account including user’s home folder files and mail spool?
# userdel -r username

85. Alternatively, how to show currently logged in users?
# users

86. How to unmount CD drive?
# umount /dev/cdrom

87. How to add user account in one shot?
# useradd -d /home/user1 user1 -c “User1 User1″ -s /bin/false -G groupname -p cryptpassword

88. How to transfer file via ssh?
# scp -C file1 user@remote-host:user-folder-destination

89. How to transfer and syncronize files/folder between two machines?
# rync -avz files1 user@remote-host:user-folder-destination

90. How to add more system path to current PATH values?
# export PATH:$PATH:/your-new-path:/another-path

91. Alternatively, how to print current login name?
# logname

92. How to clear current terminal screen?
# clear
# Ctrl+L

93. How to go to the first character of a long command from CLI terminal?
# Ctrl+A

44. How to turn on all swap file specifed from /etc/fstab?
# swapon -a

95. How to pause between command execution?
Ex. 3 seconds
# sleep 3

96. How to show detailed Perl version?
# perl -V

97. How to show current spamassassin version?
# spamassassin -V

98. How to get the numeric identifier of current host?
# hostid
99. How to list file and directory contents in a tree-like format?
cd to desired folder
# tree
100. How to show quick history of commands by root?
# history