Saturday, 4 January 2020

Scanning FC-LUN's in Redhat Linux

Scanning FC-LUN’s in Redhat Linux

1.First, find out how many disks are visible in “fdisk -l” .
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
2.Find out how many host bus adapter configured in the Linux box.you can use “systool -fc_host -v” to verify available FC in the system.
# ls /sys/class/fc_host
host0  host1
In this case,you need to scan host0 & host1 HBA.


3.If the system virtual memory is too low ,then do not proceed further.If you have enough free virtual memory,then you can proceed with below command to scan new LUNS.
# echo "1" > /sys/class/fc_host/host0/issue_lip
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "1" > /sys/class/fc_host/host1/issue_lip
# echo "- - -" > /sys/class/scsi_host/host1/scan
Note: You need to monitor the “issue_lip” in /var/log/messages to determine when the scan will complete.This operation is an asynchronous operation.

You can also use rescan-scsi-bus.sh script to detect new LUNS.
# yum install sg3_utils
# ./rescan-scsi-bus.sh

4. Verify if the new LUN is visible or not by counting the available disks.
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
If any new LUNS added , then you can see more count is more then before scanning the LUNS.


Scanning SCSI DISKS in Redhat Linux

1. Finding the existing disk from fdisk.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes

2. Find out how many SCSI controller configured.
[root@mylinz1 ~]# ls /sys/class/scsi_host/host
host0 host1 host2
In this case, you need to scan host0,host1 & host2.

3. Scan the SCSI disks using below command.
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

4. Verify if the new disks are visible or not.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes
Disk /dev/sdb: 1073 MB, 1073741824 bytes
Disk /dev/sdc: 1073 MB, 1073741824 bytes


#multipath -ll
oradata03 (360050768018085dc7000000000000xxx) dm-8 IBM ,2145
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 1:0:0:4 sde 8:64 active ready running
| `- 8:0:0:4 sdu 65:64 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
|- 1:0:1:4 sdm 8:192 active ready running
`- 8:0:1:4 sdac 65:192 active ready running

How to remove LUN from Live Server ?
Step 1: Unmounting  the LUN :

First, we need to unmount the file system we are about to release.

umount /dev/mapper/oradata03

Once unmount the filesystem  now lets remove the related  Logical volume, Volume group and Physical volume.

# fdisk -l /dev/mapper/oradata03

Disk /dev/mapper/oradata03: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disk label type: dos
Disk identifier: 0x77e6d4cb

Device Boot Start End Blocks Id System
/dev/mapper/oradata03p1 2048 1048575999 524286976 83 Linux

Now with fdisk you can delete the  partitions .

#fdisk /dev/mapper/oradata03
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/mapper/oradata03: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disk label type: dos
Disk identifier: 0x77e6d4cb

Device Boot Start End Blocks Id System
/dev/mapper/oradata03p1 2048 1048575999 524286976 83 Linux

Delete the Partition oradata03p1

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# partprobe /dev/mapper/oradata03

 

Now lets  clear the Alias information from multipath.conf.
Step 2: Removing disks from the multipath config

Delete  entries from multipath configuration file  under alias and blacklist exceptions.

# vi /etc/multipath.conf

multipaths {
multipath {
wwid 360050768018085dc7000000000000xxx
alias oradata03
}
}

blacklist_exceptions {
        
        wwid "360050768018085dc7000000000000xx"
       

}

 

Ahead we need to remove from the wwids file by editing or using the “multipath -w” command.

# vi /etc/multipath/wwids
# multipath -w 360050768018085dc7000000000000xxx
wwid '360050768018085dc7000000000000xxx' removed

Explain -w options ( multipath -help) :

-w remove a device from the wwids file

Flush the DM device name using -f option.  from above command my dm was  dm-8

# multipath -ll
# multipath -f dm-8e

Steps 3: Removing SAN paths .

Remove the device paths , from the  first command of multipath -ll   you see  that   my  devices paths  are   sde sdu  sdm sdac

Remove the devices got from “multipath -ll” or can find the device name from below location.

# ls -lthr /dev/disk/by-id/*xxx  ( to  get  more  information) 
# echo 1 > /sys/block/sde/device/delete
# echo 1 > /sys/block/sdu/device/delete
# echo 1 > /sys/block/sdm/device/delete
# echo 1 > /sys/block/sdac/device/delete

This will remove the Storage device (LUN) from RHEL, CentOS, Oracle Servers and variants.