Sunday, February 3, 2019

15 EMC PowerPath Powermt Command Examples

15 EMC PowerPath Powermt Command Examples – Display, Check, Remove, Config, Restore


If your server has two HBA cards connected to EMC SAN storage device, you can implement load-balancing, and fail-over on the HBA cards using the EMC PowerPath software.
Powermt management utility helps you manage I/O paths from the server to the EMC storage device. In this article, let us discuss how to use powermt command with practical examples.

1. powermt display – Display High Level HBA I/O Paths

powermt display command (without any arguments), displays the available HBAs and their current status. The following examples, shows that there are 2 HBAs connected to the server, both the HBAs are in active condition with 2 I/O path’s each. qla2xxx indicates that it is using the Q-Logic HBA card.
This also indicates that the connected EMC device is CLARiiON, as it displays a value for “CLARiiON logical device count” as 1.
# powermt display
Symmetrix logical device count=0
CLARiiON logical device count=1
Hitachi logical device count=0
Invista logical device count=0
HP xp logical device count=0
Ess logical device count=0
HP HSx logical device count=0
==============================================================================
----- Host Bus Adapters ---------  ------ I/O Paths -----  ------ Stats ------
###  HW Path                       Summary   Total   Dead  IO/Sec Q-IOs Errors
==============================================================================
   1 qla2xxx                       optimal       2      0       -     0      0
   2 qla2xxx                       optimal       2      0       -     0      0

2. powermt display dev=all – Display All Attached LUNs

This is the most frequently used powermt command, which will display all the attached logical devices to the server.
# powermt display dev=all
Pseudo name=emcpowera
CLARiiON ID=AAA00000000000 [dev-server]
Logical device ID=1111111111111111111 [LUN 1]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP B, current=SP B       Array failover mode: 1
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdd       SP A4     active  alive      0      0
   1 qla2xxx                   sde       SP B4     active  alive      0      0
   2 qla2xxx                   sdf       SP A5     active  alive      0      0
   2 qla2xxx                   sdg       SP B5     active  alive      0      0
Pseudo name=emcpowerb
CLARiiON ID=AAA00000000000 [dev-server]
Logical device ID=2111111111111111111 [LUN 2]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP A, current=SP A       Array failover mode: 1
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdh       SP A4     active  alive      0      0
   1 qla2xxx                   sdi       SP B4     active  alive      0      0
   2 qla2xxx                   sdj       SP A5     active  alive      0      0
   2 qla2xxx                   sdk       SP B5     active  alive      0      0
The above indicates that there are two LUNs attached to the dev-server with 4 I/O paths from the server to the SAN storage device.
The above command output indicates the following:
  • Pseudo name=emcpowera – The device name that can be used by the server. For example, /dev/emcpowera.
  • CLARiiON ID=AAA00000000000 [dev-server] – EMC CLARiiON CX3 serial number and the server name.
  • Logical device ID=11111111 [LUN 1] – LUN number. For example, LUN 1.
  • state=alive; policy=CLAROpt; – This displays that this particular LUN is valid and using the CLAROpt policy.
  • Owner: default=SP B, current=SP B – This indicates that the default (and current) owner for this LUN is storage processor SP B.

3. powermt display dev=emcpowera – Display specific LUN

When there are multiple LUNs connected to a server, you might want to view information about a specific LUN by providing the logical name of the LUN as shown below.
# powermt display dev=emcpowera
Pseudo name=emcpowera
CLARiiON ID=AAA00000000000 [dev-server]
Logical device ID=1111111111111111111 [LUN 1]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP B, current=SP B       Array failover mode: 1
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdd       SP A4     active  alive      0      0
   1 qla2xxx                   sde       SP B4     active  alive      0      0
   2 qla2xxx                   sdf       SP A5     active  alive      0      0
   2 qla2xxx                   sdg       SP B5     active  alive      0      0
If the device is not available, you’ll get a “Bad dev value” as shown below.
# powermt display dev=emcpowerc
Bad dev value emcpowerc, or not under Powerpath control.

4. powermt check_registration – Display PowerPath Registration Key / Status

If you’ve lost the PowerPath registration key that you’ve used during the EMC PowerPath installation, you can retrieve it using the following command.
# powermt check_registration
Key AAAA-BBBB-CCCC-DDDD-EEEE-FFFF
  Product: PowerPath
  Capabilities: All

5. powermt display options – Display EMC PowerPath Options

Displays the high level EMC SAN array options as shown below.
# powermt display options
        Default storage system class: all
        Show CLARiiON LUN names:      true
        Path Latency Monitor: Off
        Path Latency Threshold: 0 Sec.
        Storage
        System Class  Attributes
        ------------  ----------
        Symmetrix     periodic autorestore = on
                      status = managed
        CLARiiON      periodic autorestore = on
                      status = managed
        Hitachi       periodic autorestore = on
                      status = managed
        Invista       periodic autorestore = on
                      status = managed
        HP xp         periodic autorestore = on
                      status = managed
        Ess           periodic autorestore = on
                      status = managed
        HP HSx        periodic autorestore = on
                      status = managed

6. powermt display hba_mode – Display PowerPath HBA Mode

This is similar to #1, but displays whether hba is enabled or not, as shown in the last column of the output.
# powermt display hba_mode
Symmetrix logical device count=0
CLARiiON logical device count=1
Hitachi logical device count=0
Invista logical device count=0
HP xp logical device count=0
Ess logical device count=0
HP HSx logical device count=0
==============================================================================
----- Host Bus Adapters ---------  ------ I/O Paths -----  Stats
###  HW Path                       Summary   Total   Dead  Q-IOs Mode
==============================================================================
   1 qla2xxx                       optimal       2      0     0 Enabled
   2 qla2xxx                       optimal       2      0     0 Enabled

7. powermt display path – Display available I/O Paths.

This displays all available path for your SAN device.
# powermt display paths
Symmetrix logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
CLARiiON logical device count=1
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
   1 qla2xxx                      AAA00000000000      SP A4          1       0
   1 qla2xxx                      AAA00000000000      SP B4          1       0
   2 qla2xxx                      AAA00000000000      SP A5          1       0
   2 qla2xxx                      AAA00000000000      SP B5          1       0
Hitachi logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
Invista logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
HP xp logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
Ess logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================
HP HSx logical device count=0
==============================================================================
----- Host Bus Adapters --------- ------ Storage System -----    - I/O Paths -
###  HW Path                           ID          Interface     Total    Dead
==============================================================================

8. powermt displays port_mode – Display Port Status

Displays the status of the individual ports on the HBA. i.e Whether the port is enabled or not.
# powermt display port_mode
Storage class = Symmetrix
==============================================================================
----------- Storage System ---------------     -- I/O Paths --   --- Stats ---
    ID              Interface         Wt_Q      Total    Dead    Q-IOs  Mode
==============================================================================
Storage class = CLARiiON
==============================================================================
----------- Storage System ---------------     -- I/O Paths --   --- Stats ---
    ID              Interface         Wt_Q      Total    Dead    Q-IOs  Mode
==============================================================================
    AAA00000000000     SP A4           256          1       0        0  Enabled
    AAA00000000000     SP B4           256          1       0        0  Enabled
    AAA00000000000     SP A5           256          1       0        0  Enabled
    AAA00000000000     SP B5           256          1       0        0  Enabled

9. powermt version – Display EMC PowerPath Version

How to identify the version number of EMC PowerPath software?
# powermt version
EMC powermt for PowerPath (c) Version 5.3 (build 185)

10. powermt check – Check the I/O Paths

If you have made changes to the HBA’s, or I/O paths, just execute powermt check, to take appropriate action. For example, if you have manually removed an I/O path, check command will detect a dead path and remove it from the EMC path list.
# powermt check
 Warning: storage_system I/O path path_name is dead.
       Do you want to remove it (y/n/a/q)?
Note: If you want powermt to automatically remove all dead paths, without any confirmation, execute “powermt check force”.

11. powermt set mode hba – Forcefully set the mode for a specific HBA

You can change the mode of a specific HBA to either standby or active using this command. Following example, changes HBA #1’s mode from active to standby.
# powermt set mode=standby hba=1
After the above command, you can see the mode for HBA#1 changed to standby, as shown below.
# powermt display dev=all
Pseudo name=emcpowera
CLARiiON ID=AAA00000000000 [dev-server]
Logical device ID=1111111111111111111 [LUN 1]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP B, current=SP B       Array failover mode: 1
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdd       SP A4     standby alive      0      0
   1 qla2xxx                   sde       SP B4     standby alive      0      0
   2 qla2xxx                   sdf       SP A5     active  alive      0      0
   2 qla2xxx                   sdg       SP B5     active  alive      0      0
Note: Path mode can also be “unlic” indicating that you’ve not registered the PowerPath with proper License key.
Note: Some powermt commands (for example, powermt set port_disable), is restricted to certain platform and storage type — On AIX and Solaris, only Fibre channel is supported. On HP-UX, only iSCSI and Fibre are supported. On Linux, Only iSCSI (HBAs) and Fibre are supported.

12. powermt remove – Delete an I/O Path

Use this command to remove any specific I/O path (or) a whole device.
The following example has 4 I/O Paths.
# powermt display dev=all
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdd       SP A4     standby alive      0      0
   1 qla2xxx                   sde       SP B4     standby alive      0      0
   2 qla2xxx                   sdf       SP A5     active  alive      0      0
   2 qla2xxx                   sdg       SP B5     active  alive      0      0
To remove I/O Path sdd, execute the following powermt remove command.
# powermt remove dev=sdd

# powermt display dev=all
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sde       SP B4     standby alive      0      0
   2 qla2xxx                   sdf       SP A5     active  alive      0      0
   2 qla2xxx                   sdg       SP B5     active  alive      0      0
Following will remove all I/O Path for a particular device. i.e To remove /dev/emcpowera, do the following. If the /dev/emcpowera is mounted and used by some program, following command will not work.
# powermt remove dev=emcpowera

13. powermt config – Configure PowerPath

This command checks for available EMC SAN logical devices and add those to PowerPath configuration list. Powermt config command, sets some of the options to it’s default values. For example, write throttling = off, HBA mode = active, CLARiiON policy = CLAROpt, etc.
Possible EMC SAN LUN policy values are: Adaptive, BasicFailover, CLAROpt, LeastBlocks, LeastIos, NoRedirect, Request, RoundRobin, StreamIO, or SymmOpt.
After you execute the powermt config, if you don’t like any of the default values, you should change it accordingly.
# powermt config

14. powermt restore – Make Dead I/O Path Alive

If you have dead I/O paths, and if you’ve done something to fix the issue, you can request PowerPath to re-check the paths and mark it as active using powermt restore command.
When you execute powermt restore, it does an I/O path check. If a previously dead path is alive, it will be marked as alive, and if a previously alive path is dead, it will be marked as dead.
For some reason, if you see the default owner and the current owner of a particular LUN is not the same storage processor, then execute the following command, which will make the current owner of the LUN same as the default owner.
# powermt restore dev=all
Instead of dev, you can also specify class in the powermt restore command. Class can be one of the following depending on your system.
  • symm – Symmetrix
  • clariion –  CLARiiON
  • invista – Invista
  • ess – IBM ESS
  • hitachi – Hitachi Lightning TagmaStore
  • hpxp –  HP StorageWorks XP, or EVA series
  • hphsx – HP StorageWorks EMA, or MA
  • all – All systems

15. Powermt Save and Load – Save and Restore PowerPath Configurations

powermt save – Save the current Powerpath Configuration

If you are changing the PowerPath configurations for testing purpose, you can save the current configuration using powermt save command.
Use this method to backup the current PowerPath Configurations.
# powermt save
This will save the current powermt configuration to /etc/powermt.custom file. Following is the partial content of this file.
# cat /etc/powermt.custom
global:version:5.3.0.0.0:4.1.0
path_c:sdd:sdd:qla2xxx:0x111
path_c:sde:sde:qla2xxx:0x111
adapter:  1:  1:qla2xxx:0x111:1:0:111:0:11:0
adapter:  2:  2:qla2xxx:0x111:1:0:111:0:111:0
arrPort_c:04000000:04000000:111:111
mpext_cfg:unused:Mp:0:symm:0:0
...
...
If you want to store the current PowePath configuration to a different file, do the following.
# powermt save file=/etc/powermt.21-Aug-2010

powermt load – Load a previously saved EMC PowerPath Configuration

When you are testing EMC PowerPath configuration, if you are not satisfied with the new configuration, you can go back to the previous configuration.
For example, to restore the configuration to a specific file that you created in the above powermt save example, do the following.
# powermt load file=/etc/powermt.21-Aug-2010

To remove a LUN and all associated PowerPath

To remove a LUN and all associated PowerPath and Linux devices from the host environment follow these steps. 

Note: that it is critical to follow the procedures in exact order because deviating from the procedures can cause the host to panic

These steps were put together using steps from QLogic KB articles.

1. Stop any I/O to the device being removed. [Unmount the filesystem ] It is critical to stop all I/O on the device that is being removed.

2. Run the following command to determine which native SCSI devices are mapped to the pseudo device:

powermt display dev=all

Find the name of the LUN to be removed and match it up with the emcpower device name. This will need to be done on each server individually.

3. Run the command:

powermt remove dev=emcpower

Where corresponds to the LUN to be removed.

4. Run the command:

powermt release

Failing to run this command results in the pseudo device still being visible in /dev and /sys/block and may lead to some complications when the new devices are dynamically added.

5. In the /tmp/ql_utils directory, there should be a script to rescan the qlogic hbas. The script is called ql-dynamic-tgt-lun-disc.sh. Run the script:

/tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh

6. You will now remove the device from the storage array using your array admin utilities. On the Linux server, run powermt display to verify that the device has been removed.

7. Now remove the LUN from the Storage Group (CLARiiON) or unmap it from the FA ports (DMX).

Saturday, February 2, 2019

How to fix (fsck) a root file system that you have to boot into on Linux

How to fix (fsck) a root file system that you have to boot into on Linux

Two days ago I corrupted my file system during a failed resume from standby on Fedora 19. This feature has never quite worked correctly and randomly makes the kernel panic. Usually, I hard reboot my laptop and everything is fine but that time, something went wrong and when it came back up:
systemd-fsck[605]: /dev/sda2: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
systemd-fsck[605]: (i.e., without -a or -p options)
[ 13.652068] systemd-fsck[605]: fsck failed with error code 4.
Welcome to emergency mode. Use "systemctl default" or ^D to activate default
mode.
Give root password for maintenance
(or type Control-D to continue):
In this case /dev/sda2 is my root partition and since it was mounted even in maintenance mode, attempting to run fsck on it would output:
fsck.ext4 /dev/sda2
e2fsck 1.42.7 (21-Jan-2013)
/dev/sda2 is mounted.
e2fsck: Cannot continue, aborting.
Which makes sense as common knowledge tells us that running fsckon a mounted file system will most likely do more damage to it.

The best option

Your best option is simply to boot into another Linux, be it on a different partition, a USB drive or a CD and run fsck manually on the faulty partition, which can easily be unmounted if necessary because no OS is using it. Easy. Normally yes, but my stupid Macbook Pro 2008 cannot boot though USB into anything else other than Mac OS X, my cd drive has been dead for years and recently, I got rid of my OS X partition. To make things more complicated, I’m in Thailand at the moment and obviously not able to take apart my computer to grab the hard drive and stick into a working system.

The other option (if you cannot boot into another Linux)

In order to assess the damage, I ran fsck in dry-run mode and piped the output to more to make reading more practical:
fsck.ext4 -n /dev/sda2 | more
From there, I could ensure that no critical files had been damaged and while keeping in mind that it’s always a gamble to use a corrupted file system, I proceeded to boot into the system to make some backups. That out of the way, I did some research on the web on how to fix a root file system that I had to boot into and sadly, not many things turned up for its not an ideal solution. Forcing the system to do it a boot time by creating a file named forcefsck and writing y in it (echo y > /forcefsck) at root no longer works and adding fsck.mode=force on the kernel command line did not fix the problem as fsck will not fix errors on its own without authorization, ie: someone to enter yes on the keyboard. Tried a few other tricks but none worked. I had no choice but keep my fingers crossed and use the system as is.
A few days later, I decided to get back to the issue and while researching alternative solutions, I read that it was possible to fix errors on a read-only file system, which it turns out can also be used to boot into. And it worked, so for posterity here is the technique:
  1. Put your root partition into read-only mode by modifying the faulty partition’s line on /etc/fstab (but remember your old settings):
    UUID=fd1d0fad-3a4c-457f-9b5e-eed021cce3d1 /                       ext4    remount,ro        1 1
    Note: If you’re already in maintenance mode at this point, you may be able to remount your file system in read only mode by running “mount -o remount,ro /” and skipping the reboot (thanks Jay).
  2. Reboot
  3. Switch to runlevel 1 just to minimize the amount of interfering processes (skip this step if you are running the session over SSH [thanks Josh]):
    init 1
  4. Fix your file system (replace /dev/sda2 with your partition’s device), which should now work because the root partition is in read only:
    fsck /dev/sda2
  5. Reboot
  6. Make your root file system readable/writable:
    mount -o remount,rw /dev/sda2
  7. Restore your /etc/fstab to its original state.
  8. Reboot
Voilà, your system is safe to use again. Hopefully this will have gotten you out of a sticky situation like it did for me. If errors keep coming up, it’s probably a sign that your hard-drive is failing and before you loose it completely, you should mirror your data to a new one.

Linux Fsck Command Examples to Check and Repair Filesystem

Linux Fsck Command Examples to Check and Repair Filesystem

Linux fsck utility is used to check and repair Linux filesystems (ext2, ext3, ext4, etc.).
Depending on when was the last time a file system was checked, the system runs the fsck during boot time to check whether the filesystem is in consistent state. System administrator could also run it manually when there is a problem with the filesystems.
Make sure to execute the fsck on an unmounted file systems to avoid any data corruption issues.

This article explains 10 practical examples on how to execute fsck command to troubleshoot and fix any filesystem errors.

  • -A – Used for checking all filesystems. The list is taken from /etc/fstab.
  • -C – Show progress bar.
  • -l – Locks the device to guarantee no other program will try to use the partition during the check.
  • -M – Do not check mounted filesystems.
  • -N – Only show what would be done – no actual changes are made.
  • -P – If you want to check filesystems in parallel, including root.
  • -R – Do not check root filesystem. This is useful only with ‘-A‘.
  • -r – Provide statistics for each device that is being checked.
  • -T – Does not show the title.
  • -t – Exclusively specify the filesystem types to be checked. Types can be comma separated list.
  • -V – Provide description what is being done.

1. Filesystem Check on a Disk Partition

First, view all the available partitions on your system using parted command as shown below.
# parted /dev/sda 'print'

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  106MB   105MB   primary   fat16        diag
 2      106MB   15.8GB  15.7GB  primary   ntfs         boot
 3      15.8GB  266GB   251GB   primary   ntfs
 4      266GB   500GB   234GB   extended
 5      266GB   466GB   200GB   logical   ext4
 6      467GB   486GB   18.3GB  logical   ext2
 7      487GB   499GB   12.0GB  logical   fat32        lba
You can check a specific filesystem (for example: /dev/sda6) as shown below.
# fsck /dev/sda6
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6: clean, 95/2240224 files, 3793506/4476416 blocks
The following are the possible exit codes for fsck command.
  • 0 – No errors
  • 1 – Filesystem errors corrected
  • 2 – System should be rebooted
  • 4 – Filesystem errors left uncorrected
  • 8 – Operational error
  • 16 – Usage or syntax error
  • 32 – Fsck canceled by user request
  • 128 – Shared-library error

2. Fsck Command Specific to a Filesystem Type

fsck internally uses the respective filesystem checker command for a filesystem check operation. These fsck checker commands are typically located under /sbin.
The following example show the various possible fsck checker commands (for example: fsck.ext2, fsck.ext3, fsck.ext4, etc.)
# cd /sbin
# ls fsck*
fsck  fsck.cramfs  fsck.ext2  fsck.ext3  fsck.ext4  fsck.ext4dev  fsck.minix  fsck.msdos  fsck.nfs  fsck.vfat
fsck command will give you an error when it doesn’t find a filesystem checker for the filesystem that is being checked.
For example, if you execute fsck over a ntfs partition, you’ll get the following error message. There is no fsck.ntfs under /sbin. So, this gives the following error message.
# fsck /dev/sda2
fsck from util-linux 2.20.1
fsck: fsck.ntfs: not found
fsck: error 2 while executing fsck.ntfs for /dev/sda2

3. Check All Filesystems in One Run using Option -A

You can check all the filesystems in a single run of fsck using this option. This checks the file system in the order given by the fs_passno mentioned for each filesystem in /etc/fstab.
Please note that the filesystem with a fs_passno value of 0 are skipped, and greater than 0 are checked in the order.
The /etc/fstab contains the entries as listed below,
# cat /etc/fstab

##
proc            /proc           proc    nodev,noexec,nosuid 0       0
## / was on /dev/sda5 during installation
/dev/sda5 /               ext4    errors=remount-ro 0       1
## /mydata was on /dev/sda6 during installation
/dev/sda6 /mydata         ext2    defaults        0       2
## /backup was on /dev/sda7 during installation
/dev/sda7 /backup         vfat    defaults        0       3
Here, the filesystem with the same fs_passno are checked in parallel in your system.
# fsck -A
It is recommended that you exclude the root filesystem during this global check by adding -R option as shown below.
# fsck -AR -y
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6: clean, 95/2240224 files, 3793506/4476416 blocks
dosfsck 3.0.12, 29 Oct 2011, FAT32, LFN
/dev/sda7: 8 files, 50/1463400 clusters
Note: Option -y is explained in one of the examples below.

4. Check Only a Specific Filesystem Type using Option -t

Using fsck -t option, you can specify the list of filesystem to be checked. When you are using with option -A, the fsck will check only the filesystem mentioned with this option -t. Note that fslist is a comma separated values.
Now, pass ext2 as the fslist value to -t option as shown below:
# fsck -AR -t ext2 -y
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6: clean, 11/2240224 files, 70327/4476416 blocks
In this example, /dev/sda6 is the only partition created with the filesystem ext2, thus it get checked accordingly.
Using the keyword ‘no’ in front of filesystem, you can check all other filesystem types except a particular filesystem.
In the following example, ext2 filesystem is excluded from the check.
# fsck -AR -t noext2 -y
fsck from util-linux 2.20.1
dosfsck 3.0.12, 29 Oct 2011, FAT32, LFN
/dev/sda7: 0 files, 1/1463400 clusters

5. Don’t execute Fsck on Mounted Filesystem using Option -M

It is a good idea to use this option as default with all your fsck operation. This prevents you from running fsck accidentally on a filesystem that is mounted.
# mount | grep "/dev/sd*"
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
/dev/sda6 on /mydata type ext2 (rw)
/dev/sda7 on /backup type vfat (rw)
As shown above, /dev/sda7 is mounted. If you try to execute fsck on this /dev/sda7 mounted filesystem (along with the -M option), fsck will simply exit with the exit code 0 as shown below.
# fsck -M /dev/sda7
# echo $?
0

6. Skip the Display Title using Option -T

Using option -T, you can skip the title get displayed in the beginning of fsck command output.
# fsck -TAR
e2fsck 1.42 (29-Nov-2011)
/dev/sda6 is mounted.  e2fsck: Cannot continue, aborting.
dosfsck 3.0.12, 29 Oct 2011, FAT32, LFN
/dev/sda7: 8 files, 50/1463400 clusters
Note that the title is something like “fsck from util-linux 2.20.1”.

7. Force a Filesystem Check Even if it’s Clean using Option -f

By default fsck tries to skip the clean file system to do a quicker job.
# fsck /dev/sda6
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6: clean, 95/2240224 files, 3793503/4476416 blocks
You can force it to check the file system using -f as shown below.
# fsck /dev/sda6 -f
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda6: 95/2240224 files (7.4% non-contiguous), 3793503/4476416 blocks

8. Attempt to Fix Detected Problems Automatically using Option -y

In the following example, /dev/sda6 partition is corrupted as shown below.
# mount /dev/sda6 /mydata
# cd /mydata
# ls -li
ls: cannot access test: Input/output error
total 72
  49061 -rw-r--r--  1 root root     8 Aug 21 21:50 1
  49058 -rw-r--r--  1 root root 36864 Aug 21 21:24 file_with_holes
  49057 -rw-r--r--  1 root root  8192 Aug 21 21:23 fwh
     11 drwxr-xr-x  2 root root 49152 Aug 19 00:29 lost+found
2060353 ?rwSr-S-wT 16 root root  4096 Aug 21 21:11 Movies
      ? -?????????  ? ?    ?        ?            ? test
As seen above, the directory Movies and a file test attributes are invalid.
In the following example, -y will pass “yes” to all the questions to fix the detected corruption automatically.
# fsck -y /dev/sda6
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 2060353 is a unknown file type with mode 0137642 but it looks 
like it is really a directory.
Fix? yes

Pass 2: Checking directory structure
Entry 'test' in / (2) has deleted/unused inode 49059.  Clear? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sda6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda6: 96/2240224 files (7.3% non-contiguous), 3793508/4476416 blocks

9. Avoid Repair, but Report Problems to Stdout using Option -n

It is possible to print such detected problems into stdout without repairing the filesystem using fsck -n option.
First, you could notice/see the problem in partition /dev/sda6 that the Movies directory (and fwh file) doesn’t have valid attribute details.
# mount /dev/sda6 /mydata
# cd /mydata
# ls -lrt
total 64
drwxr-xr-x  2 root root 49152 Aug 19 00:29 lost+found
?--xrwx-wx 16 root root  4096 Aug 21 21:11 Movies
?-----x-wx  1 root root  8192 Aug 21 21:23 fwh
-rw-r--r--  1 root root 36864 Aug 21 21:24 file_with_holes
-rw-r--r--  1 root root     8 Aug 21 21:50 1
The above problem in the specific partition displayed in stdout without doing any fix on it as follows,
The following fsck example displays the problem in the stdout without fixing it. (partial output is shown below).
# fsck -n /dev/sda6
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 2060353 is a unknown file type with mode 0173 but it looks 
like it is really a directory.
Fix? no
Inode 2060353, i_blocks is 8, should be 0.  Fix? no

Pass 2: Checking directory structure
Inode 2060353 (/Movies) has invalid mode (0173).
Clear? no

Inode 49057 (/fwh) has invalid mode (013).
Clear? no

Entry 'fwh' in / (2) has an incorrect filetype (was 1, should be 0).
Fix? no

Pass 3: Checking directory connectivity
Unconnected directory inode 65409 (???)
Connect to /lost+found? no

'..' in ... (65409) is ??? (2060353), should be  (0).
Fix? no

Unconnected directory inode 2076736 (???)
Connect to /lost+found? no

Pass 4: Checking reference counts
Inode 2 ref count is 4, should be 3.  Fix? no

Inode 65409 ref count is 3, should be 2.  Fix? no

Inode 2060353 ref count is 16, should be 15.  Fix? no

Unattached inode 2060354
Connect to /lost+found? no

Pass 5: Checking group summary information
Block bitmap differences:  -(164356--164357) -4149248
Fix? no

Directories count wrong for group #126 (1, counted=0).
Fix? no

/dev/sda6: ********** WARNING: Filesystem still has errors **********

/dev/sda6: 96/2240224 files (7.3% non-contiguous), 3793508/4476416 blocks

10. Automatically Repair the Damaged Portions using Option -a

In order to repair the damaged portion automatically ( without any user interaction ), use the option -a as shown below.
# fsck -a -AR
The option -a is same as -p in e2fsck utility. It cause e2fsck to fix any detected problems that has to be safely fixed without user interaction.
In case when fsck requires administrator’s attention, it simply exits with error code 4 before printing the description of the problem.
# fsck -a /dev/sda6
fsck from util-linux 2.20.1
/dev/sda6 contains a file system with errors, check forced.
/dev/sda6: Inode 2060353 is a unknown file type with mode 0173 but it looks
like it is really a directory.

/dev/sda6: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
 (i.e., without -a or -p options)

# echo $?
4
As you remember, fsck -y option can be used here to fix the above issue automatically.
# fsck -y /dev/sda6
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/sda6 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 2060353 is a unknown file type with mode 0173 but it looks
like it is really a directory.
Fix? yes

Pass 2: Checking directory structure
Inode 49057 (/fwh) has invalid mode (013).
Clear? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  -(164356--164357)
Fix? yes

Free blocks count wrong for group #5 (0, counted=2).
Fix? yes

Free blocks count wrong (682908, counted=682910).
Fix? yes

/dev/sda6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda6: 95/2240224 files (7.4% non-contiguous), 3793506/4476416 blocks