Friday, 19 May 2017

Tar command examples

Create linux tar gz (Gzip) archive

#tar -czvf myarchive.tgz mydirectory/'
#tar -czvf myarchive.tgz myfile1 myfile2 mydir1

We use the -t option to create an linux tar archive
-c, –create create a new archive
Note that .tgz is the same thing as .tar.gz

Create linux simple tar archive (withouth compresion)

#tar -cvf myarchive.tar mydirectory/

Extracting linux tar archive:


Extract linux tar gz (Gzip) archive

#tar -xzvf mystuff.tgz

Extract linux simple tar archive

#tar -xvf mystuff.tar

We use -x to extract the files form the tar archive
-x, –extract, –get extract files from an archive
Extract linux tar archive to speciefied directorytar -xvzf filename.tar.gz -C /desired/path

And now let us shortly explain this command

Usage: tar [OPTION]… [FILE]…
Let us check the option used in this example
-c, –create                      create a new archive
-z, –gzip, –ungzip        filter the archive through gzip
-v, –verbose                   verbosely list files processed
-f, –file=ARCHIVE          use archive file or device ARCHIVE
-C directory file Performs a chdir  operation on directory and performs the c (create) or r (replace) operation on file .

In c and r mode, these changes the directory before adding the following files. In x mode, change directories after opening the archive but before extracting entries from the archive.
You can extract to a defined location using:
#tar xvf yourstuff.tar -C your/path/here
Testing / viewing your archive

#tar -tvf myarchive.tar
#tar -tzvf myarchive.tgz
Here we used the – t opton
-t, –list                           list the contents of an archive
————————————————-

TAIL command examples in UNIX / Linux

The tail command in unix or linux system is used to print the last N lines from the file on the terminal. Tail command is especially used with log files to read the last few lines to know about the error messages. The syntax of tail command is
tail [options] [files]
The tail command options are:
  • c : Prints the last N bytes of file; With leading +, prints the characters from the N byte in the file.
  • n : Prints last N lines; With leading + prints lines from the Nth line in the file.
  • f : Prints the appended lines on the terminal as the file grows.

Tail Command Examples

Create the following file in your linux or unix operating system for practising the examples:
# cat example.txt
virtual storage
oracle virtual instance
mysql backup
dedicated hosting server
cloud servers

1. Display last 10 lines

By default, the tail command prints the last 10 lines from the file.
# tail example.txt

2. Display last N lines

Use the -n option to print the last n lines from the file. The following example prints the last 2 lines from the file:
# tail -n2 example.txt
dedicated hosting server
cloud servers

3. Print lines from the Nth line

You can print lines starting from the Nth line in a file. The following example prints lines from the 2nd line.
# tail -n+2 example.txt
oracle virtual instance
mysql backup
dedicated hosting server
cloud servers

4. Print the last n bytes

use the -c option to print the last N bytes from the file. The following example prints the last 8 bytes from the file.
# tail -c8 example.txt
servers

5. Print characters from the Nth byte

Use the leading "+" with -c option to print the characters from the Nth byte. The following example prints the characters from the 79th byte.
# tail -c+79 example.txt
cloud servers

6. Print last lines from dynamically changing file

The -f option print the lines from file that is growing dynamically. When you run the tail -f filename command, it prints the last 10 lines and waits for new lines to be added to the file. Whenever the new lines are appended to the file, the tail command also appends the new lines on the standard output. The -f option is useful when debugging applications. In general, the applications writes error messages to log files. You can use the -f option to check for the error messages as and when they appear in the log file.
# tail -f logfile

System Hangs at c33 with an LFT - AIX

Question

System hangs at c33 with an LFT.

Answer

System Hangs at c33 with an LFT
c33 is configuring the console as a tty. Typically this occurs because the console is configured as a tty but has no tty. In this situation, when booting into service mode and executing an lscons, the console will show up as anlft. To verify that this is the case, enter smitty chcons. PATHNAME of console will be set to /dev/tty0. Change the pathname to /dev/lft0 and reboot your system.

System Dump [AIX]

  1. What is dump?
  2. Configuring dump devices in AIX
  3. How to start the system dump manually?
  4. Copying system dump to other directory or media
  5. Examining system dump using kdb
  6. Important LED codes related to dump

If a kernel panic occurs, a dump will be invoked automatically. The followings are dumped during the dump process.
  1. List of currently running processes and related information about the process
  2. Currently mounted filesystems, inode table and open file table
  3. currently configured ttys and their status
  4. Memory buffers for data
  5. system buffers
  6. system variables and statistics
  7. Kernel's own record of process it is currently running.

Configuring dump devices

sysdumpdev command is used to change the primary or secondary dump device designation in a running system.
 sysdumpdev 
           -l list the current dump destination
           -L view statistical information about previous dump
           -e estimate the dump size
           -d <directory> directory to copy the dump during boot time
           -p <device name>  to set the device as primary dump device
           -s <device name> to set the device as secondary dump device
           -P to make the changes permanent even after reboot
Examples:
To permanently make /dev/hd7 as the primary dump device
 # sysdumpdev -Pp /dev/hd7
To make /dev/sysdumpnull as the secondary dump device
 # sysdumpdev -s /dev/sysdumpnull
To estimate the dump size
 #susdumpdev -e

To start the dump manually

sysdumpstart command is used to start a kernel dump to the primary or secondary dump device. When the dump completes, the system halts. Use the kdb command to examine the dump.
 # sysdumpstart {-p | -s}

Copying system dump

If there is enough space to copy the dump to /var/adm/ras directory, then it will be copied directly during reboot. Dump is copied as /var/adm/ras/vmcore.x file. If there is not enough space, then "copydumpmenu" is run by /sbin/rc.boot to display the copy dump menu. Using this copydumpmenu utility, a dump can be copied to removable such as tape.

snap

 utility can be used to gather system information along with dump and compress the information in a tar file.
snap
    -a  gathers all system configuration information
    -c  creates compressed pax image (snap.pax.Z)
    -e  HACMP specific information
    -g  gathers general info
    -f  gathers filesystem info
    -k  gathers kernel info
    -d <directory> optional snap command output directory
       default directory is /tmp/ibmsupt
    -D  gathers dump and /unix
    -o <output_device>  copies the compressed image to tape or diskette

Example:

To send dump with other gathered information in to tape drive
 # snap -gfkD -o /dev/rmt0

  Examining system dump

kdb command is an interactive utility for examining an OS image or the running kernel.
 kdb <systemImageFile [Kernel File]]

LED Codes Related to dump

 0c0 - Dump completed successfully
 0c2 - Dump started
 0c4 - Dump unsuccessful. Not enough space on dump device
 0c5 - Dump failed to start
 0c9 - System initiated dump started

Syntax for /etc/inittab

This post will discuss about the syntax used in /etc/inittab.

Remember, run level for the system is always read from /etc/inittab
Syntax:
<ID>:<Run Level>:<Action>:<Command>
Run level is used for maintenance purpose.
In AIX, there are 10 run levels from 0 to 9.
0 and 1 is reserved run levels.
2 is default run level.
3 to 9 is user defined run level.

Eg:
Oracle:2/3/6/8:<once>/<wait>/<respawn>:startsrc –s oracle

Explanation:
Oracle is the ID,
2/3/6/8 is the run level for this particular process,
Once, wait, respawn is the action taken on this particular process
where
          once means the process will run and stop,
          wait means will wait for the process to complete (if error occurs will stop, system            needs to be rebooted then
          respawn means if the process does not exists, it will start it.
startsrc –s oracled is the command given to start the subsystem oracle daemon.

1. To modify records of the /etc/inittab file, commands used are:

mkitab : will add new record (entry) in /etc/inittab

2. To add an entry in /etc/inittab file,

# mkitab <rule>
For eg:
# mkitab “cdrom : 2 : respawn : startsrc –d cdromd”

3. To change an entry in /etc/inittab file,

chitab : will change the existing records in /etc/inittab
# chitab <rule>
For eg:
# chitab “cdrom : 3 : respawn : startsrc –s cdromd”
rmitab : will remove the records from /etc/inittab

4. To Remove an entry in /etc/inittab file,

# rmitab <rule>
For eg:
# rmitab “cdrom : 3 : respawn : startsrc –s cdromd”
lsitab : will list the records available in /etc/inittab

5. To list entries in /etc/inittab file,

# lsitab <rule>
For eg:
# lsitab “cdrom : 3 : respawn : startsrc –s cdromd”

6.Here’s a question, check whether the records listed by lsitab command is same as 

# cat /etc/inittab?
A:Yes

7. To identify current run level, command used is:

# cat /etc/init.state
OR
# who –r

Steps to Virtualize a VIO CD-ROM

Steps to Virtualize a VIO CD-ROM

1. Start on the profile for the VIO server that has the CD/DVD ROM on its bus.
2. Create a new SCSI virtual adapter.
3. On the "Add" screen, make it required for partition activation, make sure it's set for Any Partition, Note the virtual SCSI adapter ID, and hit OK
4. Deactivate and Reactivate the VIO server so that it reads the new profile.
5. Log into the VIO server as padmin
6. Issue the command "lsdev -type optical" to verify that the VIO server has an available CD rom
7. Issue the command "lsdev -type adapter" to identify the vhost number of the newly added vscsi adapter.
8. Issue the command "mkvdev -vdev cd0 -vadapter vhost#" where vhost# is the newly added vscsi adapter.
9. The command "lsmap -vadapter vhost#" should display the vhost and backing device information.
10. At this point, we're done on the VIO server.  Log out.
11. Open up a profile for one of the LPARs, go to Virtual Adapters, and Create a new SCSI adapter.
12. Make sure the Server partition is the VIO server and make sure the Server adapter ID matches what you've noted from step 3 (when you added the CD to the VIO server).
13. Perform steps 11 & 12 on any LPAR that you want to see the CD.
14. Deactivate and Reactivate the LPAR and it should see the CD.

To remove the CD from an LPAR to discover on another, perform these steps:

1. Log into the LPAR
2. Issue the command "lsdev -l cd0 -F parent".  This should identity the virtual scsi bus.
3. Issue the command "rmdev -dl vscsi# -R" to remove the bus and the CD.
4. Run "cfgmgr" on another LPAR to discover it (Assuming the virtual SCSI adapter for the CD has already been added and the LPAR reactivated)

Steps To Increase/Decrease A FS Size-AIX

A FS once created, can be increased (for jfs/jfs2) or decreased (for jfs2) as per the end user requirements by the administrator.

Increasing the FS will automatically increase the size of LV. Increase the size of LV will not increase the size of FS but will make provision for increasing the size of FS later when required.

Making size of the filesystem to exact size:
# chfs –a size =1G /ora
This command will  make the size of /ora FS  equal to 1 GB.

To raise the size by 1 GB will alter the above command as follows:
# chfs –a size =+1G  /ora
To verify the above command is executed properly or not:
# lsfs
# df –g

Steps involved to reduce/decrease the size of FS

Reduction of size is only possible for jfs2 types of FS. Reduction is not possible in jfs type of FS. Also, one of the limitations of a LVM is that reduction of size of LV is not possible. Refer:
Run the following command to reduce the size of FS:
# chfs –a size =512M /ora
OR
# chfs –a size =-512M /ora
Verify the same by:
# lsfs
OR
# df –m
chfs command is basically used when needs to increase the size of FS for end user as per the requirement.

Step-by-step guide to IBM Power Systems firmware update

Background

  • Hardware Management Console can be a desktop or a rack-mounted appliance that manages the servers, and is used for partitioning and as a service tool.
  • A managed system is a single physical server. It can have I/O expansion units, towers, drawers, and storage area network (SAN) resources.
  • HMC communicates to the managed system through the service processor.
  • The service processor is an embedded controller that monitors and controls the entire system and is running the bare metal Linux.
  • The IBM POWER Hypervisor™ is a layer of system firmware that supports virtualization technologies, logical partitioning (LPAR), and dynamic resource movement across multiple operating system environments.
Figure 1.

Introduction

The flexible service processor (FSP) firmware provides diagnostics, initialization, configuration, run-time error detection, and correction. It is required to periodically update the firmware on the Power Systems server. Keeping the firmware up-to-date can help in attaining the maximum reliability and functionality from your systems.
Firmware releases enable new function and might also contain fixes or enhancements.
Firmware service packs provide fixes and enhancements within a specific release.
This tutorial provides the following information:
  1. Current firmware details
  2. Different kinds of code download and update methods
  3. Steps to obtain the relevant firmware code updates or releases from the IBM FixCentral website
  4. Steps to update the firmware concurrently using DVD media, that is, the fixes that can be deployed on a running system without rebooting partitions or performing an initial program load (IPL) within a specific release
  5. Steps to update the firmware disruptively, that is, update requiring the system IPL within a specific release
  6. Advanced code update options from the Change Licensed Internal Code wizard
  7. Steps to upgrade to recent firmware releases disruptively using the File Transfer Protocol (FTP) method
  8. Steps to upgrade the firmware disruptively through the IBM Service website to a required level
In the following sections, let's go through in detail covering all the topics highlighted above.

Section 1. View system information

We will use the View system information option to get the current system firmware information.
We will be using this information in IBM Fix Central to obtain information on the latest firmware updates or upgrades available for the system and proceed with the firmware update or upgrade to newer release using the instructions described in the following sections.
Select the system under test, click Updates, and then click View system information to check the currently installed, activated, and accepted levels.
Figure 1.1



















The following figure shows the currently installed firmware levels on the system.
Figure 1.2












Fields in figure 1.2 are described below:
EC Number
This displays the numerical identifier of the engineering change (EC) that shows the system and GA level. It has the format ofPPNNSSS, where:
  • PP is the two-character package identifier.
  • NN is the two-character name that identifies a set of platforms. This is the model-unique code for the type of system.
  • SSS is the three-character service pack code stream identifier.
LIC Type
This displays the LIC types associated with the selected target.
Machine Type/Model/Serial Number
This displays the corresponding machine type, model number, and serial number.
Installed Level
This displays the LIC level that will be activated and loaded into memory at the next system restart.
Activated Level
This displays the LIC level that is activated and loaded into memory (for example, from a level 5 to level 7).
Accepted Level
This displays the LIC level that was committed. This refers to the updates selected on the system.
This is the backup level of code that you can return to, if necessary. Generally, this is the level of code on the permanent side (p-side).
Unactivated Deferred Level
This displays the latest or highest LIC level that contains unactivated deferred updates. This refers to the updates selected on the system.
A deferred update requires a system restart to activate.
Platform IPL Level
This displays the LIC level on which the hypervisor and partition firmware were last restarted. When concurrent LIC updates are performed, the activated level will change, but the platform IPL level will remain unchanged.
Update Control
This displays the current owner of LIC update control. It can be either HMC or operating system.

Section 2. Different kinds of “Code download and update” methods

Having known the current firmware levels on the system as described in Section 1 and in order to move up to the necessary latest update that is available, we have various firmware update and upgrade methods as mentioned below. Select the one that is appropriate to your requirement.
  • DVD method
    We can get the latest firmware code information from Fix Central. You need to download the code (as described inSection 3). You will be able to download the file in the ISO format. Then, you need to burn it to a DVD media to perform the update/upgrade using the obtained DVD (and this is described in Section 4).
    Section 4 describes the concurrent firmware update procedure. We can also use the DVD method to perform code upgrades (to a new release). This can be used when the HMC cannot access Internet due to firewall.
  • FTP method
    Download the required code levels using bulk FTP from Fix Central to a remote FTP-enabled system (also described inSection 3) Then, perform the code update/upgrade procedures using the FTP method, providing the login credentials and location of the update/upgrade code on your remote FTP-enabled repository system ( as described for firmware upgrade in Section 7.
    Section 7 describes the disruptive upgrade procedure using the FTP method. Similarly, the FTP procedure can also be used for concurrent code updates (within the same release).
  • IBM service website method We can perform the Power Systems firmware update/upgrade through the IBM service website to a required level (as described in Section 8).
    Section 8 describes the code upgrade procedure disruptively using the IBM website. A similar procedure can be used for performing concurrent code updates as well.
    After selecting the required system from the HMC, ensure to select Change Licensed Internal Code in order to perform code updates (any updates within the same release) and select Upgrade Licensed Internal Code in order to perform code upgrades (by installing the different release).

Section 3. Power Systems firmware code location and download from Fix Central

Power Systems firmware fix packs or firmware releases can be obtained from the IBM Fix Central website.
Select the following categories for Power Systems firmware update and choose the appropriate machine type and model of your system to be updated.
As per the example shown in Figure 3.0, the machine type and model used is: 8203-E4A. Select the appropriate machine type of your choice and continue.
Figure 3.0
























Example in Figure 3.1 shown below is for the system firmware only. Similarly, you can explore other options too.
Figure 3.1


















If users are aware of the specific firmware level, then users can select the necessary option directly. If not, users can also take help from the recommendations that the website can provide about the latest and the best-suited firmware levels. If you need help, select the I need guidance. I am not sure what level of firmware is recommended option as shown in Figure 3.2.
Choose the specific level or get the recommended level as shown below:
Figure 3.2



















Figure 3.3
















Decide whether your system needs firmware update to the latest fix pack or upgrade to a new release based on the current levels installed on the system as obtained from View system information in the above section.
Figure 3.4



















Figure 3.5
























As an example, let us continue to get the firmware service pack within the current release, as shown in Figure 3.6.
Figure 3.6



















Figure 3.7























Similarly, users can get the upgrade code, that is, newer release using the second option. Note that this will be a disruptive code install, that is, system power recycles.
Note:
Download the update code, if you are planning an update within the current release.
Download the upgrade code if you are planning for an upgrade to a newer release itself.
Figure 3.7 lists the latest, recommended, and available updates to your current release. Select the appropriate option and proceed further.
Continue with downloading the ISO file if you want burn it to a DVD to proceed with the firmware update using the DVD media, orget the code to a remote FTP-enabled system to perform update using the FTP method. The firmware update procedure is explained in detail in the following sections.
Figure 3.8












Figure 3.9




















Figure 3.10











Section 4. Power Systems firmware concurrent update procedure using the DVD method

You can update the firmware concurrently (that is, the fixes that can be deployed on a running system without rebooting partitions or performing an IPL) within a specific release. Select the Change Licensed Internal Code option for the current release.
Figure 4.0









Figure 4.1














In the Specify LIC Repository section (as shown in Figure 4.2), select the location of the LIC update repository.
Figure 4.2












Figure 4.3





elect the DVD-RAM drive option,where you have the DVD placed and proceed with code update concurrently, as shown in Figure 4.3.
Note: Place the DVD in the HMC's DVD drive (and not in the system's DVD drive).
Figure 4.4












Click OK to proceed further to the subsequent steps to perform code update. It verifies whether the system is ready for code update by performing the health check and if everything fine, we can proceed further.
The following screen captures show the step-by-step procedure to perform concurrent code update.
Figure 4.5










Figure 4.6












Figure 4.7






















Figure 4.8


















Figure 4.9













Figure 4.10







Section 5. Steps to update the firmware disruptively (that is, update requiring the system IPL within a specific release)

Firmware updates are usually concurrent. Disruptive update service packs are very rare. The procedure to perform disruptive update is quite similar to concurrent update (explained in Section 4) but this process will prompt for system power cycle during the operation.

Section 6. Advanced code update options from Change Licensed Internal Code wizard

We use the Select advanced features option to perform advanced operations, such as Remove and activate and Reject fix.
Remove and activate option
The Remove and activate option brings the system back to the update level that is on the permanent side. You can use this option to back off an update level.
Figure 6.0











Figure 6.1













Figure 6.2










Figure 6.3











Click OK and then Close to remove and activate the permanent side update level.
Figure 6.4










Reject Fix operation:
Boot the system in the Permanent Side mode (from ASMI -> Power/Restart Control -> Power On/Off System, and make sure that the Current firmware boot side option is displayed as Permanent) and only then the Reject Fix option gets enabled and the operation can be performed. This operation copies the currently running level (permanent side) to the temporary side. This can be used to reject a fix that has been applied.
Figure 6.5













Figure 6.6












Figure 6.7










Click OK to start this operation.

Section 7. Upgrade to newer firmware releases disruptively using the FTP method

Installing a release or a disruptive fix pack causes system IPL. All release upgrades are disruptive.
We can obtain the upgrade code, that is, the disruptive fix pack from Fix Central and burn it to a media drive and proceed with the upgrade process, which is quite similar to the concurrent update process explained in the earlier sections (except that this operation is disruptive).
In this section, let us learn how to use the FTP method to upgrade the system using the firmware code stored in a remote repository.
The following screen captures shows the steps to upgrade to newer firmware releases disruptively using the FTP method.
Figure 7.0








Figure 7.1












Figure 7.2













Figure 7.3













Figure 7.4












Figure 7.5




Figure 7.6















Figure 7.7
























Figure 7.8




Clicking OK starts the disruptive upgrade. System will be on the applied release level after the upgrade operation completes.

Section 8. Steps to upgrade the firmware disruptively using the IBM service website to the required level

After logging in to the HMC, click System Management > Servers > Target Server on the left pane. Instead, you can also click the Updates icon on the same pane. All the available servers will be displayed in the right pane. In the following figure, the red highlight in the right pane shows the current level installed.
Figure 8.0






  





Make sure that your target server is in the shutdown mode, and if not, switch off the server.
Now, click the Upgrade Licensed Internal Code to a new release link at the bottom of the page as shown in the following figure.
Figure 8.1













After clicking the link, you will be directed to the web page which will show information about the readiness check. If there is no errors found, you can click OK and proceed further, as shown in the following figure.
Figure 8.2










After clicking OK, you will be directed to the Specify LIC Repository page. Here, you need to select the location of the code. The options shown in the following figure are available.
Figure 8.3














If you are setting a new server configuration, the best practice at this prompt is always to select the IBM service web site option and you need not worry about the need to power off and power on the managed systems in this method.
After selecting the IBM Service web site option, you will have a new web page opened, which will show you the available LIC level details. Here, the best practice is to select the latest available code (that is, the latest available version). Most of the fixes are added by IBM and your Power Systems server will be upgraded to the latest level. Then, select the best as per your requirement, or the latest supported.
Be patient here and follow the prompts to complete the upgrade. The firmware upgrade activity will need time depending on your Internet bandwidth speed. Do not forget to switch on the server, so that the latest firmware gets activated and reflected in the navigation pane, as shown in the following figure.
Figure 8.4










Now you are done with the upgrade. Remember if you select multiple systems, you can upgrade them as well.

Resources