22.4 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

How to remove a SAN disk or Storage device (LUN) from Linux server

In this tutorial  i will help you to remove LUN  safely  from a running system , This method should work on All Redhat based systems  5 6 or 7,   with  command multipath -ll you can all  details about  your Luns and storage configuration

The ouput of multipath  -ll

#multipath -ll
oradata03 (360050768018085dc7000000000000xxx) dm-8 IBM ,2145
size=500G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 1:0:0:4 sde 8:64 active ready running
| `- 8:0:0:4 sdu 65:64 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
|- 1:0:1:4 sdm 8:192 active ready running
`- 8:0:1:4 sdac 65:192 active ready running

- Advertisement -

 

How to  remove LUN from Live Server ?

Step 1: Unmounting  the LUN :

First, we need to unmount the file system we are about to release.

umount /dev/mapper/oradata03

Once unmount the filesystem  now lets remove the related  Logical volume, Volume group and Physical volume.

# fdisk -l /dev/mapper/oradata03

Disk /dev/mapper/oradata03: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disk label type: dos
Disk identifier: 0x77e6d4cb

Device Boot Start End Blocks Id System
/dev/mapper/oradata03p1 2048 1048575999 524286976 83 Linux

Now with fdisk you can delete the  partitions .

#fdisk /dev/mapper/oradata03
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/mapper/oradata03: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disk label type: dos
Disk identifier: 0x77e6d4cb

Device Boot Start End Blocks Id System
/dev/mapper/oradata03p1 2048 1048575999 524286976 83 Linux

Delete the Partition oradata03p1

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# partprobe /dev/mapper/oradata03

 

Now lets  clear the Alias information from multipath.conf.

Step 2: Removing disks from the multipath config

Delete  entries from multipath configuration file  under alias and blacklist exceptions.

# vi /etc/multipath.conf

multipaths {
multipath {
wwid 360050768018085dc7000000000000xxx
alias oradata03
}
}
blacklist_exceptions {
        
        wwid "360050768018085dc7000000000000xx"
       

}

 

Ahead we need to remove from the wwids file by editing or using the “multipath -w” command.

# vi /etc/multipath/wwids
# multipath -w 360050768018085dc7000000000000xxx
wwid '360050768018085dc7000000000000xxx' removed

Explain -w options ( multipath -help) :

-w remove a device from the wwids file

Flush the DM device name using -f option.  from above command my dm was  dm-8

# multipath -ll
# multipath -f dm-8e

Steps 3: Removing SAN paths .

Remove the device paths , from the  first command of multipath -ll   you see  that   my  devices paths  are   sde sdu  sdm sdac

Remove the devices got from “multipath -ll” or can find the device name from below location.

# ls -lthr /dev/disk/by-id/*xxx  ( to  get  more  information) 
# echo 1 > /sys/block/sde/device/delete
# echo 1 > /sys/block/sdu/device/delete
# echo 1 > /sys/block/sdm/device/delete
# echo 1 > /sys/block/sdac/device/delete

This will remove the Storage device (LUN) from RHEL, CentOS, Oracle Servers and variants.
Conclusion:

If you are using this lun for ASM disks  please also delete the configuration from udev rules  and  reload  the configuration

Edit  udev rules under “/etc/udev/rules.d/”

Then reload the  rules

 udevadm control --reload-rules && udevadm trigger

Thank you for your visit . Please let us know if this working for you

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article