Wednesday, 18 December 2013

Remove LUN from Linux and PowerPath

If you want to remove LUN from Linux this is the procedure. Just to mention I am running SLES 11.1 x64 and for communication with storage I use PowerPath.
First list your powerpath devices.

#powermt display dev=all

This will list all powerpath devices. For one device it will look like this:

Pseudo name=emcpowern
CLARiiON ID=xxxxxxxxxxxx [XY]
Logical device ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [XY]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0;
Owner: default=SP A, current=SP A       Array failover mode: 4
--------------- Host ---------------   - Stor -   -- I/O Path --  -- Stats ---
###  HW Path               I/O Paths    Interf.   Mode    State   Q-IOs Errors

   0 lpfc                     sdba      SP A0     active  alive       0      0
   0 lpfc                     sdbb      SP B0     active  alive       0      0
   1 lpfc                     sdbc      SP A2     active  alive       0      0
   1 lpfc                     sdbd      SP B2     active  alive       0      0

From here you have all information you need for save removal LUN called XY from system.
First you have to remove LUN from powerpath.

#powermt remove hba=all dev=emcpowern

This will remove LUN XY from powerpath. In /var/log/messages you will have this

EMCPP: emcpAudit: Info: cmd=powermt: remove class=all dev=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (user ID real=0 effective=0)

So we have removed LUN from powerpath.
If you want your system to be "clean" from unused scsci block devices then you should remove scsi block devices that were associated with removed LUN.

#cd /sys/block/sdba/device

if you list content of this folder you will see delete file.

#echo 1 > delete

will delete sdba scsi block device from system.

To release emcpowern block device do this

# powermt release

If you don't release emcpower (in are case emcpowern) block device, next time when you add new LUN it wont't use letter r because system see that emcpowerr device as used. It will have letter o.
You should repeat this step for rest of scsi block devices associating with removed LUN.

And that's it! :)

No comments: