SCSI – Adding and Removing Disk, Without Reboot..
Many aeons ago, I used to have SCSI disks on my ancient Linux systems, but the only SCSI device I attached nowadays was the LTO Tape drive, for full system backups, very occasionally.. Now, I have the HP RX2600 IA64 system, with nothing but U320 SCSI LVD disks, and needed to find a way of attaching one to my x86_64 system temporarily, to backup/(re)install the root filesystem, during testing..
The physical attachment is via an LVD/68-pin adapter, connected to the main SCSI cable, with an external 12v power supply. I remembered to connect the disk directly, after disconnecting the LTO drive..
I used to use the old ‘rescan-scsi-bus.sh’ script, but that no longer worked, and I found a useful article on an alternative method, here: https://geekpeek.net/rescan-scsi-bus-on-linux-system/ This suggested running the command on every scsi hostID, but that seemed a bit of a waste, so I worked out a simpler solution..
First, find the PCI bus ID of the SCSI adapter card (Adaptec, in my case) using # lspci:
.…………………
03:04.0 SCSI storage controller: Adaptec ASC-29320ALP U320 (rev 10)
…………………
Then, look for the same PCI bus id (03:04:0, in this case) after entering # ls /sys/class/scsi_host -l:
………………..
lrwxrwxrwx 1 root root 0 Dec 23 14:33 host14 -> ../../devices/pci0000:00/0000:00:06.0/0000:02:00.0/0000:03:04.0/host14/scsi_host/host14
……………….
This gives you the hostID for the SCSI adapter (host14, in this example)
Then – as per the article – just enter # echo “- – -” > /sys/class/scsi_host/host14/scan
— and this will find and attach the disk..
# lsscsi [0:0:0:0] disk ATA WDC WD20EZRZ-00Z 0A80 /dev/sda [1:0:0:0] disk ATA WDC WD1001FALS-0 0K05 /dev/sdb [2:0:0:0] disk ATA WDC WD1001FALS-0 0K05 /dev/sdc [3:0:0:0] disk ATA WDC WD1001FALS-0 0K05 /dev/sdd [4:0:0:0] disk ATA WDC WD1001FALS-0 0K05 /dev/sde [5:0:0:0] disk ATA WDC WD1001FALS-0 0K05 /dev/sdf [6:0:0:0] disk ATA WDC WD20EARX-00P AB51 /dev/sdg [7:0:0:0] disk ATA WDC WD20EARX-00P AB51 /dev/sdh [13:0:0:0] process Marvell 91xx Config 1.01 - [14:0:9:0] disk COMPAQ BF07288285 HPB2 /dev/sdi
To detach the disk, enter # echo 1 > /sys/block/sdi/device/delete – where sdi is the SCSI disk ID from the lsscsi example above ..
Tested, and works successfully, on Kernel 4.14.8, Fedora 27.
Robert Gadsdon December 22, 2017.
Comments
SCSI – Adding and Removing Disk, Without Reboot.. — No Comments