Today we will learn how to Remove a SAN Disk or Storage Device ( LUN ) from a Linux Server. In this tutorial I will help you to safely remove LUNs from a running system, this method will work on all Redhat-based systems 5 6, or 7, with the command multipath -ll you can give all the details about your Luns and storage configuration.
The output 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

How to remove LUN from Live Server?
Unmounting the LUN :
First, we need to unmount the filesystem we are going to expose.
umount /dev/mapper/oradata03
After unmounting the filesystem let’s now remove the associated logical volumes, volume groups, and physical volumes.
# 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 let’s clear the alias information from multipath.conf.
Removing a disk from a multipath configuration
Delete the entry from the multipath configuration file under aliases and blacklist exceptions.
# vi /etc/multipath.conf
multipaths {
multipath {
wwid 360050768018085dc7000000000000xxx
alias oradata03
}
}
blacklist_exceptions {
wwid "360050768018085dc7000000000000xx"
}Next, we need to remove wwids from the file by editing or using the “multipath -w” command.
# vi /etc/multipath/wwids # multipath -w 360050768018085dc7000000000000xxx wwid '360050768018085dc7000000000000xxx' removed
Explain the -w options ( multipath -help ):
-w Remove a device from the wwids file
Flush the DM device name using the -f option. From the above command, my dm was dm-8
# multipath -ll # multipath -f dm-8e
Removing SAN paths
Remove the device paths from the first command of multipath – you will see that my device paths are sde sdu sdm sdac.
Remove the devices found from “multipath -ll” or find the device name from the location below.
# 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 the ASM disk please delete the configuration from the udev rule and reload the configuration
Edit the udev rules under “/etc/udev/rules.d/”.
Then reload the rule
udevadm control --reload-rules && udevadm trigger
Thanks for your visit. Let us know if it works for you. Learn how to secure Linux VPS.



