На Хабр обсуждалась тема до 2012 года:
https://habr.com/post/102387/
сейчас она не активна для добавления комментариев.
Я создал тему на одном из форумов:
и пытаюсь создать и оптимизировать скрипт:
for Host in $(ls -l /sys/class/scsi_host/);
do echo "- - -" >/sys/class/scsi_host$Host/scan;
done
При сканировании выполняется много лишних действий, как написать скрипт, который бы только проверял шины с номерами с 0 до 3 (например)
У меня например:
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
[root@localhost Downloads]#
а во время выполнения скрипта:
[root@localhost 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
[root@localhost Downloads]#
Как оптимизировать код?
Команд или утилит готовых не появилось для реализации этих функций?
smartctl - не сканирует подключенные новые устройства, т.к не видит их.
Т.е единственный способ как выше написано, скрипт писать и выполнять?
И на выключение для hot-plug device же есть команда eject.
может и для SATA дисков появилось что-то новое?