How to scan new iSCSI disks in Linux ?
How to scan new iSCSI disks in Linux ?
1.First check which are the existing disk available on linux server from fdisk.
[root@Centos7 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/mapper/cl-root: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-swap: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/mapper/cl-usr: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-home: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/cl-var: 5444 MB, 5444206592 bytes, 10633216 sectors
Disk /dev/mapper/cl-tmp: 2147 MB, 2147483648 bytes, 4194304 sectors
2.Find out how many SCSI controller configured.
[root@Centos7 ~]# ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx 1 root root 0 Dec 11 12:09 host0 -> ../../devices/pci0000:00/0000:00:01.1/ata1/host0/scsi_host/host0
lrwxrwxrwx 1 root root 0 Dec 11 12:09 host1 -> ../../devices/pci0000:00/0000:00:01.1/ata2/host1/scsi_host/host1
3.Scan the SCSI disks using below command.
[root@Centos7 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@Centos7 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
4.Verify if the new disks are visible or not and you can see on the last line /dev/sda and /dev/sdb : 5 GB GB and /dev/mapper/mpatha : 5.0 GB which are our new disks detected.
[root@Centos7 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/mapper/cl-root: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-swap: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/mapper/cl-usr: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-home: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/cl-var: 5444 MB, 5444206592 bytes, 10633216 sectors
Disk /dev/mapper/cl-tmp: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/mpatha: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 sectors
[root@Centos7 ~]#
5. Installing-sg3_utils on linux server
[root@Centos7 ~]# yum install sg3_utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: ftp.jaist.ac.jp
* extras: centos.excellmedia.net
* remi-php56: rpms.remirepo.net
* remi-safe: rpms.remirepo.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package sg3_utils.x86_64 0:1.37-12.el7 will be installed
--> Processing Dependency: sg3_utils-libs = 1.37-12.el7 for package: sg3_utils-1.37-12.el7.x86_64
--> Processing Dependency: libsgutils2.so.2()(64bit) for package: sg3_utils-1.37-12.el7.x86_64
--> Running transaction check
---> Package sg3_utils-libs.x86_64 0:1.37-12.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
============================================================================
Installing:
sg3_utils x86_64 1.37-12.el7 base 644 k
Installing for dependencies:
sg3_utils-libs x86_64 1.37-12.el7 base 64 k
Transaction Summary
=============================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 708 k
Installed size: 1.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): sg3_utils-libs-1.37-12.el7.x86_64.rpm | 64 kB 00:00:00
(2/2): sg3_utils-1.37-12.el7.x86_64.rpm | 644 kB 00:00:01
-----------------------------------------------------------------------------------------------
Total 621 kB/s | 708 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : sg3_utils-libs-1.37-12.el7.x86_64 1/2
Installing : sg3_utils-1.37-12.el7.x86_64 2/2
Verifying : sg3_utils-1.37-12.el7.x86_64 1/2
Verifying : sg3_utils-libs-1.37-12.el7.x86_64 2/2
Installed:
sg3_utils.x86_64 0:1.37-12.el7
Dependency Installed:
sg3_utils-libs.x86_64 0:1.37-12.el7
Complete!
[root@Centos7 ~]# sh /usr/bin/rescan-scsi-bus.sh
Scanning SCSI subsystem for new devices
Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning host 1 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning for device 1 0 1 0 ...
OLD: Host: scsi1 Channel: 00 Id: 01 Lun: 00
Vendor: QEMU Model: QEMU DVD-ROM Rev: 0.10
Type: CD-ROM ANSI SCSI revision: 05
Scanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: Sanstorage Model: iSCSI Storage Rev: 4.0
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
0 new or changed device(s) found.
0 remapped or resized device(s) found.
0 device(s) removed.
Note : Redhat Linux 5.4 onwards, redhat introduced /usr/bin/rescan-scsi-bus.sh script to scan all the LUNs and update the SCSI layer to reflect new devices. It is important to know the two methods because most of the time, rescan script can not be available to scan new disks and you will need to go with echo command.
1.First check which are the existing disk available on linux server from fdisk.
[root@Centos7 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/mapper/cl-root: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-swap: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/mapper/cl-usr: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-home: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/cl-var: 5444 MB, 5444206592 bytes, 10633216 sectors
Disk /dev/mapper/cl-tmp: 2147 MB, 2147483648 bytes, 4194304 sectors
2.Find out how many SCSI controller configured.
[root@Centos7 ~]# ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx 1 root root 0 Dec 11 12:09 host0 -> ../../devices/pci0000:00/0000:00:01.1/ata1/host0/scsi_host/host0
lrwxrwxrwx 1 root root 0 Dec 11 12:09 host1 -> ../../devices/pci0000:00/0000:00:01.1/ata2/host1/scsi_host/host1
3.Scan the SCSI disks using below command.
[root@Centos7 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@Centos7 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
4.Verify if the new disks are visible or not and you can see on the last line /dev/sda and /dev/sdb : 5 GB GB and /dev/mapper/mpatha : 5.0 GB which are our new disks detected.
[root@Centos7 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/mapper/cl-root: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-swap: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/mapper/cl-usr: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/cl-home: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/cl-var: 5444 MB, 5444206592 bytes, 10633216 sectors
Disk /dev/mapper/cl-tmp: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/mpatha: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 sectors
[root@Centos7 ~]#
5. Installing-sg3_utils on linux server
[root@Centos7 ~]# yum install sg3_utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: ftp.jaist.ac.jp
* extras: centos.excellmedia.net
* remi-php56: rpms.remirepo.net
* remi-safe: rpms.remirepo.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package sg3_utils.x86_64 0:1.37-12.el7 will be installed
--> Processing Dependency: sg3_utils-libs = 1.37-12.el7 for package: sg3_utils-1.37-12.el7.x86_64
--> Processing Dependency: libsgutils2.so.2()(64bit) for package: sg3_utils-1.37-12.el7.x86_64
--> Running transaction check
---> Package sg3_utils-libs.x86_64 0:1.37-12.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
============================================================================
Installing:
sg3_utils x86_64 1.37-12.el7 base 644 k
Installing for dependencies:
sg3_utils-libs x86_64 1.37-12.el7 base 64 k
Transaction Summary
=============================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 708 k
Installed size: 1.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): sg3_utils-libs-1.37-12.el7.x86_64.rpm | 64 kB 00:00:00
(2/2): sg3_utils-1.37-12.el7.x86_64.rpm | 644 kB 00:00:01
-----------------------------------------------------------------------------------------------
Total 621 kB/s | 708 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : sg3_utils-libs-1.37-12.el7.x86_64 1/2
Installing : sg3_utils-1.37-12.el7.x86_64 2/2
Verifying : sg3_utils-1.37-12.el7.x86_64 1/2
Verifying : sg3_utils-libs-1.37-12.el7.x86_64 2/2
Installed:
sg3_utils.x86_64 0:1.37-12.el7
Dependency Installed:
sg3_utils-libs.x86_64 0:1.37-12.el7
Complete!
[root@Centos7 ~]# sh /usr/bin/rescan-scsi-bus.sh
Scanning SCSI subsystem for new devices
Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning host 1 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning for device 1 0 1 0 ...
OLD: Host: scsi1 Channel: 00 Id: 01 Lun: 00
Vendor: QEMU Model: QEMU DVD-ROM Rev: 0.10
Type: CD-ROM ANSI SCSI revision: 05
Scanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: Sanstorage Model: iSCSI Storage Rev: 4.0
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
0 new or changed device(s) found.
0 remapped or resized device(s) found.
0 device(s) removed.
Comments