- 🐧 Как сканировать / обнаруживать новые LUN и SCSI-диски на Linux
- Метод 1: Как найти новые LUN и SCSI-диски в Linux с помощью файла класса «/ sys»
- Метод 2: Как просканировать новые LUN и SCSI-диски в Linux с помощью скрипта
- How to Scan/Detect New LUNs on Linux
- Check the number of attached disks
- 1) Using /sys class file
- Method to find Channel Routes
- Another Method
- 2) Scan lun with multipath/powermt
- 3) Using Script
- Conclusion
- How to rescan disk in Linux after extending VMware disk
- Step 1:
- Step 2:
- Step 3:
- Step 4:
- Linux SCSI/SATA bus rescan
🐧 Как сканировать / обнаруживать новые 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/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.
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/$
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.
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.
Источник
How to rescan disk in Linux after extending VMware disk
Published: June 23, 2017 | Modified: June 24, 2020
Learn to rescan disk in Linux VM when its backed vdisk in VMware is extended. This method does not require downtime and no data loss.
Sometimes we get a disk utilization situations and needs to increase disk space. In the VMware environment, this can be done on the fly at VMware level. VM assigned disk can be increased in size without any downtime. But, you need to take care of increasing space at OS level within VM. In such a scenario we often think, how to increase disk size in Linux when VMware disk size is increased? or how to increase mount point size when vdisk size is increased? or steps for expanding LVM partitions in VMware Linux guest? or how to rescan disk when vdisk expanded? We are going to see steps to achieve this without any downtime.
In our example here, we have one disk /dev/sdd assigned to VM of 1GB. It is part of volume group vg01 and mount point /mydrive is carved out of it. Now, we will increase the size of the disk to 2GB at VMware level and then will add up this space in the mount point /mydrive .
If you re using the whole disk in LVM without any fdisk partitioning, then skip step 1 and step 3.
Step 1:
See below fdisk -l output snippet showing disk /dev/sdd of 1GB size. We have created a single primary partition on it /dev/sdd1 which in turn forms vg01 as stated earlier. Always make sure you have data backup in place of the disk you are working on.
Step 2:
Now, change disk size at VMware level. We are increasing it by 1 more GB so the final size is 2GB now. At this stage disk need to be re-scanned in Linux so that kernel identifies this size change. Re-scan disk using below command :
Make sure you use the correct disk name in command (before rescan). You can match your SCSI number (X:X:X:X) with VMware disk using this method.
Note : Sending “– – -” to /sys/class/scsi_host/hostX/scan is scanning SCSI host adapters for new disks on every channel (first -), every target (second -), and every device i.e. disk/lun (third -) i.e. CTD format. This will only help to scan when new devices are attached to the system. It will not help us to re-scan already identified devices.
That’s why we have to send “1” to /sys/class/block/XYZ/device/rescan to respective SCSI block device to refresh device information like the size. So this will be helpful here since our device is already identified by the kernel but we want the kernel to re-read its new size and update itself accordingly.
Now, kernel re-scan disk and fetch its new size. You can see new size is being shown in your fdisk -l output.
Step 3:
At this stage, our kernel know the new size of the disk but our partition ( /dev/sdd1 ) is still of old 1GB size. This left us no choice but to delete this partition and re-create it again with full size. Make a note here your data is safe and make sure your (old & new) partition is marked as Linux LVM using hex code 8e or else your will mess up the whole configuration.
Delete and re-create partition using fdisk console as below:
All fdisk prompt commands are highlighted in the above output. Now you can see the new partition /dev/sdd1 is of 2GB size. But this partition table is not yet written to disk. Use w command at fdisk prompt to write table.
You may see the warning and error like above. If yes, you can use partprobe -s and you should be good. If you still below error with partprobe then you need to reboot your system (which is sad ).
Step 4:
Now rest of the part should be tackled by LVM. You need to resize PV so that LVM identifies this new space. This can be done with pvresize command.
As new PV size is learned by LVM you should see free/extra space available in VG.
You can see our VG now have 2GB space! Now you can use this space to create new lvol in this VG or extend existing lvol using LVM commands. Further you can extend filesystem online which is sitting on logical volumes.
You can observe all lvol in this VG will be unaffected by this activity and data is still there as it was previously.
Источник
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 СД-драйва такой способ не прокатил
Источник