Note that removing a SAN LUN (or disk) is a semi-tedious process that must be followed. Failure to do so will result in your server being left in a funky state. The process varries depending on how you are using your disk.
Using LVM?
For Example: Is the disk part of a Logical Volume and under LVM control? Then shrink the volume group and then remove the disk from the volume group using pvremove.
vgreduce VolGroup <device name from `vgdisplay -v vgname` output>
pvremove <device name from `pvscan` output>
Kpartx & Multipath
Despite its name, its not a KDE-tool for partitioning disks.
Kpartx is a Partition device manager for device-mapper devices that is usually shipped as part of
multipath. Its purpose is to read the partition table of a device or a
file and create device map entries for the individual partitions.
When removing a disk from a system, you will need to remove the partition map of the multipathed device.
kpartx -d /dev/mapper/mpath5 <to remove the /dev/mapper/mpath5p1 device>
multipath -f mpath5 <where mpath5 is the alias for the multipathed device>
See example below:
mpath5 (360060e801004e780052fab2800000064) dm-7 HITACHI,DF600F
[size=1.0G][features=1 queue_if_no_path][hwhandler=0]
\_ round-robin 0 [prio=1][active]
\_ 3:0:0:3 sdj 8:144 [active][ready]
\_ 4:0:0:3 sdh 8:112 [active][ready]
Removing the disk from Linux Control.
This is the most important step, as not doing this part is what will screw up your box.
cd /sys/class/scsi_device
Then cd to the number of the SCSI device, for example 4:0:0:3 is the device id for /dev/sdh then type
echo 1 > device/delete
Excellent doc – made my morning – thank you.
thanks for the aid!
Fantastic article, thanks so much! I’ve added several iSCSI LUNs, but this is the first time I’ve had to remove one.
Again, many thanks!