K
K
krserv2019-01-11 18:51:35
linux
krserv, 2019-01-11 18:51:35

What are the utilities, commands for Linux Fedora hot plugging SATA drives?

The topic was discussed on Habr until 2012:
https://habr.com/post/102387/
now it is not active for adding comments.
I created a topic on one of the forums:
and I'm trying to create and optimize a script:

for Host in $(ls -l /sys/class/scsi_host/);
do echo "- - -" >/sys/class/scsi_host$Host/scan;
done

When scanning, a lot of unnecessary actions are performed, how to write a script that would only check tires with numbers from 0 to 3 (for example)
I have for example:
ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host0 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host1 -> ../../devices/pci0000:00/0000:00:1f.2/ata2/host1/scsi_host/host1
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host2 -> ../../devices/pci0000:00/0000:00:1f.2/ata3/host2/scsi_host/host2
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host3 -> ../../devices/pci0000:00/0000:00:1f.2/ata4/host3/scsi_host/host3
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host4 -> ../../devices/pci0000:00/0000:00:1f.2/ata5/host4/scsi_host/host4
lrwxrwxrwx. 1 root root 0 Jan 11 16:49 host5 -> ../../devices/pci0000:00/0000:00:1f.2/ata6/host5/scsi_host/host5
lrwxrwxrwx. 1 root root 0 Jan 11 13:50 host6 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/ata7/host6/scsi_host/host6
lrwxrwxrwx. 1 root root 0 Jan 11 13:50 host7 -> ../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/ata8/host7/scsi_host/host7
[[email protected] Downloads]#

while running the script:
[[email protected] Downloads]# for Host in $(ls -l /sys/class/scsi_host/);
> do echo "- - -" >/sys/class/scsi_host$Host/scan;
> done
bash: /sys/class/scsi_hosttotal/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost0/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost1/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata2/host1/scsi_host/host1/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost2/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata3/host2/scsi_host/host2/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost3/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata4/host3/scsi_host/host3/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost4/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata5/host4/scsi_host/host4/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host16:49/scan: No such file or directory
bash: /sys/class/scsi_hosthost5/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1f.2/ata6/host5/scsi_host/host5/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host13:50/scan: No such file or directory
bash: /sys/class/scsi_hosthost6/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/ata7/host6/scsi_host/host6/scan: No such file or directory
bash: /sys/class/scsi_hostlrwxrwxrwx./scan: No such file or directory
bash: /sys/class/scsi_host1/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_hostroot/scan: No such file or directory
bash: /sys/class/scsi_host0/scan: No such file or directory
bash: /sys/class/scsi_hostJan/scan: No such file or directory
bash: /sys/class/scsi_host11/scan: No such file or directory
bash: /sys/class/scsi_host13:50/scan: No such file or directory
bash: /sys/class/scsi_hosthost7/scan: No such file or directory
bash: /sys/class/scsi_host->/scan: No such file or directory
bash: /sys/class/scsi_host../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/ata8/host7/scsi_host/host7/scan: No such file or directory
[[email protected] Downloads]#

How to optimize the code?
Commands or utilities ready did not appear to implement these functions?
smartctl - does not scan for connected new devices, because it does not see them.
That is, the only way, as it is written above, is to write and execute a script?
And there is an eject command to turn off the hot-plug device.
maybe something new has appeared for SATA drives?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question