Removing automatically attached SCSI devices

Red Hat Enterprise Linux 9.2 LPAR mode z/VM guest

When running with NPIV and automatic LUN scan, you can temporarily delete a SCSI device by writing 1 to the delete attribute of the directory that represents the device in the sysfs SCSI branch.

About this task

See Mapping the representations of a SCSI device in sysfs about how to find this directory.
Note: These steps delete the SCSI device only temporarily, until the next automatic or user triggered Linux® SCSI target scan. The scan automatically adds the SCSI devices again, unless the LUNs were deconfigured on the storage target. To permanently delete SCSI devices, you must disable automatic LUN scannning and configure all LUNs manually, see Manually configured FCP LUNs and their SCSI devices.

Procedure

Issue a command of this form:
# echo 1 > /sys/bus/scsi/devices/<device>/delete

Example

In this example, an SCSI device with LUN 0x4010403700000000 is to be removed. Before the device is deleted, the corresponding device in the sysfs SCSI branch is found with an lszfcp command.
# lszfcp -l 0x4010403700000000
0.0.3d0f/0x500507630300c567/0x4010403700000000 0:0:3:1077362704
# echo 1 > /sys/bus/scsi/devices/0:0:3:1077362704/delete