I hate it when I have a disk that needs to be removed while the system is still active. If you are sick of having to reboot to remove devices, look no further! Brainstormes U to the rescue!
From the CLI (where all Linux and Unix administration REALLY happens) execute the following:
echo 1 > /block/sys/<devicename>/device/delete
So if you had a disk /dev/sdb that was either a LUN you want to delete, or an attached device (SATA,SAS,IDE,yo mamma) by issuing the command
echo 1 > /block/sys/sdb/device/delete
You will have successfully removed it from the kernel and can unplug, deattach, throw out on its butt, the device in question, all without a reboot.
Ok, I'll take it to the next step and reverse the process:
To add a device on any bus (SATA,SAS,FC-HBA,iSCSI) the reverse is true...with some modifications:
echo "- - -" >/sys/class/scsi_host/host$NUMBER/scan
Where host$NUMBER is the number of the bus you want to scan. (The "- - -" means to look at every channel, every target, and every lun on that host). After you finish, check dmesg for your new device and BAM! You've successfully hotplugged a new LUN,SATA disk, SAS disk, USB disk
Peace!
Share on Facebook
