How to delete iscsi target from initiator? How to remove inactive iscsi target? Remove iscsi storage target from initiator? Remove iscsi virtual disk on CentOS / RHEL 7 Linux.

How to delete iscsi target from initiator ( CentOS / RHEL 7 ) Linux

In my earlier article I shared a step by step guide to configure iscsi target and initiator to setup a multipath SAN storage using your CentOS / RHEL 7 Linux machine. In the same article I had given brief steps to remove or delete iscsi target. Anyhow here I will share the steps to delete iscsi target on CentOS / RHEL 7 Linux in detail.

 

Steps to delete iscsi target

  • Remove iscsci entry from /etc/fstab (if any)
  • Un-mount the iscsi disk
  • Disconnect the iscsi disk from that target
  • Delete the connection
  • Go have a beer (if you drink one)

 

Update /etc/fstab

Firstly make sure you remove the iscsi entry from /etc/fstab of the target you wish to remove.

Assuming you wish to remove the iscsi target visible as /dev/sdc from our last article. Get the UUID of /dev/sdc using blkid as shown in the below example

# blkid /dev/sdc
/dev/sdc: UUID="f87DLO-DXDO-jjJ5-3vgO-RfCE-oOCA-VGploa" TYPE="LVM2_member"

Here UUID for /dev/sdc is f87DLO-DXDO-jjJ5-3vgO-RfCE-oOCA-VGploa. So look out for this UUID in /etc/fstab and remove that entry.

 

Un-mount the disk

Now it is time to un-mount your disk before we go ahead with deleting the target. You can manually unmount the disk using umount

# umount /mount_point

Assuming /dev/sdc was mounted on /clusterfs as was on our last example, we can unmount the disk by using

# umount /clusterfs

 

Disconnect the iscsi disk from that target

If you need an iSCSI connection not to be restored after reboot, you first have to log out to disconnect the actual session by using below command

[[email protected] ~]# iscsiadm --mode node --targetname iqn.2018-12.com.example:servers  --portal 10.0.2.13 -u
Logging out of session [sid: 1, target: iqn.2018-12.com.example:servers, portal: 10.0.2.13,3260]
Logout of [sid: 1, target: iqn.2018-12.com.example:servers, portal: 10.0.2.13,3260] successful.
NOTE:
Repeat this command for every iscsi target you wish to remove/delete.

 

Delete the connection

Now is the time to delete your iscsi target connection on the initiator node.

# iscsiadm --mode node --targetname iqn.2018-03.com.golinuxcloud:tgt1 --portal 10.0.2.13 -o delete
NOTE:
Similarly repeat this command for every iscsi target which you wish to delete.

 

Stop the iscsi service (optional)

If you have deleted all the iscsi targets from your setup then you do not any additional daemon running on your initiator node.

So you can stop the iscsid daemon

# systemctl stop iscsid
# systemctl disable iscsid
IMPORTANT NOTE:
If you are deleting only some of the iscsi target, and others are still connected then do not disable or stop this service.

So all good, time to have a beer.

 

Lastly I hope the steps from the article to delete iscsi target on RHEL/CentOS 7 Linux was helpful. So, let me know your suggestions and feedback using the comment section.

1 Comments

Leave a Reply

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