Linux – delete the LUN and remove traces from OS

In my previous article explained about how to delete disk from ASM library. In this article will learn to delete the LUN and remove traces from server. This article applicable for deleting ASM disk, standard partitioned disk and LVM physical volume. These steps works well for Redhat and SUSE.

 

  1. Remove traces of deleted LUN/disk

Note: Be cautious in placing correct device names. Else you end up with data loss and broken server.

Step1: collect kernel device names of LUN

#multipath –ll mpatha
mpatha (360a98000486e616e504a512345678908)
[size=20 GB][features="1 queue_if_no_path"][hwhandler="0"]
\_ round-robin 0 [prio=16][active]
 \_ 3:0:1:24 sdba 67:64   [active][ready]
 \_ 3:0:3:24 sdda 70:128  [active][ready]
 \_ 4:0:2:24 sdga 131:96  [active][ready]
 \_ 4:0:3:24 sdha 133:0   [active][ready]
\_ round-robin 0 [prio=4][enabled]
 \_ 3:0:0:24 sdaa 65:160  [active][ready]
 \_ 3:0:2:24 sdca 68:224  [active][ready]
 \_ 4:0:0:24 sdea 128:32  [active][ready]
 \_ 4:0:1:24 sdfa 129:192 [active][ready]
  • Note down all kernel device names mapped with LUN. Collect device names one per line under file /tmp/device_names.
#cat /tmp/device_names
sdba
sdda
sdga
sdha
sdaa
sdca
sdea
sdfa

Step2: Delete disk partition

#kpartx -d /dev/mapper/mpatha
  • verify disk is deleted
#ls -ltr /dev/mapper/mpatha*

Step3: Remove the device from multipath

  • delete the multipath paths to LUN
#multipath -f mpatha
  • Remove the entry from multipath.conf
#cp –p multipath.conf multipath.conf_bkp
#vi multipath.conf
   (delete the entry associated with WWID which we got 
    from previous step (360a98000486e616e504a512345678908))

Step4: Flush any outstanding I/O to deleted device

  • device names collected from multipath –ll should be used here. Depends upon multipath configuration 4 or 8 device names will be available.
#for i in `cat /tmp/device_names` ; do ; blockdev –flushbufs devices /dev/$i ; done

Step5: Remove path to devices from SCSI subsystem

#for i in `cat /tmp/device_names` ; do ; echo 1 > /sys/block/$i/device/delete ; done

That’s all. At here we deleted the LUN mpatha (360a98000486e616e504a512345678908). Removed all the traces that LUN left from kernel and SCSI subsystem.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Przekazywanie portów TCP rinetd
Viewed 43908 times since Thu, May 24, 2018
RHEL: Extending the maximum inode count on a ext2/ext3/ext4 filesystem
Viewed 3427 times since Sun, May 27, 2018
20 IPtables Examples For New SysAdmins
Viewed 2334 times since Fri, May 15, 2020
Setup SSL Tunnel Using Stunnel on Ubuntu
Viewed 2829 times since Fri, Sep 28, 2018
Using renice and taskset to manage process priority and CPU affinity with Linux OEL 6.4
Viewed 3784 times since Mon, Feb 17, 2020
Modifying the inode count for an ext2/ext3/ext4 file system
Viewed 15548 times since Fri, Sep 18, 2020
“Too many authentication failures” with SSH
Viewed 6200 times since Mon, May 21, 2018
Linux ssh Hide OpenSSH Version Banner
Viewed 52081 times since Wed, Apr 22, 2020
logrotate Log Rotate Configuration
Viewed 3317 times since Sun, Jan 12, 2020
systemctl Use systemd to Start a Linux Service at Boot
Viewed 5950 times since Mon, Dec 7, 2020