Saturday, 12 May 2018

Fiber Channel Cheat Sheet - Deleting LUNs

I want to delete the following LUN:
"mpathe" LUN WWID is "600507680c800507f0000000000000c6" (without "3") Disks are "/dev/sdh", "/dev/sdm", "/dev/sdc" and "/dev/sdr".
[root@B54LFRTMPSTG01 ~]# multipath -ll
mpathe (3600507680c800507f0000000000000c6) dm-4 IBM     ,2145            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:2 sdh        8:112 active ready running
| `- 1:0:0:2 sdm        8:192 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:2 sdc        8:32  active ready running
  `- 1:0:1:2 sdr        65:16 active ready running


Find the used Physical Volume (PV), Volume Group (VG), Logical Volume (LV), Filesystem and Mount Point used by "mpathe"
[root@B54LFRTMPSTG01 ~]# pvs | grep -e PV  -e mpathe
  PV                 VG                  Fmt  Attr PSize     PFree 
  /dev/mapper/mpathe vg-community-master lvm2 a--    <55.00g     0 
[root@B54LFRTMPSTG01 ~]# lvs | grep -e LV -e vg-community-master
  LV               VG                  Attr       LSize     Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  community-master vg-community-master -wi-ao----   <55.00g    
[root@B54LFRTMPSTG01 ~]# df -hT /dev/vg-community-master/community-master
Filesystem                                          Type  Size  Used Avail Use% Mounted on
/dev/mapper/vg--community--master-community--master ext3   55G   52M   52G   1% /home/databases/community-master
[root@B54LFRTMPSTG01 ~]# lsblk | grep -B1 -A1 mpathe
sdc                                           8:32   0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdh                                           8:112  0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdm                                           8:192  0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdr                                          65:16   0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master


Umount "/home/databases/community-master" mount point:
[root@B54LFRTMPSTG01 ~]# umount /home/databases/community-master


Comment "/home/databases/community-master" line from "/etc/fstab" file:
#/dev/vg-community-master/community-master       /home/databases/community-master        ext3    defaults,noatime        0       0


Deactivate "community-master" LV and "vg-community-master" VG:
[root@B54LFRTMPSTG01 ~]# lvchange -an /dev/vg-community-master/community-master
[root@B54LFRTMPSTG01 ~]# vgchange -an vg-community-master
  0 logical volume(s) in volume group "vgsql" now active


IF AND ONLY IF YOU DO NOT WANT THE TO MOVE THE LV AND VG TO ANOTHER HOST, THEN DELETE "community-master" LV and "vg-community-master" VG, OTHERWISE, EXPORT the VG:
[root@B54LFRTMPSTG01 ~]# lvremove /dev/vg-community-master/community-master
[root@B54LFRTMPSTG01 ~]# vgremove vg-community-master


Remove 'mpathe" device:
[root@B54LFRTMPSTG01 ~]# multipath -f mpathe
[root@B54LFRTMPSTG01 ~]# multipath -ll
[root@B54LFRTMPSTG01 ~]# echo $?
0


Unmap Disks the forms "mpathe" from your discovered LUNs:
[root@B54LFRTMPSTG01 ~]# echo 1 > /sys/block/sdh/device/delete 
[root@B54LFRTMPSTG01 ~]# echo 1 > /sys/block/sdm/device/delete 
[root@B54LFRTMPSTG01 ~]# echo 1 > /sys/block/sdc/device/delete 
[root@B54LFRTMPSTG01 ~]# echo 1 > /sys/block/sdr/device/delete 

Fiber Channel Cheat Sheet - Adding new LUNs

New Server that has no LUNs
[root@B54LFRTMPSTG01 ~]# hostname && cat /etc/redhat-release 
B54LFRTMPSTG01
Red Hat Enterprise Linux Server release 7.4 (Maipo)


Make sue that there is not Attached LUNs by cechking "/proc/scsi/scsi":
[root@B54LFRTMPSTG01 ~]# cat /proc/scsi/scsi 
Attached devices:


As you have only Direct Attached Disks, you will see them only under "/dev/disk/by-path":
[root@B54LFRTMPSTG01 ~]# ls -lha /dev/disk/by-path/
total 0
drwxr-xr-x 2 root root 100 Apr 28 11:29 .
drwxr-xr-x 5 root root 100 Apr 23 10:34 ..
lrwxrwxrwx 1 root root  16 Apr 23 10:35 pci-0000:0b:08.0-cciss-disk0 -> ../../cciss/c0d0
lrwxrwxrwx 1 root root  18 Apr 23 10:35 pci-0000:0b:08.0-cciss-disk0-part1 -> ../../cciss/c0d0p1
lrwxrwxrwx 1 root root  18 Apr 23 10:35 pci-0000:0b:08.0-cciss-disk0-part2 -> ../../cciss/c0d0p2


Check How many Fibre Channel Cards (HBAs), you have two: "host0" and "host1"
[root@B54LFRTMPSTG01 ~]# ls /sys/class/fc_host
host0  host1


Refresh LUNs list to discover new mapped LUNs to your OS:
[root@B54LFRTMPSTG01 ~]# echo "1" > /sys/class/fc_host/host0/issue_lip
[root@B54LFRTMPSTG01 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@B54LFRTMPSTG01 ~]# echo "1" > /sys/class/fc_host/host1/issue_lip
[root@B54LFRTMPSTG01 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan


Now, there are 20 LUNs attached to your OS:
Vendor: IBM
Model: 2145
[root@B54LFRTMPSTG01 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
[root@B54LFRTMPSTG01 ~]# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
20
[root@B54LFRTMPSTG01 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
Disk /dev/cciss/c0d0: 73.4 GB, 73372631040 bytes, 143305920 sectors
Disk /dev/mapper/rhel-root: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/mapper/rhel-swap: 7340 MB, 7340032000 bytes, 14336000 sectors
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Disk /dev/sdb: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdc: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdd: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sde: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Disk /dev/sdf: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Disk /dev/sdg: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/mapper/mpathc: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Disk /dev/mapper/mpathd: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdh: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdi: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/mapper/mpathe: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdj: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Disk /dev/mapper/mpathf: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/mapper/mpathg: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Disk /dev/sdk: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Disk /dev/sdl: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdm: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdn: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdo: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Disk /dev/sdp: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Disk /dev/sdq: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdr: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sds: 59.1 GB, 59055800320 bytes, 115343360 sectors
Disk /dev/sdt: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors


Optional: Find Device instructions to e added to "/etc/multipath.conf" configuration file:
RHEL 7
[root@B54LFRTMPSTG01 ~]# multipath -t | grep -B2 -A8 2145
 device {
  vendor "IBM"
  product "^2145"
  path_grouping_policy "group_by_prio"
  path_checker "tur"
  features "1 queue_if_no_path"
  hardware_handler "0"
  prio "alua"
  failback immediate
  rr_weight "uniform"
 }
RHEL 6
[root@fcsmpsql4:~]# grep -B2 -A12  2145 /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.defaults 
# device {
#  vendor "IBM"
#  product "^2145"
#  path_grouping_policy group_by_prio
#  getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
#  path_selector "round-robin 0"
#  path_checker tur
#  features "1 queue_if_no_path"
#  hardware_handler "0"
#  prio alua
#  failback immediate
#  rr_weight uniform
#  rr_min_io 1000
#  rr_min_io_rq 1
# }


Set initial configuration for "multipathd" daemon using "mpathconf" command:
mpathconf --enable --user_friendly_names n'


Adjust the "multipath" configurations as you need, here is just an example:
[root@B54LFRTMPSTG01 ~]# grep -v ^# /etc/multipath.conf | awk NF
defaults {
 user_friendly_names yes
 find_multipaths yes
}
devices {
 device {
  vendor "IBM"
  product "^2145"
  path_grouping_policy "group_by_prio"
  path_checker "tur"
  features "1 queue_if_no_path"
  hardware_handler "0"
  prio "alua"
  failback immediate
  rr_weight "uniform"
 }
}
[root@B54LFRTMPSTG01 ~]# systemctl restart multipathd 


List the new 'multipath -ll' output:
[root@B54LFRTMPSTG01 ~]# multipath -ll
mpathe (3600507680c800507f0000000000000c6) dm-4 IBM     ,2145            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:2 sdh        8:112 active ready running
| `- 1:0:0:2 sdm        8:192 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:2 sdc        8:32  active ready running
  `- 1:0:1:2 sdr        65:16 active ready running
mpathd (3600507680c800507f0000000000000c5) dm-3 IBM     ,2145            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:1 sdg        8:96  active ready running
| `- 1:0:0:1 sdl        8:176 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:1 sdb        8:16  active ready running
  `- 1:0:1:1 sdq        65:0  active ready running
mpathc (3600507680c800507f0000000000000c4) dm-2 IBM     ,2145            
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:0 sdf        8:80  active ready running
| `- 1:0:0:0 sdk        8:160 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:0 sda        8:0   active ready running
  `- 1:0:1:0 sdp        8:240 active ready running
mpathg (3600507680c800507f0000000000000c8) dm-6 IBM     ,2145            
size=1000G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:4 sdj        8:144 active ready running
| `- 1:0:0:4 sdo        8:224 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:4 sde        8:64  active ready running
  `- 1:0:1:4 sdt        65:48 active ready running
mpathf (3600507680c800507f0000000000000c7) dm-5 IBM     ,2145            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:3 sdi        8:128 active ready running
| `- 1:0:0:3 sdn        8:208 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:3 sdd        8:48  active ready running
  `- 1:0:1:3 sds        65:32 active ready running

Thursday, 10 May 2018

Fiber Channel Cheat Sheet - Collecting Data

References:

https://www.opentechguides.com/how-to/article/linux/18/fc-hba-linux.html
http://www.fibrevillage.com/sysadmin/9-storage/9-check-hba-card-and-its-driver-s-info-in-linux-rhel6
http://fibrevillage.com/storage/61-systool-a-useful-tool-for-san-as-well-for-sysfs-devices
https://access.redhat.com/articles/17054#NR2
https://access.redhat.com/articles/17628


Storage Connection Diagram




List your Fibre Channel Cards (HBAs) Hardware Info:


Determine the Manufacturer and Model of the HBAs (Fibre Channel Card):
[root@fcsmpsql4:~]# lspci | grep "Fibre Channel"
06:00.0 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)
06:00.1 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)

Get the Vendor and Device IDs for the HBAs installed:
Vendor10df
Vendor NameEmulex Corporation
Devicefe00
Device NameZephyr-X LightPulse Fibre Channel Host Adapter
[root@fcsmpsql4:~]# lspci -nn | grep "Fibre Channel"
06:00.0 Fibre Channel [0c04]: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter [10df:fe00] (rev 02)
06:00.1 Fibre Channel [0c04]: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter [10df:fe00] (rev 02)
[root@fcsmpsql4:~]# grep -e "10df  Emulex Corporation" -e "fe00  Zephyr-X LightPulse Fibre Channel Host Adapter" /usr/share/hwdata/pci.ids
# List of PCI ID's
#
# Version: 2017.02.15
# Date:    2017-02-15 03:15:02
#
# Maintained by Albert Pool, Martin Mares, and other volunteers from
# the PCI ID Project at http://pci-ids.ucw.cz/.
#
# New data are always welcome, especially if they are accurate. If you have
# anything to contribute, please follow the instructions at the web site.
#
# This file can be distributed under either the GNU General Public License
# (version 2 or higher) or the 3-clause BSD License.
#

# Vendors, devices and subsystems. Please keep sorted.

# Syntax:
# vendor  vendor_name
# device  device_name    
10df  Emulex Corporation
 fe00  Zephyr-X LightPulse Fibre Channel Host Adapter

Check if the HBA driver modules are installed:
[root@fcsmpsql4:~]# grep 10df /lib/modules/$(uname -r)/modules.* | grep fe00
/lib/modules/2.6.32-696.6.3.el6.x86_64/modules.pcimap:lpfc                 0x000010df 0x0000fe00 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

Find HBA Kernel driver:
[root@fcsmpsql4:~]# lspci -v -s 06:00.0 | grep Kernel
 Kernel driver in use: lpfc
 Kernel modules: lpfc

Check if the drivers for HBA are loaded in the kernel:
[root@fcsmpsql4:~]# lsmod |  grep -e Module -e lpfc
Module                  Size  Used by
lpfc                  664415  84 
scsi_transport_fc      55235  1 lpfc
crc_t10dif              1209  2 sd_mod,lpfc

Collect information about HBA kernel module:
## -- HBA Kernel Module Dependencies -- ##
[root@fcsmpsql4:~]# modprobe --show-depends lpfc
WARNING: All config files need .conf: /etc/modprobe.d/fc-hba.conf.old, it will be ignored in a future release.
insmod /lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/lib/crc-t10dif.ko 
insmod /lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/drivers/scsi/scsi_tgt.ko 
insmod /lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/drivers/scsi/scsi_transport_fc.ko 
insmod /lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/drivers/scsi/lpfc/lpfc.ko lpfc_lun_queue_depth=16 lpfc_nodev_tmo=30 lpfc_discovery_threads=32 lpfc_lun_queue_depth=16 lpfc_nodev_tmo=30 lpfc_discovery_threads=32
## -- HBA Author Infomation -- ##
[root@fcsmpsql4:~]# modinfo -a lpfc
Emulex Corporation - tech.support@emulex.com
## -- HBA Description -- ##
[root@fcsmpsql4:~]# modinfo -d lpfc
Emulex LightPulse Fibre Channel SCSI driver 11.0.0.6
## -- HBA Kernel Module Filename -- ##
[root@fcsmpsql4:~]# modinfo -n lpfc
/lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/drivers/scsi/lpfc/lpfc.ko
## -- HBA Kernel Module Licence Info -- ##
[root@fcsmpsql4:~]# modinfo -l lpfc
GPL
## -- HBA Kernel Module Version and Source Version -- ##
[root@fcsmpsql4:~]# modinfo lpfc | grep -e ^version -e srcversion
version:        0:11.0.0.6
srcversion:     2BC7C844F14E68EDDECDE59
## -- Check if the current HBA Kernal module is the same with the current kernel one -- ##
[root@fcsmpsql4:~]# uname -r
2.6.32-696.6.3.el6.x86_64

[root@fcsmpsql4:~]# modinfo -k $(uname -r) -n lpfc
/lib/modules/2.6.32-696.6.3.el6.x86_64/kernel/drivers/scsi/lpfc/lpfc.ko

Check How many HBAs (Fibre Channels Card) you have - Two Cards here (host1, and host2):
[root@fcsmpsql4:~]# ls -lh /sys/class//fc_host/
total 0
lrwxrwxrwx 1 root root 0 May 10 14:50 host1 -> ../../devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/fc_host/host1
lrwxrwxrwx 1 root root 0 May 10 17:40 host2 -> ../../devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/fc_host/host2
OR
[root@fcsmpsql4:~]# systool -c fc_host
Class = "fc_host"

  Class Device = "host1"
    Device = "host1"

  Class Device = "host2"
    Device = "host2"

Collect:
1) HBA Name for the two above HBA.
2) FC SAN Switch World Wide Name (WWN).
3) HBA World Wide Node Name (WWNN) for the two above two HBAs.
4) HBA World Wide Port Number (WWPN) for the above two HBAs.
5) Fabric port id assigned by the SAN to above two HBAs
[root@fcsmpsql4:~]# systool -c fc_host -v 
Class = "fc_host"

  Class Device = "host1"                        --> HBA Name
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/fc_host/host1"  --> Kernel assigned host name/number
    fabric_name         = "0x100050eb1a486d5d"  --> FC SAN Switch WWN
    node_name           = "0x20000000c9be6c4e"  --> HBA WWNN
    port_name           = "0x10000000c9be6c4e"  --> HBA WWPN
    port_id             = "0x030918"            --> fabric port id assigned by the san to this HBA
    port_state          = "Online"
    port_type           = "NPort (fabric via point-to-point)"
    speed               = "4 Gbit"
    supported_speeds    = "1 Gbit, 2 Gbit, 4 Gbit"


  Class Device = "host2"                        --> HBA Name
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/fc_host/host2"  --> Kernel assigned host name/number
    fabric_name         = "0x100050eb1a4868c5"  --> FC SAN Switch WWN 
    node_name           = "0x20000000c9be6c4f"  --> HBA WWNN
    port_name           = "0x10000000c9be6c4f"  --> HBA WWPN
    port_id             = "0x040929"            --> fabric port id assigned by the san to this HBA
    port_state          = "Online"
    port_type           = "NPort (fabric via point-to-point)"
    speed               = "4 Gbit"
    supported_speeds    = "1 Gbit, 2 Gbit, 4 Gbit"
OR
## -- FC SAN Switch WWN -- ##
[root@fcsmpsql4:~]# cat /sys/class/fc_host/host1/fabric_name 
0x100050eb1a486d5d

[root@fcsmpsql4:~]# cat /sys/class/fc_host/host2/fabric_name 
0x100050eb1a4868c5
## -- HBA WWNN -- ##
[root@fcsmpsql4:~]# cat /sys/class/fc_host/host1/node_name
0x20000000c9be6c4e

[root@fcsmpsql4:~]# cat /sys/class/fc_host/host2/node_name
0x20000000c9be6c4f
## -- HBA WWPN -- ##
[root@fcsmpsql4:~]# cat /sys/class/fc_host/host1/port_name
0x10000000c9be6c4e

[root@fcsmpsql4:~]# cat /sys/class/fc_host/host2/port_name
0x10000000c9be6c4f
## -- fabric port id assigned by the san to this HBA --##
[root@fcsmpsql4:~]# cat /sys/class/fc_host/host1/port_id
0x030918

[root@fcsmpsql4:~]# cat /sys/class/fc_host/host2/port_id
0x040929



List Storage Arrays (targets) Information:

Collect:
1) Storage (Target) World Wide Node Name (WWNN).
2) Storage (Target) World Wide Port Number (WWPN).
3) Fabric port id assigned by the san to this storage port

We have 4 paths for each HBA as shown in the first diagram, so we can see the following targets:
Host1 -> "target1:0:0", "target1:0:6", "target1:0:7" and "target1:0:8"
Host2 -> "target2:0:1", "target2:0:6", "target2:0:7" and "target2:0:8"
[root@fcsmpsql4:~]# systool -c fc_transport -v
  Class Device = "0:0"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/rport-1:0-2/target1:0:0/fc_transport/target1:0:0"
    node_name           = "0x5000144047606984"        --> Storage target WWNN
    port_id             = "0x033800"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442a0698400"        --> Storage target WWPN

  Class Device = "0:1"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/rport-2:0-3/target2:0:1/fc_transport/target2:0:1"
    node_name           = "0x5000144047706984"        --> Storage target WWNN
    port_id             = "0x043800"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442b0698401"        --> Storage target WWPN

  Class Device = "0:6"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/rport-1:0-8/target1:0:6/fc_transport/target1:0:6"
    node_name           = "0x5000144047706991"        --> Storage target WWNN
    port_id             = "0x033c00"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442b0699100"        --> Storage target WWPN

  Class Device = "0:6"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/rport-2:0-8/target2:0:6/fc_transport/target2:0:6"
    node_name           = "0x5000144047606991"        --> Storage target WWNN
    port_id             = "0x040c00"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442a0699101"        --> Storage target WWPN

 Class Device = "0:7"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/rport-1:0-9/target1:0:7/fc_transport/target1:0:7"
    node_name           = "0x5000144047b02b61"        --> Storage target WWNN
    port_id             = "0x034d00"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442d02b6101"        --> Storage target WWPN

  Class Device = "0:7"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/rport-2:0-9/target2:0:7/fc_transport/target2:0:7"
    node_name           = "0x5000144047b02b9c"        --> Storage target WWNN
    port_id             = "0x044900"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442d02b9c00"        --> Storage target WWPN

  Class Device = "0:8"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host1/rport-1:0-10/target1:0:8/fc_transport/target1:0:8"
    node_name           = "0x5000144047a02b9c"        --> Storage target WWNN
    port_id             = "0x034800"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442c02b9c01"        --> Storage target WWPN

  Class Device = "0:8"
  Class Device path = "/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host2/rport-2:0-10/target2:0:8/fc_transport/target2:0:8"
    node_name           = "0x5000144047a02b61"        --> Storage target WWNN
    port_id             = "0x044c00"                  --> Fabric port id assigned by the SAN to this storage port
    port_name           = "0x50001442c02b6100"        --> Storage target WWPN
OR
RHEL 5:
[root@fcsmpsql4:~]# ls -1c /sys/class/fc_transport/target*/*_name  2> /dev/null | xargs -I {} grep -H -v "ZzZz" {} | sort
[root@fcsmpsql4:~]# ls -1c /sys/class/fc_transport/target*/port_id 2> /dev/null | xargs -I {} grep -H -v "ZzZz" {} | sort
RHEL 6 and RHEL 7:
[root@fcsmpsql4:~]# ls -1c /sys/bus/scsi/devices/target*/fc_transport/target*/*_name  2> /dev/null | xargs -I {} grep -H -v "ZzZz" {} | sort
/sys/bus/scsi/devices/target1:0:0/fc_transport/target1:0:0/node_name:0x5000144047606984
/sys/bus/scsi/devices/target1:0:0/fc_transport/target1:0:0/port_name:0x50001442a0698400
/sys/bus/scsi/devices/target1:0:6/fc_transport/target1:0:6/node_name:0x5000144047706991
/sys/bus/scsi/devices/target1:0:6/fc_transport/target1:0:6/port_name:0x50001442b0699100
/sys/bus/scsi/devices/target1:0:7/fc_transport/target1:0:7/node_name:0x5000144047b02b61
/sys/bus/scsi/devices/target1:0:7/fc_transport/target1:0:7/port_name:0x50001442d02b6101
/sys/bus/scsi/devices/target1:0:8/fc_transport/target1:0:8/node_name:0x5000144047a02b9c
/sys/bus/scsi/devices/target1:0:8/fc_transport/target1:0:8/port_name:0x50001442c02b9c01
/sys/bus/scsi/devices/target2:0:1/fc_transport/target2:0:1/node_name:0x5000144047706984
/sys/bus/scsi/devices/target2:0:1/fc_transport/target2:0:1/port_name:0x50001442b0698401
/sys/bus/scsi/devices/target2:0:6/fc_transport/target2:0:6/node_name:0x5000144047606991
/sys/bus/scsi/devices/target2:0:6/fc_transport/target2:0:6/port_name:0x50001442a0699101
/sys/bus/scsi/devices/target2:0:7/fc_transport/target2:0:7/node_name:0x5000144047b02b9c
/sys/bus/scsi/devices/target2:0:7/fc_transport/target2:0:7/port_name:0x50001442d02b9c00
/sys/bus/scsi/devices/target2:0:8/fc_transport/target2:0:8/node_name:0x5000144047a02b61
/sys/bus/scsi/devices/target2:0:8/fc_transport/target2:0:8/port_name:0x50001442c02b6100
[root@fcsmpsql4:~]# ls -1c /sys/bus/scsi/devices/target*/fc_transport/target*/port_id 2> /dev/null | xargs -I {} grep -H -v "ZzZz" {} | sort
/sys/bus/scsi/devices/target1:0:0/fc_transport/target1:0:0/port_id:0x033800
/sys/bus/scsi/devices/target1:0:6/fc_transport/target1:0:6/port_id:0x033c00
/sys/bus/scsi/devices/target1:0:7/fc_transport/target1:0:7/port_id:0x034d00
/sys/bus/scsi/devices/target1:0:8/fc_transport/target1:0:8/port_id:0x034800
/sys/bus/scsi/devices/target2:0:1/fc_transport/target2:0:1/port_id:0x043800
/sys/bus/scsi/devices/target2:0:6/fc_transport/target2:0:6/port_id:0x040c00
/sys/bus/scsi/devices/target2:0:7/fc_transport/target2:0:7/port_id:0x044900
/sys/bus/scsi/devices/target2:0:8/fc_transport/target2:0:8/port_id:0x044c00



Collecting LUNs information:


Collect LUN General Information


I have two HBAs:
[root@B54LFRTMPSTG01 ~]# ls /sys/class/fc_host/
host0  host1
[root@B54LFRTMPSTG01 ~]# cat /proc/scsi/scsi 
Attached devices:
Host: scsi0 Channel: 00 Id: 01 Lun: 00                                --> LUN is shown using HBA 'host0'
  Vendor: IBM      Model: 2145             Rev: 0000                  --> Vendor is "IBM" and Model is "2145"
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 01
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 03
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 04
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 00 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi0 Channel: 00 Id: 01 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 00 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06
Host: scsi1 Channel: 00 Id: 01 Lun: 02
  Vendor: IBM      Model: 2145             Rev: 0000
  Type:   Direct-Access                    ANSI  SCSI revision: 06

Collect LUN World Wide ID [WWID] and other Information:

Way #1 - "multipathd":


Best and simple way if you have "multipathd" installed:
[root@B54LFRTMPSTG01 ~]# multipath -ll
mpathe (3600507680c800507f0000000000000c6) dm-4 IBM     ,2145      --> LUN WWID is "600507680c800507f0000000000000c6" (without "3")            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw         --> LUN size is 55 GB
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:2 sdc        8:32  active ready running
| `- 1:0:0:2 sdm        8:192 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:2 sdh        8:112 active ready running
  `- 1:0:1:2 sdr        65:16 active ready running
mpathd (3600507680c800507f0000000000000c5) dm-3 IBM     ,2145      --> LUN WWID is "600507680c800507f0000000000000c5" (without "3")            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw         --> LUN size is 55 GB
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:1 sdg        8:96  active ready running
| `- 1:0:0:1 sdl        8:176 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:1 sdb        8:16  active ready running
  `- 1:0:1:1 sdq        65:0  active ready running
mpathc (3600507680c800507f0000000000000c4) dm-2 IBM     ,2145      --> LUN WWID is "600507680c800507f0000000000000c4" (without "3")            
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw         --> LUN size is 500 GB
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:0 sdf        8:80  active ready running
| `- 1:0:0:0 sdk        8:160 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:0 sda        8:0   active ready running
  `- 1:0:1:0 sdp        8:240 active ready running
mpathg (3600507680c800507f0000000000000c8) dm-6 IBM     ,2145      --> LUN WWID is "600507680c800507f0000000000000c8" (without "3")            
size=1000G features='1 queue_if_no_path' hwhandler='0' wp=rw       --> LUN size is 1000 GB
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:4 sdj        8:144 active ready running
| `- 1:0:0:4 sdo        8:224 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:4 sde        8:64  active ready running
  `- 1:0:1:4 sdt        65:48 active ready running
mpathf (3600507680c800507f0000000000000c7) dm-5 IBM     ,2145      --> LUN WWID is "600507680c800507f0000000000000c7" (without "3")            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw         --> LUN size is 55 GB
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:3 sdi        8:128 active ready running
| `- 1:0:0:3 sdn        8:208 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:3 sdd        8:48  active ready running
  `- 1:0:1:3 sds        65:32 active ready running

Way # 2 - Using "lsscsi" or "scsi_id" commands:


If you don't have "multipathd" installed or you want to list WWID for each SCSI Disk you have:

RHEL 7
"/dev/sdf", "/dev/sda", "/dev/sdk" and "/dev/sdp" are the same disk over 4 different paths and they are the same LUN as shown in above "multipath -ll" output
[root@B54LFRTMPSTG01 ~]# lsscsi --scsi-id -g
[0:0:0:0]    disk    IBM      2145             0000  /dev/sdf   3600507680c800507f0000000000000c4  /dev/sg5      --> "/dev/sdf" WWID is "600507680c800507f0000000000000c4" (without 3)
[0:0:0:1]    disk    IBM      2145             0000  /dev/sdg   3600507680c800507f0000000000000c5  /dev/sg6 
[0:0:0:2]    disk    IBM      2145             0000  /dev/sdc   3600507680c800507f0000000000000c6  /dev/sg2 
[0:0:0:3]    disk    IBM      2145             0000  /dev/sdi   3600507680c800507f0000000000000c7  /dev/sg8 
[0:0:0:4]    disk    IBM      2145             0000  /dev/sdj   3600507680c800507f0000000000000c8  /dev/sg9 
[0:0:1:0]    disk    IBM      2145             0000  /dev/sda   3600507680c800507f0000000000000c4  /dev/sg0      --> "/dev/sda" WWID is "600507680c800507f0000000000000c4" (without 3) 
[0:0:1:1]    disk    IBM      2145             0000  /dev/sdb   3600507680c800507f0000000000000c5  /dev/sg1 
[0:0:1:2]    disk    IBM      2145             0000  /dev/sdh   3600507680c800507f0000000000000c6  /dev/sg7 
[0:0:1:3]    disk    IBM      2145             0000  /dev/sdd   3600507680c800507f0000000000000c7  /dev/sg3 
[0:0:1:4]    disk    IBM      2145             0000  /dev/sde   3600507680c800507f0000000000000c8  /dev/sg4 
[1:0:0:0]    disk    IBM      2145             0000  /dev/sdk   3600507680c800507f0000000000000c4  /dev/sg10      --> "/dev/sdk" WWID is "600507680c800507f0000000000000c4" (without 3)
[1:0:0:1]    disk    IBM      2145             0000  /dev/sdl   3600507680c800507f0000000000000c5  /dev/sg11
[1:0:0:2]    disk    IBM      2145             0000  /dev/sdm   3600507680c800507f0000000000000c6  /dev/sg12
[1:0:0:3]    disk    IBM      2145             0000  /dev/sdn   3600507680c800507f0000000000000c7  /dev/sg13
[1:0:0:4]    disk    IBM      2145             0000  /dev/sdo   3600507680c800507f0000000000000c8  /dev/sg14
[1:0:1:0]    disk    IBM      2145             0000  /dev/sdp   3600507680c800507f0000000000000c4  /dev/sg15      --> "/dev/sdp" WWID is "600507680c800507f0000000000000c4" (without 3)
[1:0:1:1]    disk    IBM      2145             0000  /dev/sdq   3600507680c800507f0000000000000c5  /dev/sg16
[1:0:1:2]    disk    IBM      2145             0000  /dev/sdr   3600507680c800507f0000000000000c6  /dev/sg17
[1:0:1:3]    disk    IBM      2145             0000  /dev/sds   3600507680c800507f0000000000000c7  /dev/sg18
[1:0:1:4]    disk    IBM      2145             0000  /dev/sdt   3600507680c800507f0000000000000c8  /dev/sg19
RHEL 6:
[root@fcsmpsql4:~]# multipath -ll mpaths
mpaths (36000144000000010b02b614439810a61) dm-5 EMC,Invista
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 1:0:0:5 sdg  8:96   active ready running
  |- 2:0:1:5 sdam 66:96  active ready running
  |- 1:0:6:5 sdbg 67:160 active ready running
  |- 2:0:8:5 sdaq 66:160 active ready running
  |- 1:0:8:5 sdq  65:0   active ready running
  |- 2:0:7:5 sdaf 65:240 active ready running
  |- 1:0:7:5 sdl  8:176  active ready running
  `- 2:0:6:5 sdaa 65:160 active ready running
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdg
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdam
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdbg
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdaq
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdq
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdaf
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdl
36000144000000010b02b614439810a61
[root@fcsmpsql4:~]# scsi_id --replace-whitespace --whitelisted --device /dev/sdaa
RHEL 5
# scsi_id -g -u -s /block/sdm

Way # 3 - Using "sg_inq" commands:

[root@B54LFRTMPSTG01 ~]# lsscsi --scsi-id -g
[0:0:0:0]    disk    IBM      2145             0000  /dev/sdf   3600507680c800507f0000000000000c4  /dev/sg5 
[0:0:0:1]    disk    IBM      2145             0000  /dev/sdg   3600507680c800507f0000000000000c5  /dev/sg6 
[0:0:0:2]    disk    IBM      2145             0000  /dev/sdc   3600507680c800507f0000000000000c6  /dev/sg2 
[0:0:0:3]    disk    IBM      2145             0000  /dev/sdi   3600507680c800507f0000000000000c7  /dev/sg8 
[0:0:0:4]    disk    IBM      2145             0000  /dev/sdj   3600507680c800507f0000000000000c8  /dev/sg9 
[0:0:1:0]    disk    IBM      2145             0000  /dev/sda   3600507680c800507f0000000000000c4  /dev/sg0 
[0:0:1:1]    disk    IBM      2145             0000  /dev/sdb   3600507680c800507f0000000000000c5  /dev/sg1 
[0:0:1:2]    disk    IBM      2145             0000  /dev/sdh   3600507680c800507f0000000000000c6  /dev/sg7 
[0:0:1:3]    disk    IBM      2145             0000  /dev/sdd   3600507680c800507f0000000000000c7  /dev/sg3 
[0:0:1:4]    disk    IBM      2145             0000  /dev/sde   3600507680c800507f0000000000000c8  /dev/sg4 
[1:0:0:0]    disk    IBM      2145             0000  /dev/sdk   3600507680c800507f0000000000000c4  /dev/sg10
[1:0:0:1]    disk    IBM      2145             0000  /dev/sdl   3600507680c800507f0000000000000c5  /dev/sg11
[1:0:0:2]    disk    IBM      2145             0000  /dev/sdm   3600507680c800507f0000000000000c6  /dev/sg12
[1:0:0:3]    disk    IBM      2145             0000  /dev/sdn   3600507680c800507f0000000000000c7  /dev/sg13
[1:0:0:4]    disk    IBM      2145             0000  /dev/sdo   3600507680c800507f0000000000000c8  /dev/sg14
[1:0:1:0]    disk    IBM      2145             0000  /dev/sdp   3600507680c800507f0000000000000c4  /dev/sg15
[1:0:1:1]    disk    IBM      2145             0000  /dev/sdq   3600507680c800507f0000000000000c5  /dev/sg16
[1:0:1:2]    disk    IBM      2145             0000  /dev/sdr   3600507680c800507f0000000000000c6  /dev/sg17
[1:0:1:3]    disk    IBM      2145             0000  /dev/sds   3600507680c800507f0000000000000c7  /dev/sg18
[1:0:1:4]    disk    IBM      2145             0000  /dev/sdt   3600507680c800507f0000000000000c8  /dev/sg19
RHEL 6 and RHEL 7:
[root@B54LFRTMPSTG01 ~]# sg_inq -p 0x83 /dev/sdf | grep -A1 "Vendor Specific Identifier Extension:"
      Vendor Specific Identifier Extension: 0xf0000000000000c4
      [0x600507680c800507f0000000000000c4]                     --> LUN WWID is "600507680c800507f0000000000000c4" (without "0x")
[root@B54LFRTMPSTG01 ~]# sg_inq -p 0x83 /dev/sda | grep -A1 "Vendor Specific Identifier Extension:"
      Vendor Specific Identifier Extension: 0xf0000000000000c4
      [0x600507680c800507f0000000000000c4]                     --> LUN WWID is "600507680c800507f0000000000000c4" (without "0x")
[root@B54LFRTMPSTG01 ~]# sg_inq -p 0x83 /dev/sdk | grep -A1 "Vendor Specific Identifier Extension:"
      Vendor Specific Identifier Extension: 0xf0000000000000c4
      [0x600507680c800507f0000000000000c4]                     --> LUN WWID is "600507680c800507f0000000000000c4" (without "0x")
[root@B54LFRTMPSTG01 ~]# sg_inq -p 0x83 /dev/sdp | grep -A1 "Vendor Specific Identifier Extension:"
      Vendor Specific Identifier Extension: 0xf0000000000000c4
      [0x600507680c800507f0000000000000c4]                     --> LUN WWID is "600507680c800507f0000000000000c4" (without "0x")
RHEL 5
# sg_inq --page 0x83 /dev/sdp | grep -A1 "Vendor Specific Identifier Extension:



Collecting Data for the current mount points that based on LVM system or direct multipath devices

>Case #1 - We have LVM system
[root@B54LFRTMPSTG01 ~]# multipath -ll mpathe
mpathe (3600507680c800507f0000000000000c6) dm-4 IBM     ,2145            
size=55G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:2 sdc        8:32  active ready running
| `- 1:0:0:2 sdm        8:192 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:2 sdh        8:112 active ready running
  `- 1:0:1:2 sdr        65:16 active ready running
[root@B54LFRTMPSTG01 ~]# lsblk | grep -B1 -A1 mpathe
sdc                                           8:32   0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdh                                           8:112  0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdm                                           8:192  0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
--
sdr                                          65:16   0   55G  0 disk  
└─mpathe                                    253:4    0   55G  0 mpath 
  └─vg--community--master-community--master 253:7    0   55G  0 lvm   /home/databases/community-master
[root@B54LFRTMPSTG01 ~]# pvs | grep -e "PV" -e "mpathe"
  PV                 VG                  Fmt  Attr PSize     PFree 
  /dev/mapper/mpathe vg-community-master lvm2 a--    <55.00g     0 
[root@B54LFRTMPSTG01 ~]# vgs | grep -e "VG" -e  -e "vg-community-master"
  VG                  #PV #LV #SN Attr   VSize     VFree 
  vg-community-master   1   1   0 wz--n-   <55.00g     0 
[root@B54LFRTMPSTG01 ~]# lvs | grep -e "LV" -e "community-master"
  Volume group VolGroup00 is exported
  LV               VG                  Attr       LSize     Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert                                             
  community-master vg-community-master -wi-ao----   <55.00g                                                    
[root@B54LFRTMPSTG01 ~]# df -hT /home/databases/community-master
Filesystem                                          Type  Size  Used Avail Use% Mounted on
/dev/mapper/vg--community--master-community--master ext3   55G   52M   52G   1% /home/databases/community-master

Case #2 - We don't have LVM system:
[root@B54LFRTMPSTG01 ~]# multipath -ll mpathc
mpathc (3600507680c800507f0000000000000c4) dm-2 IBM     ,2145            
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 0:0:0:0 sdf        8:80  active ready running
| `- 1:0:0:0 sdk        8:160 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 0:0:1:0 sda        8:0   active ready running
  `- 1:0:1:0 sdp        8:240 active ready running
[root@B54LFRTMPSTG01 ~]# lsblk | grep -B1 mpathc
sda                                           8:0    0  500G  0 disk  
└─mpathc                                    253:2    0  500G  0 mpath /home/databases/mysql/binlogs
--
sdf                                           8:80   0  500G  0 disk  
└─mpathc                                    253:2    0  500G  0 mpath /home/databases/mysql/binlogs
--
sdk                                           8:160  0  500G  0 disk  
└─mpathc                                    253:2    0  500G  0 mpath /home/databases/mysql/binlogs
--
sdp                                           8:240  0  500G  0 disk  
└─mpathc                                    253:2    0  500G  0 mpath /home/databases/mysql/binlogs
[root@B54LFRTMPSTG01 ~]# df -hT /home/databases/mysql/binlogs
Filesystem         Type  Size  Used Avail Use% Mounted on
/dev/mapper/mpathc ext4  493G   73M  467G   1% /home/databases/mysql/binlogs

Saturday, 23 September 2017

SFTP Server


Case #1



- I will create three OS groups:

  • companies -> has N number of companies which has read and write  privileges
  • nusers -> has N number of normal users which has read and write privileges.
  • rousers -> has N number of normal users which has read-only privileges.
for group in companies nusers rousers; do
  groupadd $group
done


- I will create required folders for above groups and set required permissions:

mkdir -pv /sftp/{companies,nusers,rousers}
for dir in companies nusers rousers; do
  chown -v root:root /sftp/${dir}
done


- For demonstration purpose,  Each group of the above groups has the following members:

  • companies: company1, company2 and company3 users
  • nusers: nuser1, nuser2 and nusers3 users.
  • rousers: rouser1, rouser2 and rouser3 users
for id in 1 2 3; do
  adduser company${id} -g companies -s /sbin/nologin
  echo "redhat" | passwd --stdin company${id}
  mkdir -v /sftp/companies/company${id}
  chown -v company${id}:companies /sftp/companies/company${id}
  chmod -v 700 /sftp/companies/company${id}
done
for id in 1 2 3; do
  adduser nuser${id} -g nusers -s /sbin/nologin
  echo "redhat" | passwd --stdin nuser${id}
  mkdir -v /sftp/nusers/nuser${id}
  chown -v nuser${id}:nusers /sftp/nusers/nuser${id}
  chmod -v 700 /sftp/nusers/nuser${id}
done
for id in 1 2 3; do
  adduser rouser${id} -g rousers -s /sbin/nologin
  echo "redhat" | passwd --stdin rouser${id}
  mkdir -v /sftp/rousers/rouser${id}
  chown -v rouser${id}:rousers /sftp/rousers/rouser${id}
  chmod -v 700 /sftp/rousers/rouser${id}
done


- Add the following lines to '/etc/ssh/sshd_config' file:

[root@sftp-server ~]# cp -av /etc/ssh/sshd_config /root/orig_files/
‘/etc/ssh/sshd_config’ -> ‘/root/orig_files/sshd_config’
[root@base ~]# tail -n23 /etc/ssh/sshd_config 
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server

# Companies
Match Group companies
  ChrootDirectory /sftp/companies  # Directory that 'companies' group members will change directory to 
  ForceCommand internal-sftp
  X11Forwarding no
  AllowTcpForwarding no

# nusers
Match Group nusers
  ChrootDirectory /sftp/nusers  # Directory that 'nusers' group members will change directory to    
  ForceCommand internal-sftp
  X11Forwarding no
  AllowTcpForwarding no

# rousers
Match Group rousers
  ChrootDirectory /sftp/rousers  # Directory that 'rousers' group members will change directory to
  ForceCommand internal-sftp -R  # read-only privileges 
  X11Forwarding no
  AllowTcpForwarding no


- Restart sshd service:

[root@sftp-server ~]# systemctl restart sshd


- Testing upload and download for 'company1':

[root@sftp-server ~]# sftp company1@localhost
company1@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /

sftp> ls -lh
drwx------    0 1000     1000           6B Sep 23 12:42 company1
drwx------    0 1001     1000           6B Sep 23 12:35 company2
drwx------    0 1002     1000           6B Sep 23 12:35 company3

sftp> cd company1

sftp> pwd
Remote working directory: /company1

sftp> ls -lh

sftp> !ls
anaconda-ks.cfg  orig_files

sftp> put anaconda-ks.cfg 
Uploading anaconda-ks.cfg to /company1/anaconda-ks.cfg
anaconda-ks.cfg                                                                                                                                         100% 1266     2.0MB/s   00:00    

sftp> ls -lh 
-rw-------    0 1000     1000         1.2K Sep 23 12:42 anaconda-ks.cfg
sftp> exit
[root@sftp-server ~]# cd /tmp/

[root@sftp-server tmp]# sftp company1@localhost
company1@localhost's password: 
Connected to localhost.

sftp> cd company1

sftp> ls -lh
-rw-------    0 1000     1000         1.2K Sep 23 12:42 anaconda-ks.cfg

sftp> get anaconda-ks.cfg 
Fetching /company1/anaconda-ks.cfg to anaconda-ks.cfg
/company1/anaconda-ks.cfg                                                                                                                               100% 1266     1.3MB/s   00:00    

sftp> !ls -lh /tmp/anaconda-ks.cfg
-rw-------. 1 root root 1.3K Sep 23 12:44 /tmp/anaconda-ks.cfg


- Testing upload and download for 'rouser1':

Upload is not working as it is read-only-user

[root@sftp-server tmp]# sftp rouser1@localhost
rouser1@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /

sftp> ls -lh 
drwx------    0 1006     1002           6B Sep 23 12:35 rouser1
drwx------    0 1007     1002           6B Sep 23 12:35 rouser2
drwx------    0 1008     1002           6B Sep 23 12:35 rouser3

sftp> cd rouser1

sftp> !ls
anaconda-ks.cfg  ks-script-51xRrk  systemd-private-2b0f49d01f0d466292863ddd50a5ffae-chronyd.service-tHAMF3  yum.log

sftp> put anaconda-ks.cfg
Uploading anaconda-ks.cfg to /rouser1/anaconda-ks.cfg
remote open("/rouser1/anaconda-ks.cfg"): Permission denied

sftp> exit
[root@sftp-server tmp]# sftp rouser1@localhost
rouser1@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /
sftp> cd /rouser1

sftp> ls -lh
-rw-------    0 1006     0            1.2K Sep 23 12:52 anaconda-ks.cfg

sftp> get anaconda-ks.cfg 
Fetching /rouser1/anaconda-ks.cfg to anaconda-ks.cfg
/rouser1/anaconda-ks.cfg                                                                                                                                100% 1266     1.5MB/s   00:00    

sftp> exit


- Script to add ad remove users "https://github.com/abdurrahman84/BASH-real-examples/blob/master/wesam-script.sh":

#!/bin/bash


#----------
# Functions
#----------

# List Current Groups
func_list_groups() {
  echo ""
  echo "Current Used Groups:"
  echo "--------------------"
  echo "GROUP #1: companies (rw)"
  echo "GROUP #2: nusers (rw)"
  echo "GROUP #3: rousers (ro)"
  echo ""
}
   

# Add User
func_add_user(){
  read -p "Enter username: " USERNAME
  read -p "Enter Group Name: " GROUP_NAME
  echo -n "Enter User Password: " 
  read -s USER_PASSWORD
  grep $USERNAME /etc/passwd 1>/dev/null 2>/dev/null
  if [ $? -eq 0 ]; then
    echo ""
    echo ""
    echo "$USERNAME username is exsit!"
    echo "Exitting..."
    exit 1
  fi
  adduser ${USERNAME} -g $GROUP_NAME -s /sbin/nologin
  echo "$USER_PASSWORD" | passwd --stdin ${USERNAME}
  mkdir -v /sftp/${GROUP_NAME}/${USERNAME}
  chown -v ${USERNAME}:${GROUP_NAME} /sftp/${GROUP_NAME}/${USERNAME}
  chmod -v 700 /sftp/${GROUP_NAME}/${USERNAME}
}


# Delete User
func_del_user() {
  read -p "Enter username: " USERNAME
  grep $USERNAME /etc/passwd 1> /dev/null 2> /dev/null
  if [ $? -ne 0 ]; then
    echo ""
    echo ""
    echo "$USERNAME username is NOT exsit!"
    echo "Exitting..."
    exit 1
  fi
  GROUP_NAME=`groups $USERNAME | cut -d" " -f3`
  userdel -r $USERNAME
  rm -rfv -v /sftp/${GROUP_NAME}/${USERNAME} 
 } 


#----------
# Main Part
#----------

clear # Clear Screen

echo "USER ACTIONS"
echo "------------"
echo "1) Add User"
echo "2) Delete User"
echo ""

read -p "Enter Your Choice: " MENU_CHOICE2
case $MENU_CHOICE2 in
  1)
    func_list_groups
    func_add_user
    ;;
  2)
    func_del_user
    ;;
  *)
    echo "You chose unwisely.";;
esac


- Testing the script:

[root@sftp-server tmp]# ./add_del_user.sh 
USER ACTIONS
------------
1) Add User
2) Delete User

Enter Your Choice: 1

Current Used Groups:
--------------------
GROUP #1: companies (rw)
GROUP #2: nusers (rw)
GROUP #3: rousers (ro)

Enter username: ab
Enter Group Name: rousers
Enter User Password: 
Changing password for user ab.
passwd: all authentication tokens updated successfully.
mkdir: created directory ‘/sftp/rousers/ab’
changed ownership of ‘/sftp/rousers/ab’ from root:root to ab:rousers
mode of ‘/sftp/rousers/ab’ changed from 0755 (rwxr-xr-x) to 0700 (rwx------)
[root@sftp-server tmp]# sftp ab@localhost
ab@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /

sftp> ls -lh
drwx------    0 1009     1002           6B Sep 23 13:12 ab
drwx------    0 1006     1002          29B Sep 23 12:52 rouser1
drwx------    0 1007     1002           6B Sep 23 12:35 rouser2
drwx------    0 1008     1002           6B Sep 23 12:35 rouser3

sftp> cd ab

sftp> !ls
add_del_user.sh  anaconda-ks.cfg  ks-script-51xRrk  systemd-private-2b0f49d01f0d466292863ddd50a5ffae-chronyd.service-tHAMF3  yum.log

sftp> put add_del_user.sh 
Uploading add_del_user.sh to /ab/add_del_user.sh
remote open("/ab/add_del_user.sh"): Permission denied

sftp> exit



Case #2



- I will create three OS groups:

  • companies -> has N number of companies which has read and write  privileges.
  • nusers -> has N number of normal users which has read and write privileges.
  • rousers -> has N number of normal users which has read-only privileges.
for group in companies nusers rousers; do
  groupadd $group
done


- I will create required folders for above groups and set required permissions:

mkdir -pv /sftp/{companies,nusers,rousers}
for dir in companies nusers rousers; do
  chown -v root:root /sftp/${dir}
done


- For demonstration purpose,  Each group of the above groups has the following members:

  • companies: company1, company2 and company3 users. EACH USER WILL NOT EVEN EABLE TO SEE OTHER USER HOME DIR
  • nusers: nuser1, nuser2 and nusers3 users. EACH USER WILL NOT EVEN EABLE TO SEE OTHER USER HOME DIR
  • rousers: rouser1, rouser2 and rouser3 users. EACH USER WILL NOT EVEN EABLE TO SEE OTHER USER HOME DIR
for id in 1 2 3; do
  adduser company${id} -g companies -s /sbin/nologin
  echo "redhat" | passwd --stdin company${id}
  mkdir -v /sftp/companies/company${id}
  chown -v root:root /sftp/companies/company${id}
  chmod -v 755 /sftp/companies/company${id}
  mkdir -v /sftp/companies/company${id}/files
  chown -v company${id}:companies /sftp/companies/company${id}/files
  chmod -v 700 /sftp/companies/company${id}/files
done
for id in 1 2 3; do
  adduser nuser${id} -g nusers -s /sbin/nologin
  echo "redhat" | passwd --stdin nuser${id}
  mkdir -v /sftp/nusers/nuser${id}
  chown -v root:root /sftp/nusers/nuser${id}
  chmod -v 755 /sftp/nusers/nuser${id}
  mkdir -v /sftp/nusers/nuser${id}/files
  chown -v nuser${id}:nusers /sftp/nusers/nuser${id}/files
  chmod -v 700 /sftp/nusers/nuser${id}/files
done
for id in 1 2 3; do
  adduser rouser${id} -g rousers -s /sbin/nologin
  echo "redhat" | passwd --stdin rouser${id}
  mkdir -v /sftp/rousers/rouser${id}
  chown -v root:root /sftp/rousers/rouser${id}
  chmod -v 755 /sftp/rousers/rouser${id}
  mkdir -v /sftp/rousers/rouser${id}/files
  chown -v rouser${id}:rousers /sftp/rousers/rouser${id}/files
  chmod -v 700 /sftp/rousers/rouser${id}/files
done


- Add the following lines to '/etc/ssh/sshd_config' file:

[root@sftp-server ~]# cp -av /etc/ssh/sshd_config /root/orig_files/
‘/etc/ssh/sshd_config’ -> ‘/root/orig_files/sshd_config’
[root@sftp-server ~]# tail -n23 /etc/ssh/sshd_config 
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server

# Companies
Match Group companies
  ChrootDirectory /sftp/companies/%u  # Directory that 'companies' group members will change directory to 
  ForceCommand internal-sftp
  X11Forwarding no
  AllowTcpForwarding no
 
# nusers
Match Group nusers
  ChrootDirectory /sftp/nusers/%u  # Directory that 'nusers' group members will change directory to    
  ForceCommand internal-sftp
  X11Forwarding no
  AllowTcpForwarding no
 
# rousers
Match Group rousers
  ChrootDirectory /sftp/rousers/%u  # Directory that 'rousers' group members will change directory to
  ForceCommand internal-sftp -R  # read-only privileges 
  X11Forwarding no
  AllowTcpForwarding no


- Restart sshd service:

[root@sftp-server ~]# systemctl restart sshd


- Testing upload and download for 'company1':

'company1' will not be able to see 'company2' and 'company3' as before.

[root@sftp-server ~]# sftp company1@localhost
company1@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /

sftp> ls -lh
drwx------    0 1000     1000           6B Sep 23 13:45 files

sftp> cd files/

sftp> ls -lh

sftp> !ls
anaconda-ks.cfg  orig_files

sftp> put anaconda-ks.cfg 
Uploading anaconda-ks.cfg to /files/anaconda-ks.cfg
anaconda-ks.cfg                                                                                                                                         100% 1266     1.7MB/s   00:00    

sftp> ls -lh
-rw-------    0 1000     1000         1.2K Sep 23 13:46 anaconda-ks.cfg

sftp> exit
[root@sftp-server ~]# cd /tmp/

[root@sftp-server tmp]# sftp company1@localhost
company1@localhost's password: 
Connected to localhost.

sftp> pwd
Remote working directory: /

sftp> ls -lh
drwx------    0 1000     1000          29B Sep 23 13:46 files

sftp> cd files/

sftp> ls -lh
-rw-------    0 1000     1000         1.2K Sep 23 13:46 anaconda-ks.cfg

sftp> get anaconda-ks.cfg 
Fetching /files/anaconda-ks.cfg to anaconda-ks.cfg
/files/anaconda-ks.cfg                                                                                                                                  100% 1266     1.4MB/s   00:00    

sftp> exit


- Testing upload and download for 'ruser1':

Upload is not working as it is read-only user.

'rouser1' will not be able to see 'rouser2' and 'rouser3' as before.

[root@sftp-server ~]# sftp rouser1@localhost
rouser1@localhost's password: 
Connected to localhost.
sftp> pwd
Remote working directory: /
sftp> ls -lh 
drwx------    0 1006     1002           6B Sep 23 13:41 files
sftp> cd files/
sftp> ls -lh
sftp> !ls -lh
total 4.0K
-rw-------. 1 root root 1.3K Sep 22 17:28 anaconda-ks.cfg
drwxr-xr-x. 2 root root   25 Sep 23 13:42 orig_files
sftp> put anaconda-ks.cfg 
Uploading anaconda-ks.cfg to /files/anaconda-ks.cfg
remote open("/files/anaconda-ks.cfg"): Permission denied
sftp> ls -lh 
sftp> exit

Friday, 26 February 2016

RH134 - CH13 - Selecting a boot target

1. Reset 'server0':
[root@foundation0 ~]# rht-vmctl reset server
2. Configure 'server0' to boot into 'multi-user' target without rebooting:
[root@server0 ~]# systemctl --help | grep isolate
  isolate [NAME]                  Start one unit and stop all others
[root@server0 ~]# systemctl list-units --type=target
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Encrypted Volumes
getty.target        loaded active active Login Prompts
graphical.target    loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
nfs.target          loaded active active Network File System Server
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

16 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@server0 ~]# systemctl isolate multi-user.target

RH134 - CH13 - Controlling and Troubleshooting RHEL boot process

1. RHEL 7 booting process. -> page 266, 277

2. To Poweroff machine or reboot it:
[root@server0 ~]# systemctl poweroff
[root@server0 ~]# systemctl reboot

3. 'poweroff' and 'reboot' commands are still there but has symbolic links to the new command 'systemctl':
[root@server0 ~]# ls -lh /sbin/poweroff 
lrwxrwxrwx. 1 root root 16 May  7  2014 /sbin/poweroff -> ../bin/systemctl
[root@server0 ~]# ls -lh /sbin/reboot 
lrwxrwxrwx. 1 root root 16 May  7  2014 /sbin/reboot -> ../bin/systemctl

4. Defenation of 'systemctl halt' as in pager 267:
[root@server0 ~]# systemctl halt
Result:

You can now Poweroff the machine manually:
[root@server0 ~]# ls -lh /sbin/halt 
lrwxrwxrwx. 1 root root 16 May  7  2014 /sbin/halt -> ../bin/systemctl
5. 'systemd target' dfination -> page 267,268
List current active 'systemd target':
[root@server0 ~]# systemctl list-units --type help
Available unit types:
service
socket
target
device
mount
automount
snapshot
timer
swap
path
slice
scope
[root@server0 ~]# systemctl list-units --type=target 
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Encrypted Volumes
getty.target        loaded active active Login Prompts
graphical.target    loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
nfs.target          loaded active active Network File System Server
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

16 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

You can found it also in '/etc/systemd/system' dir:
root@server0 ~]# ls -lh /etc/systemd/system
total 12K
drwxr-xr-x. 2 root root   54 Jul 11  2014 basic.target.wants
drwxr-xr-x. 2 root root   30 Jul 11  2014 bluetooth.target.wants
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service
lrwxrwxrwx. 1 root root   44 May  7  2014 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx. 1 root root   44 Jul 11  2014 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx. 1 root root   46 May  7  2014 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root   57 May  7  2014 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx. 1 root root   40 Jul 11  2014 default.target -> /usr/lib/systemd/system/graphical.target
drwxr-xr-x. 2 root root   85 May  7  2014 default.target.wants
lrwxrwxrwx. 1 root root   35 Jul 11  2014 display-manager.service -> /usr/lib/systemd/system/gdm.service
drwxr-xr-x. 2 root root   31 May  7  2014 getty.target.wants
drwxr-xr-x. 2 root root   63 Jul 11  2014 graphical.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 multi-user.target.wants
drwxr-xr-x. 2 root root   29 May  7  2014 nfs.target.wants
drwxr-xr-x. 2 root root   25 Jul 11  2014 printer.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sockets.target.wants
drwxr-xr-x. 2 root root   35 Jul 11  2014 spice-vdagentd.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sysinit.target.wants
drwxr-xr-x. 2 root root   83 Jul 11  2014 system-update.target.wants
lrwxrwxrwx. 1 root root    9 May  7  2014 tmp.mount -> /dev/null

List all 'systemd target':
[root@server0 ~]# systemctl list-units --type=target --all
UNIT                   LOAD   ACTIVE   SUB    DESCRIPTION
basic.target           loaded active   active Basic System
cryptsetup.target      loaded active   active Encrypted Volumes
emergency.target       loaded inactive dead   Emergency Mode
final.target           loaded inactive dead   Final Step
getty.target           loaded active   active Login Prompts
graphical.target       loaded active   active Graphical Interface
local-fs-pre.target    loaded active   active Local File Systems (Pre)
local-fs.target        loaded active   active Local File Systems
multi-user.target      loaded active   active Multi-User System
network-online.target  loaded inactive dead   Network is Online
network.target         loaded active   active Network
nfs.target             loaded active   active Network File System Server
nss-lookup.target      loaded inactive dead   Host and Network Name Lookups
nss-user-lookup.target loaded inactive dead   User and Group Name Lookups
paths.target           loaded active   active Paths
remote-fs-pre.target   loaded inactive dead   Remote File Systems (Pre)
remote-fs.target       loaded active   active Remote File Systems
rescue.target          loaded inactive dead   Rescue Mode
shutdown.target        loaded inactive dead   Shutdown
slices.target          loaded active   active Slices
sockets.target         loaded active   active Sockets
swap.target            loaded active   active Swap
sysinit.target         loaded active   active System Initialization
syslog.target          not-found inactive dead   syslog.target
time-sync.target       loaded inactive dead   System Time Synchronized
timers.target          loaded active   active Timers
umount.target          loaded inactive dead   Unmount All Filesystems

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

27 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

IMPORTANT:
Main'systemd target' defination can be found in
[root@server0 ~]# man systemd.special
[root@server0 ~]# man systemd.target
To be reviewed:
[root@server0 ~]# systemctl list-unit-files --type=target 
[root@server0 ~]# systemctl list-unit-files --type=target --all

6. List dependancies of 'systemd target':
[root@server0 ~]# systemctl list-dependencies graphical.target | grep target
graphical.target
└─multi-user.target
  ├─basic.target
  │ ├─paths.target
  │ ├─slices.target
  │ ├─sockets.target
  │ ├─sysinit.target
  │ │ ├─cryptsetup.target
  │ │ ├─local-fs.target
  │ │ └─swap.target
  │ └─timers.target
  ├─getty.target
  ├─nfs.target
  └─remote-fs.target
7. Selecting 'systemd target' at runtime:
Following command is some sort equal to 'init 3':
[root@server0 ~]# systemctl isolate multi-user.target

8. Find default 'systemd target' using 'systemctl get-default' command line or by exploaring '/etc/systemd/system' dir:
[root@server0 ~]# systemctl get-default
graphical.target
[root@server0 ~]# ls -lh /etc/systemd/system
total 12K
drwxr-xr-x. 2 root root   54 Jul 11  2014 basic.target.wants
drwxr-xr-x. 2 root root   30 Jul 11  2014 bluetooth.target.wants
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service
lrwxrwxrwx. 1 root root   44 May  7  2014 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx. 1 root root   44 Jul 11  2014 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx. 1 root root   46 May  7  2014 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root   57 May  7  2014 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx. 1 root root   40 Jul 11  2014 default.target -> /usr/lib/systemd/system/graphical.target
drwxr-xr-x. 2 root root   85 May  7  2014 default.target.wants
lrwxrwxrwx. 1 root root   35 Jul 11  2014 display-manager.service -> /usr/lib/systemd/system/gdm.service
drwxr-xr-x. 2 root root   31 May  7  2014 getty.target.wants
drwxr-xr-x. 2 root root   63 Jul 11  2014 graphical.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 multi-user.target.wants
drwxr-xr-x. 2 root root   29 May  7  2014 nfs.target.wants
drwxr-xr-x. 2 root root   25 Jul 11  2014 printer.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sockets.target.wants
drwxr-xr-x. 2 root root   35 Jul 11  2014 spice-vdagentd.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sysinit.target.wants
drwxr-xr-x. 2 root root   83 Jul 11  2014 system-update.target.wants
lrwxrwxrwx. 1 root root    9 May  7  2014 tmp.mount -> /dev/null

9. Set Default 'systemd target':
[root@server0 ~]# systemctl  get-default
graphical.target
[root@server0 ~]# ls -lh /etc/systemd/system total 12K drwxr-xr-x. 2 root root 54 Jul 11 2014 basic.target.wants drwxr-xr-x. 2 root root 30 Jul 11 2014 bluetooth.target.wants lrwxrwxrwx. 1 root root 41 Jul 11 2014 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service lrwxrwxrwx. 1 root root 41 Jul 11 2014 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service lrwxrwxrwx. 1 root root 44 May 7 2014 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service lrwxrwxrwx. 1 root root 44 Jul 11 2014 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service lrwxrwxrwx. 1 root root 46 May 7 2014 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service lrwxrwxrwx. 1 root root 57 May 7 2014 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service lrwxrwxrwx. 1 root root 40 Jul 11 2014 default.target -> /usr/lib/systemd/system/graphical.target drwxr-xr-x. 2 root root 85 May 7 2014 default.target.wants lrwxrwxrwx. 1 root root 35 Jul 11 2014 display-manager.service -> /usr/lib/systemd/system/gdm.service drwxr-xr-x. 2 root root 31 May 7 2014 getty.target.wants drwxr-xr-x. 2 root root 63 Jul 11 2014 graphical.target.wants drwxr-xr-x. 2 root root 4.0K Jul 11 2014 multi-user.target.wants drwxr-xr-x. 2 root root 29 May 7 2014 nfs.target.wants drwxr-xr-x. 2 root root 25 Jul 11 2014 printer.target.wants drwxr-xr-x. 2 root root 4.0K Jul 11 2014 sockets.target.wants drwxr-xr-x. 2 root root 35 Jul 11 2014 spice-vdagentd.target.wants drwxr-xr-x. 2 root root 4.0K Jul 11 2014 sysinit.target.wants drwxr-xr-x. 2 root root 83 Jul 11 2014 system-update.target.wants lrwxrwxrwx. 1 root root 9 May 7 2014 tmp.mount -> /dev/null [root@server0 ~]# systemctl list-units --type=target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cryptsetup.target loaded active active Encrypted Volumes getty.target loaded active active Login Prompts local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network.target loaded active active Network nfs.target loaded active active Network File System Server paths.target loaded active active Paths remote-fs.target loaded active active Remote File Systems slices.target loaded active active Slices sockets.target loaded active active Sockets swap.target loaded active active Swap sysinit.target loaded active active System Initialization timers.target loaded active active Timers LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 15 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
[root@server0 ~]# systemctl set-default multi-user.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
[root@server0 ~]# systemctl  get-default
multi-user.target
[root@server0 ~]# ls -lh /etc/systemd/system
total 12K
drwxr-xr-x. 2 root root   54 Jul 11  2014 basic.target.wants
drwxr-xr-x. 2 root root   30 Jul 11  2014 bluetooth.target.wants
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx. 1 root root   41 Jul 11  2014 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service
lrwxrwxrwx. 1 root root   44 May  7  2014 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx. 1 root root   44 Jul 11  2014 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx. 1 root root   46 May  7  2014 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root   57 May  7  2014 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx. 1 root root   41 Feb 25 06:29 default.target -> /usr/lib/systemd/system/multi-user.target
drwxr-xr-x. 2 root root   85 May  7  2014 default.target.wants
lrwxrwxrwx. 1 root root   35 Jul 11  2014 display-manager.service -> /usr/lib/systemd/system/gdm.service
drwxr-xr-x. 2 root root   31 May  7  2014 getty.target.wants
drwxr-xr-x. 2 root root   63 Jul 11  2014 graphical.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 multi-user.target.wants
drwxr-xr-x. 2 root root   29 May  7  2014 nfs.target.wants
drwxr-xr-x. 2 root root   25 Jul 11  2014 printer.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sockets.target.wants
drwxr-xr-x. 2 root root   35 Jul 11  2014 spice-vdagentd.target.wants
drwxr-xr-x. 2 root root 4.0K Jul 11  2014 sysinit.target.wants
drwxr-xr-x. 2 root root   83 Jul 11  2014 system-update.target.wants
lrwxrwxrwx. 1 root root    9 May  7  2014 tmp.mount -> /dev/null

To be reviewd: 
==========
1. 'info grub2', 'man sulogin', 'man dracut.bootup' -> page 69 
2. 'man bootup' -> important.