2

I'm currently developing a program that fetches and validates the information inside 5 SSDs at the same time. My problem is the command I'm using to scan the drives (/sbin/rescan-scsi-bus) takes too long and sometimes freezes my program or the entire computer. So what I'm looking for is a way to scan the SSDs even if I need to change some environment variables or so. I'm using a test board to perform this scan and I've tried other commands like the following:

echo 1 > /sys/block/sdX **with** echo "- - -" | tee /sys/class/scsi_host/host?/scan
/sbin/rescan-scsi-bus --luns=0 --ids=0 --channels=0
/sbin/rescan-scsi-bus       # with other parameters

And a bash command to delete all disks except the one that has the OS mounted.

2
  • your formatting in the question appears messed up. Are echo 1 > /sys/block/sdX and echo "- - -" | tee /sys/class/scsi_host/host?/scan supposed to be two separate commands ? Jun 27, 2017 at 19:37
  • Yes, they are two separate commands, but I ran both commands on the program, I tried first deleting every disk connected to the SCSI port with echo 1 > /sys/block/sdX and then scanning all of them with the echo "- - -" | tee /sys/class/scsi_host/host?/scan command.
    – xedge
    Jun 28, 2017 at 11:48

1 Answer 1

1

I came with a solution to my problem.

Even it's an old kernel command it helped me to resolve wait times and to assure all SSDs are scanned before the validation.

echo 'scsi add-single-device X 0 0 0' > /proc/scsi/scsi

and

echo 'scsi remove-single-device X 0 0 0' > /proc/scsi/scsi

where X is the number of the host I want to mount/unmount, in this specific case, for example for 'ATA1' port host is 0, so it would be:

echo 'scsi add-single-device 0 0 0 0' > /proc/scsi/scsi

and

echo 'scsi remove-single-device 0 0 0 0' > /proc/scsi/scsi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .