1

I'm constantly having to make SAN changes which means that I am also constantly having to rescan the scsi bus so that my various changes are reflected in the machines I've exported disks to.

I've been plauged for some time by various facets of re-scanning disks in Linux.

Not to give Microsoft Credit, but they have really simplified the process into a single command which does everything and a lot faster than their linux counterparts.

I've been using the rescan-scsi-bus.sh command for quite some time now. However, the rescan-scsi-bus.sh command usually needs to be ran several times depending on what changes were made. IE. If a path was removed, I need to run "rescan-scsi-bus.sh -f -a -r -m". However, this command will not scan the disks for re-mapped disks nor will it scan for resized disks. In order to get the same functionality out of rescan-scsi-bus.sh, I end up having to run the command multiple times in succession which can end up taking lots of time (With lots of disks, 5 minutes or so which is years longer than windows takes.) Example:

# If the disk was removed.. Even though we aren't syncing, rescan can still hang
# unless we remove the disks first.
rescan-scsi-bus.sh --nosync -f -a -r -m 
# Next, We scan for new disks.. Don't know why the last command can't do it at the same time..
rescan-scsi-bus.sh -a
# Look for remapped disks.
rescan-scsi-bus.sh --nosync -a -u
# Look for resized disks.. Once again.. We have to go through the entire list which can take a good O'l 1 minute.
rescan-scsi-bus.sh --nosync -a -s

The question is, is there a better policy to re-scanning disks rather than running a gambit of rescan-scsi-bus.sh commands?

The requirement here is a single command which removes disks and disk paths which have been removed, adds disks and paths which are new, updates drives which have been remapped somewhere else, picks up changes in drives that have new sizes and runs in a reasonable amount of time (0-30 seconds) on ANY linux distribution regardless of the amount of disks or level of IO load the system is under.

I could go back to echoing values into sysfs, but that kind of defeats the whole make it simple and have a single command which runs that does it all in a timely fashion.

0

You can use any of the below methods

iscsiadm -m session --rescan
iscsiadm -m session -r SID --rescan

When Adding disk

echo "- - -" > /sys/class/scsi_host/hostX/scan

When expending existing disk

echo 1 > /sys/class/scsi_device/device/rescan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.