Tuesday, December 22, 2020

Very useful command related to network concept in aix?

 Very useful command related to network concept in aix? 


How to identify the default gateway in aix?
#netstat -nr|egrep -iw 'default|ug'
#lsconf|grep -i gateway

How to find out the MAC address of the network card in aix?
# netstat -ai

How to find out the netmask and other important details of the network card?
#lsdev -Cc adapter
#lsattr -El en0        (remember it is ent0, it is en0) (This will help when you are in a position to restore the network card when it crashed)


The above commands may be familiar to you. But I am sure, this will get you the exact/direct information you looking for when you are in sev-1 call/service recovery.


Friday, November 20, 2020

Raid concept - How to deal with RAID concepts in interview persective?

 Raid concept - How to deal with RAID concepts from an interview perspective?


RAID (Redundant Array of Independent Disks)

 

RAID 0 -  RAID 1 -  RAID 5 -  RAID 10

 

RAID 0 (Striping)

==============

Not fault tolerance

Data is striped across multiple disks

The data will be lost if one of the disk got corruped/destroyed.

 

RAID 1 (Mirroring and Duplexing)

============================

Fault tolerant

Data is copied on more than one disk

Each disk has the same data (data is safe)

 

RAID 5  (Striping with parity)

======================

Requires 3 or more disks

commonly used and It can store large amount of data and raid 5 is fast

Data is 'striped' across multiple disks along with parity (Parity is used to rebuild the data in the event of disk failure.)

 

RAID 10 (RAID 1+0)

==================

Combines Raid 1 and Raid 0

Need to use minimum of 4 disks

Two disks is mirrored using raid 1 setup (Both sets of 2 disks are striped using raid 0 setup)

Benefits from the fault tolerance of raid 1 and speed of raid 0

The disadvantage is - can only use 50% for data storage

 

(BTW, Fault tolerance refers to the ability of a system (computer, network, cloud cluster, etc.) to continue operating without interruption when one or more of its components fail.)

 


Tuesday, November 17, 2020

How to list out all the directories and sub-directories on the particular filesystem or directory in aix?

 How to view directories and sub-directories in aix?


Sometimes, you may in the situation to list out all the directories and sub-directories on the particular FS (or) directory in aix, Please use the below commands. It will list out all the directories and all the sub directories/files inside the directory/FS.

 

# ls -aeltFR



Thursday, August 27, 2020

How to restore a directory from mksysb backup in aix?

 How to restore a directory from mksysb backup in aix?



Using the below command, we can restore the directory from the mksysb backup whenever you required.

For example, if you want to restore the directory - /var/spool/mail from the mksysb. Please follow below.

Check if the target directory is existing on the mksysb:

testlpar:# restore -T -q -l -f /backup/testlpar.mksysb |grep "/var/spool/mail"

It will list out the detailed output and at the end, it will display the directory which we need to recover.

drwxrwxr-x  2 bin  mail  512  27 July 10:00 ./var/spool/mail


We can confirmed that the directory is available on the mksysb and we can try to restore it using /tmp/restore directory, then follow below.


Restore the particular directory (/var/spool/mail) using below
============================================

testlpar:# cd /tmp/restore

testlpar:# restore -xdvqf /backup/testlpar.backup ./var/spool/mail

Please note the (.) before the directory name

new volume on /backup/testlpar.mksysb :
Cluster size is 51200 bytes (100 blocks)
The volume number is 1.
The backup date is: Wed 26 July 00:05:15 2020
Files are backed by name
The user is root.

x 0./var/spool/mail
x 12586 ./var/spool/mail/root
x 485 ./var/spool/mail/wasadmin

The total size is 1684952 bytes.
The number of restored file is 2.
testlpar:# 
testlpar:# pwd
/tmp/restore/var/spool/mail
testlpar:# ls -ltr
total 2333
-rw-rw----   1 1001 mail 12586  17 may 2019 root
-rw-rw----   1 1001 mail 485      17 may 2019 wasadmin
testlpar:# 


Note: If you want to restore a single file from mksysb backup, please see the below link


Saturday, May 9, 2020

Facing issue while Restoring /image.data from mksysb image in aix?

Facing issue while Restoring /image.data from mksysb image in aix?


Facing issue while Restoring /image.data from mksysb image in aix

testnim# alt_disk_mksysb -m testserver.mksysb -d hdisk3
Restoring /image.data from mksysb image.
checking disk sizes
0505-111 alt_disk_install: There is not enough disk space on target
disks specified.
Total disk space required is 67072 megabytes and target
disk space is only 34175 megabytes.
testnim#

(or)

testnim# alt_disk_mksysb -m testserver.mksysb -d hdisk3
Restoring /image.data from mksysb image.
checking disk sizes
creating cloned rootvg volume group and associated logical volumes.
Creating logical volume alt_hd5
0516-404 allocp: This system cannot fulfill the allocatioin request.
          There are not enough free partitions or not enough physical volumes to keep restrictness and satisfy allocation requests.
          The command should be retried with different allocaiton characteristics.
0516-822 mklv: unable to create logical volume.
0505-115 alt_disk_install: mklv failed to create logical volume hd5
cleaning up.
testnim#

 Solution:

We will get the above error only if the rootvg was mirrored priror to taking the mksysb.

As long as your rootvg was mirrored you can break the mirror and retry the installation. You need to edit image.data so that you can use it to restore to a single disk.

we need to manually break the mirror in the mksysb with a custom image.data file.

#mkdir /export/idata
#cd /export/idata
#restore -xqvf /<path>/<mksysb_file_name> ./image.data
#vi /export/idata/image.data
 for each lv_data stanza.
   -Change the COPIES=2 to COPIES=1
   -Note the size of the LPs=XX value
   -change the PP=YY to match the Ps=XX value


Define a customized image_data resource:

#smitty nim_mkres
>>Resource Type: image_data
>>Resource Name: [nomirror_idata]
>>Resource Type: image_data
>>Server to Resource: [master]
>>Location of Resource: [/export/idata/image.data]

From the steps which you have you shoud go back and use the following migration command.

#nimadm -s <spot> -l <lpp_source> -i <image_data> -j <volume group for cache> -Y -T <old_mksysb_resource> -O <new_mksysb_resource_file_pathname> -N <new_mksysb_resource>


How to put log rotate in aix?


How to put log rotate in aix?


To rotate the file you should append 'rotate size <desired size> files <desired number of files> part to the above entry similar to the following entry in your /etc/syslog.conf

*.info;mark.none      /var/adm/syslog rotate size 32m files 8 compress

once done that please "refresh -s syslogd"

Output similar to below.

ls -l /var/adm/syslog*
-rw-rw-r--      1 adm adm     19718076 08 Apr 09.34      /var/adm/syslog
-rw-rw-r--      1 adm adm     2728076 07 Apr 09.34        /var/adm/syslog.0.Z
-rw-rw-r--      1 adm adm     2608076 07 Apr 09.34        /var/adm/syslog.1.Z
-rw-rw-r--      1 adm adm     2688076 07 Apr 09.34        /var/adm/syslog.2.Z
-rw-rw-r--      1 adm adm     2528076 06 Apr 09.34        /var/adm/syslog.3.Z
-rw-rw-r--      1 adm adm     2378076 06 Apr 09.34        /var/adm/syslog.4.Z
-rw-rw-r--      1 adm adm     2898076 06 Apr 09.34        /var/adm/syslog.5.Z
-rw-rw-r--      1 adm adm     2678076 06 Apr 09.34        /var/adm/syslog.6.Z
-rw-rw-r--      1 adm adm     2888076 06 Apr 09.34        /var/adm/syslog.7.Z



Wednesday, May 6, 2020

What is NPIV in aix?

What is NPIV in aix?


NPIV  (N_Port ID Virtualization)

The virtual fiber channel adapters support the use of N-Port ID Virtualization (NPIV)

With NPIV, the VIO's role is fundamentally different, The VIOs serving NPIV is a pass through, providing a Fiber channel protocol (FCP) connection from the client to the SAN.

The Virutal Fiber channel adapter capability allows client partitions to access SAN (Storage Area Network) devices using NPIV.  Each partition is identified by a unique WWPN.


Requirements:
============

Not all Fibre channel adapters and SAN Switches support NPIV. 

NPIV capable switches present the virtual WWPN to other SAN switches and devices as if they represent physical FC adapter endpoints.

VIO 2.1.0.10 and AIX oslevel 6.1.2 or 5.3.9
P6 processes based servers.
HMC 7.3.4

Commands
=========

To list the available NPIV capable ports -> #lsnports
To map a virutal FC server adapter to a port of physical hba  -> # vfcmap -vadapter vfchostX -fcp fcs0
To unmap a virutal FC server adapter -> # vfcmap -vadapter vfchostX - fcp
To identify the wwpn ->  # lscfg -vl fcsX
To identify the wwpn using hmc - >  # lshwres -m frame_name -r virtualio --rsubtype fc --level lpar
To View the fibre channel mapping -> # lsmap -all -npiv
To see the virtual FC adapters details  -> # lsdev -vpd|grep vfchost
To see the specific info about vfchostX -> # lsmap -npiv -vadapter vfchostX


Friday, April 24, 2020

how to enable the failed path in aix?

How to enable the failed path in aix?



The below script (For Loop) will be used to Enabled the failed disk path in aix. 
You no need to worry about the disk name/number and then fscsi/vscsi details. You can simply execute the below script and the script itself can able to fetch the failed disks and its fscsi/vscsi details on the server and then enabled it smoothly.


for s in `lspath|grep -i failed|awk '{print $2'}`
do
chpath -l $s -p `lspath -l $s|grep -i failed|awk '{print $3'}` -s Enabled
done

(or)

for s in `lspath|grep -i failed|awk '{print $2'}`; do chpath -l $s -p `lspath -l $s|grep -i failed|awk '{print $3'}` -s Enabled; done


Thursday, April 23, 2020

WPAR cheat sheet in iax

WPAR cheat sheet in aix?


Action
Commands
To list wpar
# lswpar  (and)    # lswpar <wpar_name>
To list the detailed info about wpar
# lswpar -L <wpar_name>
To read the network info of wpar from GE
# lswpar -d '|' -N <wpar_name>
To view inf oabout devices that are exported and allocated to vwpar
# lswpar -D <wpar_name>
to list the longs outpout of vwpar from GE
# lswpar -L
To list the exported disk details to vwpar from GE
# lswpar -L|grep -p "DEVICE EXPORTS"
To list the important info about vwpar
# lswpar -G
To list out the flag details for the vwpar In lswpar
# lswpar -a
To stop system wpar in same way that shutdown command
# stopwpar -F <wpar_name>
To reboot vwpa
# stopwpar -F -r <wpar_name>
To rebooot vwpar from vwpar itself
 # reboot
To remove wpar
# rmwpar <wpar_name>
To stop a wpar before removing it
# rmwpar -s <wpar_name>
To confirm whether we are in GE or vwpar
# uname -W   (Value is 0 means GE, numeric value means vwpar)
To view wpar identification and processor information
# lparstat -w
To display the UUID of a WPAR
# lswpar -a UUID <wpar_name>
To login to the vwpar
# clogin <wpar_name>
To log into a system WPAR for different user
# clogin <wpar_name> -l username
To take backup
# /opt/rbos/networker/bin/lbackup-ge -pre
To take savewpar backup of vwpar
# savewpar -f /vwp01/<wpar_name>/backup/<wpar_name>.vwbck -I -e -x <wpar_name>
To restore vwpar from backup
# restwpar -f 'backup/<wpar_name>.vwbck' '-s' '-A'
To list out the processes details consuming for vwpar
# ps -ef@ <wpar_name>
How to take alt_disk for GE in wpar
# alt_disk_copy -B -u -d hdiskX
How to create ISO image from backup
# mkcd -L -S -I /repos/savevg/lparname/iso -m /repos/savevg/lparname/<backup_name>
How to create a filesystem in wpar from GE
# crfs -v jfs2 -g testvg -u testwpar -A no -a size=10M -m /wpars/testwpar/datafs
How to create a shared FS which can e used by GE and wpar
# crfs -v namefs -d /myfs -m /wpars/mywpar/myfs -u mywpar 
How to list the FS information of wpars from GE
# lswpar  #lswpar -M <wpar-name>
what is the configuration file for the vwpar
/vwp01/<vwpar_name>/etc
what is the location for devmap
# ls -l /etc/wpars/devmap
How to create a wpar
#mkwpar -n testwpar -h testwpar -N interface=en0 address=<ip_addr> 
netmask=255.255.255.0 -r -R shares_CPU=10 CPU=6%-30%,45%
 shares_memory=20 memory=5%-10%,20% totalProcesses=128 totalThreads=512 -A -s



Monday, April 20, 2020

New lpp_source creation using the old lpp_source in aix?

New lpp_source creation using the old lpp_source in aix?


The below steps clearly explain, how to create a new lpp_source with the help of existing lpp_source.
Here, I am planning to create a lpp_source for AIX 71TL05SP02 using the old lpp_source AIX71 TL04SP05.


Download the AIX 7.1.5.2 patch files (*.bff) from aix fixcentral and keep it on our server.
===========================================================================================
cd /patching/aix7152    --> (Here we can keep the AIX 7.1.5.2 path files (.bff) format))
inutoc .
ls -l .toc

Create a separate filesytem for the lppsource
==============================================
mklv -y lpplv -t jfs2 migrationvg 120
crfs -v jfs2 -d lpplv -A yes -m /export/lpp_source/aix7152_lppsource -a logname=INLINE -a logsize=245
mount /export/lpp_source/aix7152_lppsource

 Copy all the files from the current lpp_source which is aix7145_lppsource to the new created FS
================================================================================================
cp -rp /export/lpp_source/aix7145_lppsource* /export/lpp_source/aix7152_lppsource
cd /export/lpp_source/aix7152_lppsource/installp/ppc
chown root:system *
chmod 644 *

Define the new lpp_source directory as an lpp_source resource
==============================================================
nim -o define -t lpp_source -a server=master -a location=/export/lpp_source/aix7152_lppsource aix7152_lppsource

 Upgrade the lpp_source using the patch directory as a source of patches
=======================================================================
nim -o update -a packages=all -a source=/patching/aix7152 aix7152_lppsource
cd /export/lpp_source/aix7152_lppsource/installp/ppc
chown root:system *
chmod 644 *

 Remove the duplicate software and any superseded updates from new lpp_source
=============================================================================
nim -o lppmgr -a lppmgr_flgs="-bu -x -r -e" aix7152_lppsource
lsnim -l aix7152_lppsource  (** check the "Rstate" equals "Ready for use" and "simages" equals "yes"**)


**NOW UPGRADE THE SERVER USING THE NEWLY CREATED LPP_SOURCE and MAKE SURE ALL THE FILESETS ARE IN CONSISTENT STATE**


 Create SPOT from LPP_SOURCE
===========================
 Define spot
============
nim -o define -t spot -a server=master -a locatioin=/export/spot --a source=aix7152_lppsource aix7152_spot
lsnim -l aix7152_spot

Check if bos.alt_disk_install.rte is in spot
===========================================
nim -o showres aix7152_spot|grep -i bos.alt_disk_install.rte

Execute only if bos.alt_disk_install.rte not in spot
=====================================================
nim -o cust -a lpp_source=aix7152_lppsource -a filesets=bos.alt_disk_install.rte aix7152_spot

Check bos.alt_disk_install.rte installed now in spot
=====================================================
nim -o showres aix7152_spot|grep -i bos.alt_disk_install.rte



Saturday, April 18, 2020

How to get the status and configuration details of the SEA in aix?

How to get the status and configuration details of the SEA in aix?


Using the following commands, we can easily identify the configuration details and status of the SEA (Shared Ethernet Adapter) in aix.

# lsdev -cadapter


# entstat -d ent20 |grep -i state
# entstat -d ent20 |grep -i priority
# entstat -d ent20 |grep -i vlan
# entstat -d ent20 |grep -i pvid
# entstat -d ent20 |grep -i real
# entstat -d ent20 |grep -i link
# entstat -d ent20 |grep -i media
# entstat -d ent20 |grep -i trunk
 (or)
entstat -d ent20|egrep -i 'state|priority|vlan|pvid|real|link|media|trunk'


To Set ha_mode to standby on primary vios:

# chdev -l entX -a ha_mode=standby    (or)     $ chdev -dev entX -attr ha_mode=standby


To Reset it back to auto and the SEA should failback to the primary vios

# chdev -l entX -a ha_mode=auto   (or)    $ chdev -dev entX -attr ha_mode=auto


How to take the backupios command in aix?

How to take the backupios command in aix?


/usr/ios/cli/ioscli mount nimserver:/export/mksysbs /mnt 

/usr/ios/cli/ioscli backupios -file /mnt/viosbackup -mksysb

If you want to redirect the output to a file you must use the "tee" command instead of the ">"

Example: 

/usr/ios/cli/ioscli backupios -file /mnt/viosbackup -mksysb | tee /home/padmin/backupiosissues.log

How to change the padmin passwor in vio?

How to change the padmin passwor in vio?


The bootable media should be as the same version and release as the system.

Welcome to the Base OS Menu
start maintenance mode from the system recovery (3rd option)
Access root volume group (1st option)
Select 0 to continue
Select the proper vios rootvg for the vio partition
Access this volume group and start a shell (1st option)

Now you will get the prompt
passwd: padmin
padmin new passwd:
enter the new passwd again:
sync;sync;sync;reboot

Note: The bootable media can be "bootable vios installation cd-rom / bootable vios install tape / non_autoinstall mksysb.

How to change the reserve_policy to no_reserve to the secondary vios?

How to change the reserve_policy to no_reserve to the secondary vios?


On Client:

unmount /fs
varyoff datavg
rmdev -l hdisk2  (We need to set the disk as defined state)


Target VIO server:

lsmap -vadapter vhostX
rmvdev -vtd <vtd_name>
lsdev -dev hdiskX -attr
chdev -dev hdiskX -attr reserve_policy=no_reserve
lsdev -dev hdiskX -attr   (Now the reserve policy set to no_reserve)
mkvdev -vdev hdiskX -vadapter vhostX -dev <vtd_name>

On client:

cfgmgr
lsdev -Cc disk   (hdiskX should back available)
varyonvg datavg
mount /fs

Thursday, April 9, 2020

How to create a lppsource and spot on the nim server in aix?

How to create a lppsource on the nim server in aix?


The below steps clearly explains you to create a lppsource (aix71_TL4SP2_lppsource ) on the nim server using the similiar lppsource (which is already created succesfully) from some other nim servers.
so what we can do is, we can copy the content of the lppsource from other nim server and paste it on our target servers' filesystem and then define it as a lppsource resource.


create a separate filesystem for the lppsource in our target server
=========================================================

# mklv -y lpplv -t jfs2 testvg 120
# crfs -v jfs2 -d lpplv -A yes -m /lpp_source/aix71_TL4SP2_lppsource -a logname=INLINE -a logsize=245
# mount /lppsource/aix71_TL4SP2_lppsource
# df -gt /lppsource/aix71_TL4SP2_lppsource


Mount the similar aix71_TL4SP2_lppsource from another NIM server (named testnim) to our target Nim server
=======================================================================================

# mount testnim:/lpp_source/aix71_TL4SP2_lppsource /mnt


Copy all the files from the mounted lpp_source into the newly created filesystem
==================================================================

# cp -rp /mnt/aix71_TL4SP2_lppsource/* /lpp_source/aix71_TL4SP2_lppsource
# cd /lpp_source/aix71_TL4SP2_lppsource/installp/ppc
# chown root:system *
# chmod 644 *


Define the new lpp_source directory as an LPP_SOURCE resource
=====================================================
# nim -o define -t lpp_source -a server=master -a locatioin=/lpp_source/aix71_TL4SP2_lppsource aix71_TL4SP2_lppsource

# lsnim -l aix71_TL4SP2_lppsource   (** check the "Rstate" equals "ready for use" and "simages" equals yes**)



CREATE SPOT FROM NEW LPP_SOURCE
================================
 Define SPOT
===========

# nim -o define -t spot -a server=master -a location=/export/spot -a source=aix71_TL4SP2_lppsource aix71_TL4SP2_spot

# lsnim -l aix71_TL4SP2_spot    -> make sure the spot resource has been created.

 
Check if bos.alt_disk_install.rte is in spot
=============================================
# nim -o showres aix71_TL04SP2_spot|grep -i bos.alt_disk_install.rte

 "Execute only if bos.alt_disk_install.rte not in spot"  
#nim -o cust -a lpp_source=aix71_TL4SP2_lppsource -a filesets=bos.alt_disk_install.rte aix71_TL4SP2_spot

# nim -o showres aix71_TL4SP2_spot|grep -i bos.alt_disk_install.rte
# lsnim -l aix71_TL4SP2_spot


Migration concepts - How to update the existing lpp source with any additional filesets from the ISO iamges / DVD media in aix?

Migration concepts - How to update the existing lpp source with any additional filesets from the  ISO images in aix?


Implementation steps:

First copy the AIX710402 base iso images files to the target nim server using SCP.

  AIX_7.1_Base_7100-04-02_DVD_1_of_2_17226.iso
  AIX_7.1_Base_7100-04-02_DVD_2_of_2_17226.iso


1. Mount the iso images:
  # loopmount -i AIX_7.1_Base_7100-04-02_DVD_1_of_2_17226.iso -o "-V cdrfs -o ro" -m /mnt

2. Update the existing lpp source with any additonal filesets from the dvd media:
  # nim -o update -a show_progress=yes -a packages=all -a source=/mnt aix71_TL04_lppsource
  # cd /export/lpp_source/aix71_TL04_lppsource/installp/ppc
  # chown root:system *
  # chmod 644 *

(or)

smitty nim - perform nim admin tasks - manage resources - perform operations on resoruce - select aix71_TL04_lppsource - select "update=add or remove software to or from an lpp_source" -  select "Add" and enter the software media  source  
(Target lpp_source=aix71_TL04_lppsource; sources of software to add=/mnt; software packages to add: all)


Note down the list of packages that are being added to the lpp_source. We need this list if we were to backout.

3. Repeat step 1 and 2 for the second DVD image

4. Remove any duplicate software and superseded updates.

   # nim -o lppmgr -a lppmgr_glags="-bu-x-r" aix71_TL04_lppsource

(or)

# smitty nim - perform nim admin tasks - manage resources - perform operations on resoruce - select aix71_TL04_lppsource - select "lppmgr=eliminate unnecessasry software in an lpp_source"
(target lpp_source=aix71_TL04_lppsource; preview only:no; Remove duplicate software:yes; Remove superseded software:yes; Remove language software:no; Preserve lang: [C];  Remove non-simage software: no; Save removed files: no; directory for storing save files[]; Extend filesystem if space needed: yes)

5. Check the source "Rstate" equals "Ready for use" and "simages" equals "yes"

   # lsnim -l aix71_TL04_lppsource.

6. Update the SPOT resource (To make sure SPOT is in right state, check the SPOT resource and if required update or recreate it)

   # nim -o check -a show_progress=yes aix71_TL04_spot  
   # nim -o lppchk -a show_progress=yes aix71_TL04_spot
   # nim -o cust -a lpp_source=aix71_TL04_lppsource aix71_TL04_spot

if any of the above operation fails or give errors, remove the SPOT resource and recreate it from the updated lpp_source.

   # nim -o remove aix71_TL04_spot
   # nim -o define -t spot -a show_progress=yes -a server=master -a location=/export/spot/aix71_TL04_spot -a installp_flags=aQg -a source=aix71_TL04_lppsource aix71_TL04_spot


7. Check the source "Rstate" equals "Ready for use" and correct OS levels are reported.

    #lsnim -l aix71_TL04_spot