Skip to content

Instantly share code, notes, and snippets.

@lifeblood
Forked from rafaelfoster/rescan.sh
Created May 16, 2023 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifeblood/b7956255a119f0541ad489918b4068ab to your computer and use it in GitHub Desktop.
Save lifeblood/b7956255a119f0541ad489918b4068ab to your computer and use it in GitHub Desktop.
Rescan the devices (can detect new space when disk is resized OR new devices that were attached)
# Reference: http://blog.gurudelleccelsopicco.org/2009/09/online-lun-expansion-and-partition-resizing-without-reboot-under-linux/
echo 1 > /sys/block/[DEVICE]/device/rescan
# DETECT IF NEW DISKS ARE ATTACHED TO THE HOST
# Reference: http://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html
ls /sys/class/scsi_host
# Output:
# host0 host1 ...
# Now type the following to send a rescan request:
echo "- - -" > /sys/class/scsi_host/host0/scan
fdisk -l
# OR
ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment