How to remve an ISCSI disk from linux server without reboot

root's picture

Following I want to remove an unused disk, in our example it is "backups":

root@pluto:~# iscsiadm -m discovery -t sendtargets -p 192.168.69.1
192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:backups
192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:swap-pluto
192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:backups-file
root@pluto:~# fdisk -l /dev/sdc

Disk /dev/sdc: 375.8 GB, 375809638400 bytes
255 heads, 63 sectors/track, 45689 cylinders, total 734003200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

So you know the disk, all you have to do is to use the option -u against it:

iscsiadm -m node --targetname iqn.2014-07.ro.gz.sun:backups -u

The command output should look as follows:

root@pluto:~# iscsiadm -m node --targetname iqn.2014-07.ro.gz.sun:backups -u
Logging out of session [sid: 2, target: iqn.2014-07.ro.gz.sun:backups, portal: 192.168.69.1,3260]
Logout of [sid: 2, target: iqn.2014-07.ro.gz.sun:backups, portal: 192.168.69.1,3260] successful.
root@pluto:~# fdisk -l /dev/sdc
root@pluto:~#

Note: no output on fdisk command is exactly what we wanted.

END!

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content