Remove LUN from RHEL 6.5

Posted by ronald on april 29, 2015 in RHEL |

Logon as root

 

First remove LUN from Volume group:

vgreduce /dev/mapper/mpathX

 

Then remove pv signature:

pvremove /dev/mapper/mpathX

 

First remove scsi devices from the multipath device of mpathX.

The following script will display what to remove:

#!/bin/bash
LUN=$1

if [ -L /dev/mapper/$LUN ]
then
multipath -l $LUN | grep -v policy | grep -v size┬á | grep -v “$LUN” | sed “s/.*sd/sd/g” | awk ‘{ print $1 }’ | while read devnode
do
nodeloc=$(lsscsi | grep -w “${devnode}” | awk ‘{ print $1 }’ | tr -d ‘[‘ | tr -d ‘]’)
echo echo 1 \> \”/sys/class/scsi_device/$nodeloc/device/delete\”
done
fi

Example output:

echo 1 > “/sys/class/scsi_device/0:0:1:6/device/delete”
echo 1 > “/sys/class/scsi_device/1:0:1:6/device/delete”
echo 1 > “/sys/class/scsi_device/0:0:0:6/device/delete”
echo 1 > “/sys/class/scsi_device/1:0:0:6/device/delete”

 

Run this output.

After this run:

multipath -F

multipath -r

 

 

 

 

 

Copyright © 2012-2018 Dutch Ronaldo All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.