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.
- Stop all access to the device that has to be removed.
- Unmount the device.
- Remove the device from any md and LVM volume that is using it.
- 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 - Use the following command to flush any outstanding I/O to all paths to the device:
# blockdev –flushbufs deviceRemove 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 lsscsi, scsi_id, multipath -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
Post a Comment