Last active
June 5, 2020 16:51
-
-
Save frytaz/06136ad473b2b056da68a835128417b1 to your computer and use it in GitHub Desktop.
Reload hard disk on linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Use ./reload_device.sh sdX | |
| DEVICE=$1 | |
| HOST=$(ls -la /sys/block/$DEVICE/device | cut -d'/' -f8 | cut -d':' -f1) | |
| echo "Deleting device: $DEVICE on host: $HOST" | |
| echo 1 > /sys/block/$DEVICE/device/delete | |
| echo "Sleep 5....." | |
| sleep 1 | |
| echo "Sleep 4...." | |
| sleep 1 | |
| echo "Sleep 3..." | |
| sleep 1 | |
| echo "Sleep 2.." | |
| sleep 1 | |
| echo "Sleep 1." | |
| sleep 1 | |
| echo "Rescanning host: $HOST" | |
| echo "- - -" > /sys/class/scsi_host/host$HOST/scan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment