Skip to main content

How to Remove a Storage Device (LUN)

Before removing access to the storage device itself, it is advisable to back up data from the device first.
Afterwards, flush I/O and remove all operating system references to the device.
  1. Stop all access to the device that has to be removed.
  2. Unmount the device.
  3. Remove the device from any md and LVM volume that is using it.
  4. If a multipath device is being removed, run multipath -l and take note of all the paths to the device.
    When this has been done, remove the multipath device:

    # multipath -f device 
  5. Use the following command to flush any outstanding I/O to all paths to the device:

    # blockdev –flushbufs device 
    Remove any reference to the device's path-based name, like /dev/sd or /dev/disk/by-path or the major:minor number, in applications, scripts, or utilities on the system.
    This is important to ensure that a different device, when added in the future, will not be mistaken for the current device.
The final step is to remove each path to the device from the SCSI subsystem. The command to remove a path is:

# echo 1 > /sys/block/device-name/device/delete 
The older form of these commands:
 
# echo "scsi remove-single-device 0 0 0 0" > /proc/scsi/scsi 
is deprecated.
Where device-name may be sde, for example.
Another variation of this operation is:

# echo 1 > /sys/class/scsi_device/h:c:t:l/device/delete 
Where h is the HBA number, c is the channel on the HBA, t is the SCSI target ID, and l is the LUN.
The device-name and the h, c, t, l for a device from various commands, such as lsscsiscsi_idmultipath -l, and ls -l /dev/disk/by-* can be determined.
If each of the steps above are followed in order, then a device can safely be removed from a running system. It is not necessary to stop I/O to other devices while this is done.

Comments

Popular posts from this blog

Interpreting the output of lspci

On Linux, the lspci command lists all PCI devices connected to a host (a computer). Modern computers and PCI devices communicate with each other via PCI Express buses instead of the older Conventional PCI and PCI-X buses since the former buses offer many advantages such as higher throughput rates, smaller physical footprint and native hot plugging functionality. The high performance of the PCI Express bus has also led it to take over the role of other buses such as AGP ; it is also expected that SATA buses too will be replaced by PCI Express buses in the future as solid-state drives become faster and therefore demand higher throughputs from the bus they are attached to (see this article for more on this topic). As a first step, open a terminal and run lspci without any flags (note: lspci may show more information if executed with root privileges): lspci   This is the output I get on my laptop: 00:00.0 Host bridge: Intel Corporation Haswell-ULT DRA...

UNIX/Linux Advanced File Permissions - SUID,SGID and Sticky Bit

UNIX/Linux Advanced File Permissions - SUID,SGID and Sticky Bit After you have worked for a while with Linux you discover probably that there is much more to file permissions than just the "rwx" bits. When you look around in your file system you will see "s" and "t" $ ls -ld /tmp drwxrwxrwt 29 root root 36864 Mar 21 19:49 /tmp $ which passwd /usr/bin/passwd $ ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 22984 Jan 6 2007 /usr/bin/passwd What is this "s" and "t" bit? The vector of permission bits is really 4 * 3 bits long. Yes there are 12 permission bits,not just 9.The first three bits are special and are frequently zero. And you almost always learn about the trailing 9 bits first.Some people stop there and never learn those first three bits. The forth permission bit is used only when a special mode of a file needs to be set. It has the value 4 for SUID, 2 for SGID and 1 for the sticky bit. The other 3 bits have ...