Six Simple Steps to Remove a Storage Device (LUN) from Linux

There are situations where a storage device or LUN must be removed from running system without any issue.

This happens for a variety of reasons, but most commonly, when the storage team migrates to new storage.

In this scenario, the storage LUN has been configured as a logical volume disk (LVM) on the system.

In this tutorial, we will show you how to remove a storage device (LUN) from a Linux system with six simple steps.

Make a note: As a best practice, I would recommend backing up data from the device before removing it from the system. This is necessary if you want to restore the data to an earlier state.

Step-1: Identifying Device

Identify the device ‘/dev/sd[X]’ to be removed from the system using smartctl command. Assume that we are going to remove the named disk ‘sdf’, which is currently holding the ‘data’ mount point.

smartctl -a /dev/sdf |grep -i 'unit'

Step-2: Unmounting File System

First, you need to unmount the file system that you would like to release.

umount /data

Step-3: Removing /etc/fstab entry

Remove the mount point’s entry from the /etc/fstab file, otherwise it blocks the system on next reboot.

Step-4: Deactivating Volume Group

The vgchange command activates or deactivates one or more volume groups. We need to deactivate the respective volume group in order to removes it from the kernel table.

vgchange -an vg01

Step-5: Exporting Volume Group

Export the volume group. This prevents it from being accessed on the current host system and prepares it to be removed. Also, it flush any outstanding IO’s of the device.

vgexport vg01

Step-6: Removing Device from Linux Server

Finally, delete the block device, which is mapped against the storage LUN.

echo 1 > /sys/block/sdf/device/delete

Conclusion

In this tutorial, we’ve shown you how to remove a SAN disk or Storage Device (LUN) from Linux with six easy steps. This same procedure works in Red Hat (RHEL) and their clones.

If you have any questions or feedback, feel free to comment below.

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

One Comment on “Six Simple Steps to Remove a Storage Device (LUN) from Linux”

Leave a Reply to Jayabal Cancel reply

Your email address will not be published. Required fields are marked *