Remove a deleted virtual disk LUN on a Linux system (MD3000i SAN array)

When you delete a Virtual Disk on a MD3000i array, that was previously used by a Linux system, the device is not removed from the system, and Linux will still try to access it (if you use LVM for example, you’ll see lots of errors while the system scans the disks to identify PVs). This can be very inconvenient if you reassign a previously assigned LUN, as the system won’t detect the new parameters of the device.
I did not find a command similar to hot_add (used to detect new devices) to automatically remove deleted disks.

By trial and error, though, I understood that you can delete a scsi device with this method:
echo "1" > /sys/class/scsi_device/adapter:bus:target:lun/device/delete

I also wrote a small script that will try and guess the paths to your devices, when you tell it the LUN number you just deleted on the SAN array :
md300i_delete_lun bash script
Warning: this script comes with no guarantee and I won’t take any responsibility if you try to use it :-). I could just test it on two RHEL 5.3 systems, and I don’t know if it will work anywhere else. Since it can be a little bit dangerous, it won’t actually delete anything, just tell you what commands you could use to delete the devices. At your own risk. 🙂

Leave a Reply