Linux rescan scsi bus

Linux SCSI/SATA bus rescan

Подключив «по-горячему» еще один SATA винт, не обнаружил автоматического его подхвата системой, как это происходит когда подключаешь по USB. Переходник SATA-USB, как на зло, остался дома…

Машинка же была занята выполнением производственных задач и перегружать ее было бы очень и очень болезненно. Система — убунта 9.04, думаю что должно работать для всех 2.6.* ядер.
Linux ws10.dom 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 18:40:08 UTC 2009 i686 GNU/Linux

В FreeBSD есть такая замечательная штука как atacontrol которой можно заставить реинициализироваться контроллер. В линуксе такой полезной утилиты не обнаружил…
Но порыскав на просторах инета нашел следующее:
#find /sys -name scan
/sys/devices/pci0000:00/0000:00:06.0/host4/scsi_host/host4/scan
/sys/devices/pci0000:00/0000:00:06.0/host5/scsi_host/host5/scan
/sys/devices/pci0000:00/0000:00:08.0/host0/scsi_host/host0/scan
/sys/devices/pci0000:00/0000:00:08.0/host1/scsi_host/host1/scan
/sys/devices/pci0000:00/0000:00:08.1/host2/scsi_host/host2/scan
/sys/devices/pci0000:00/0000:00:08.1/host3/scsi_host/host3/scan

смотрим что есть из подключенного
#dmesg | grep ata
[ 1.801457] ata1: SATA max UDMA/133 cmd 0xe400 ctl 0xe080 bmdma 0xd880 irq 15
[ 1.801459] ata2: SATA max UDMA/133 cmd 0xe000 ctl 0xdc00 bmdma 0xd888 irq 15
[ 2.268032] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[ 2.276290] ata1.00: ATA-7: Hitachi HDS721612PLA380, P23OABEA, max UDMA/133
[ 2.276292] ata1.00: 234441648 sectors, multi 16: LBA48 NCQ (depth 0/32)
[ 2.292298] ata1.00: configured for UDMA/133
[ 2.697111] ata3: SATA max UDMA/133 cmd 0xd800 ctl 0xd480 bmdma 0xd000 irq 5
[ 2.697113] ata4: SATA max UDMA/133 cmd 0xd400 ctl 0xd080 bmdma 0xd008 irq 5
[ 3.338805] ata5: PATA max UDMA/133 cmd 0x1f0 ctl 0x3f6 bmdma 0xffa0 irq 14
[ 3.338807] ata6: PATA max UDMA/133 cmd 0x170 ctl 0x376 bmdma 0xffa8 irq 15

Из чего следует, что 5,6 — параллельные и точно не наши, а на 1м живет основной диск.
Значит «пробуем» 2,3,4 порт
#echo ‘- — -‘ > /sys/class/scsi_host/host2/scan
#echo ‘- — -‘ > /sys/class/scsi_host/host3/scan
#echo ‘- — -‘ > /sys/class/scsi_host/host4/scan

Получаем в /var/log/mesages
[114471.168196] ata4: SError: < PHYRdyChg CommWake >
[114471.884034] ata4: soft resetting link
[114472.040055] ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[114472.048259] ata4.00: ATA-7: WDC WD800JD-00LSA0, 06.01D06, max UDMA/133
[114472.048264] ata4.00: 156301488 sectors, multi 0: LBA48
[114472.058191] ata4.00: configured for UDMA/133
[114472.058205] ata4: EH complete
[114472.059257] scsi 3:0:0:0: Direct-Access ATA WDC WD800JD-00LS 06.0 PQ: 0 ANSI: 5

Диск обнаружен на 4м порту, готов к употреблению. Монтируем стандартными средствами системы.

UPD: 18.11.2009 — для PATA СД-драйва такой способ не прокатил

Источник

How to Scan/Detect New LUNs on Linux

When you are running RedHat Enterprise Linux 5, 6, and 7 series system with DM-Multipath and the software iSCSI initiator, you can discover new LUNs by rescanning the iSCSI service on the host.

Rescanning the service will display all the newly created LUNs that have been mapped to the host. In this tutorial I will show commands to scan and detect (outputs to check) new luns attached to the Centos/RHEL server.

To scan new FC LUNS and SCSI disks in Linux, you can use the echo script command for a manual scan that doesn’t require a system reboot. But, from 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.

Читайте также:  Gma 3600 linux mint

Check the number of attached disks

You use the below commands to identify existing LUNs and how to add newly mapped LUNs to Linux.

You can use the following command to have better output of all the disks

1) Using /sys class file

You can use the echo command to scan each scsi host device as below. Now to rescan the bus, use the following command

The three dash («- — -«) of the command act as wildcards meaning rescan everything. Remember that the three values normally stand for channel, SCSI target ID, and LUN.

  • h is the HBA number
  • c is the channel on the HBA
  • t is the SCSI target ID
  • l is the LUN.

If you don’t have the host bus number, you must list all the existing host bus number on your system with the command

Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means

It may look like very simple as we perform this operation but the system has much work to do in the background when you execute storage scanning commands.

Method to find Channel Routes

If we know the channel, target ID and LUN address, we can scan using that. Here, we have 4 HBA emulex cards 0, 1, 2 and 3.

Through card 0 and 2,

It has the same WWNN (World Wide Node Name) for all the 4 WWPN (World Wide Port Name).

We can do a depth research by filtering the WWPN (World Wide Port Name) to have more information

This indicates there are four Fibre Channel routes to this target.

So now, you can scan for LUNs as follows and addresss «8» is given by storage team.

The output of SCSI file is illustrated for your reference:

Another Method

If you don’t have the host bus number, you must list all the existing host bus number on your system with the command

On the output, host0 is the relevant field. As we have said earlier, we need to have the host bus number to determine what to scan

Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means

If you have too many hosts (from host0 to host20 for example), you can use the command below

or you can try (this one for Fibre Channel)

# for host in `ls /sys/class/fc_host/`; do
echo «1» >/sys/class/fc_host/$/issue_lip;
done

Can devices be rescanned in Linux OS without reloading the Linux driver?

There is a procedure which forces the driver to rescan the targets and to allow a new device which is to be added. This triggers the driver to initiate a LUN discovery process.

To force a rescan from the command line, type the following command:

# echo «scsi-qlascan» > /proc/scsi//

— = qla2100, qla2200, qla2300 (2.4 kernel drivers) or qla2xxx (2.6 kernel drivers)
— = the instance number of the HBA

After executing this command, force the SCSI mid layer to do its own scan and build the device table entry for the new device by typing the following command:

# echo «scsi add-single-device 0 1 2 3» >/proc/scsi/scsi

— «0 1 2 3» = your «Host Channel ID LUN»

The scanning must be done in the above-mentioned order; first the driver (qla2300/qla2200 driver, etc.) and then the Linux SCSI mid-layer (i.e. OS scan).

2) Scan lun with multipath/powermt

You can check current multipath setup using multipath or powermt command.

If EMC powerpath is installed, check the disk/multipath status as below:

Multipath daemon will automatically add attached devices if it’s configured properly. For powermt, we need to run below command manually.

Читайте также:  Linux php fpm install

3) Using Script

You can rescan using the SCSI rescan script which will detect new luns and add it to your server automatically. You can find this script in sg3_utils package.

Conclusion

For storage (Netapp,equallogic) that use iscsi target, command iscsiadm -m session —rescan could be used to rescan when new lun added to the target. I would recommend always to use vendor-specific script or tools to scan Luns.

I hope you have enjoyed reading and let us know if you found any other method to scan storage disk devices.

Источник

🐧 Как сканировать / обнаруживать новые LUN и SCSI-диски на Linux

Когда система Linux подключена к SAN (Storage Area Network), вам необходимо повторно просканировать службу iSCSI, чтобы обнаружить новые LUN.

Для этого вы должны предоставить группе хранения данных номер WWN хоста Linux и требуемый размер LUN.

После того, как группа хранения сопоставит LUN с заданным хостом Linux, они предоставят вам новые сведения о LUN.

LUN в терминах хранения называется последовательным шестнадцатеричным номером LUN.

Вам необходимо просканировать хост SCSI, чтобы найти новые LUN, назначенные группой хранения.

Это можно сделать двумя способами: сканировать каждое хост-устройство scsi или запустить скрипт rescan-scsi-bus.sh для обнаружения новых дисков.

После сканирования их можно будет найти в каталоге «/dev/disk/by-id».

Кроме того, вы можете найти их с помощью команды Multipath, если они уже настроены с Multipath.

Multipath в основном настраивается на сервере базы данных Oracle для повышения производительности.

Метод 1: Как найти новые LUN и SCSI-диски в Linux с помощью файла класса «/ sys»

Файловая система sysfs – это псевдофайловая система, которая предоставляет интерфейс для структур данных ядра.

Файлы в sysfs предоставляют информацию об устройствах, модулях ядра, файловых системах и других компонентах ядра.

Файловая система sysfs обычно монтируется в «/sys».

Обычно она устанавливается системой автоматически.

Вы можете использовать команду echo для сканирования каждого хост-устройства scsi, как показано ниже.

  • c – Канал на HBA
  • t – целевой идентификатор SCSI
  • l – LUN ID
  • n – номер HBA

Выполните приведенную ниже команду, чтобы найти все номера хост-шины в вашей системе.

Как только вы получите номер хост-шины, выполните следующую команду, чтобы обнаружить новые диски.

Кроме того, их можно просканировать с помощью «цикла for» с помощью одной команды.

Вы можете проверить их с помощью команды ls, как упоминалось в начале статьи.

Метод 2: Как просканировать новые LUN и SCSI-диски в Linux с помощью скрипта

Убедитесь, что вы уже установили пакет «sg3_utils», чтобы использовать этот сценарий. В противном случае выполните следующую команду, чтобы установить его.

Для систем RHEL/CentOS 6/7 используйте команду yum для установки sg3_utils.

Для систем RHEL / CentOS 8 и Fedora используйте команду dnf для установки sg3_utils.

Источник

How to scan new FC LUNS and SCSI disks in Linux ?

How to scan new FC LUNS and SCSI disks in Redhat Linux without rebooting the server? Most of the Linux beginners have to wonder how to do this and this article will be for them. It may look very simple as we perform this in daily operation to scan LUNS but the system has much work to do in the background when you execute storage scanning commands. Redhat says this type of scan can be distributive since it can cause delays while I/O operation timeout and remove devices unexpectedly from OS.

Scanning FC-LUN’s in Redhat Linux

1.First, find out how many disks are visible in “fdisk -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.

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.

Читайте также:  Astra linux install pip

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.

4. Verify if the new LUN is visible or not by counting the available disks.

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.

2. Find out how many SCSI controller configured.

In this case, you need to scan host0,host1 & host2.

3. Scan the SCSI disks using below command.

4. Verify if the new disks are visible or not.

From Redhat Linux 5.4 onwards, Red hat introduced “/usr/bin/rescan-scsi-bus.sh” script to scan all the SCSI bus and update the SCSI layer to reflect new devices.

But most of the time, the script will not be able to scan new disks and you need to go with echo command.

Источник

Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

When you need to add a hard disk or network interface cards on the new VMware virtual machine on the production server, but you are not allowed to shutdown the server or you have several related issues as below. The following quick article shows how to rescan SCSI Bus to add or remove a SCSI Devices on Linux.

This steps may work on CentOS 5/6/7 and RHEL 5/6/7.

  • Is it possible to add or remove a SCSI device without rebooting a running system?
  • Can you scan a SCSI bus for new or missing SCSI devices without rebooting?
  • How can I make newly connected SCSI storage devices available without rebooting?
  • What is the Linux equivalent to the Solaris command devfsadm to add or remove storage devices?
  • I am trying to add a LUN to a live system but it is not recognized
  • I am trying to add a tape drive to a live system but it is not recognized
  • I am trying to add a disk drive to a live system but it is not recognized
  • How can I force a rescan of my SAN to find newly associated LUNs?
  • What to do if a newly allocated LUN on my SAN is not available?
  • Unable to probe for a newly allocated LUN
  • Some nodes can’t see my new storage device, how can I make it available?
  • After SAN maintenance activity, not all devices returned – devices in multipath missing or remain in failed state.
  • After SAN failover testing completed, not all devices returned to running state as expected – devices in multipath missing or remain in failed state.
  • What is the best way to remove a SCSI disk from the system

After Red Hat Enterprise Linux 5.0 (RHEL 5) and above (RHEL 6 and RHEL 7), it is possible to make changes to the SCSI I/O subsystem without rebooting.

How to Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

1. Identify host bus number :

2. Rescan the SCSI Bus to Add a SCSI Devices :

Reference :

There are two ways to add user into existing group which are useradd and usermod.…

When you installing CentOS, game also included in the the Operating system. Apart from the…

In this post i will show on how to add the RPMforge repository into CentOS…

Iptables is used to set up, maintain, and inspect the tables of IPv4 packet filter…

This article covers the steps on how to uninstall or remove webmin software on linux…

Источник

Оцените статью