Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Force iSCSI Disconnect


(cross-posted from Superuser, because it's all crickets over there...)


I've been toying around with iSCSI for a little while (FreeNAS 11.1-U5 target, Win10 Pro (1803) initiator) and have run into what would be a bit of a deal-breaking issue: I can't seem to disconnect from an iSCSI target, regardless of what I try. All methods get a "The session cannot be logged out since a device on that session is currently being used" message, and fails to disconnect.


What I've tried:

  • Clicking Disconnect in the iSCSI Initiator panel
  • Running the equivalent command in PowerShell
  • Taking the disk offline in Disk Management first
  • Disabling the Microsoft iSCSI Initiator device in Device Manager (requires a reboot, not tenable)
  • Turning the iSCSI service off in FreeNAS (this works eventually, but I'd like to not have to do it this way, if I can help it)
  • Per other sources, I've removed all favorite targets and target portals in the iSCSI properties dialog first

The 'device' is not currently initiated in Windows, and therefore does not have a file system (so, if I understand correctly, cannot be accessed by the OS in a way that would hold the connection open); it's just a disk device at the moment.


My preferred behavior would be to disconnect on request (or at least, successfully force disconnect), so I can then connect from another machine, and then back again when necessary.


Thanks in advance for any ideas!



Hardware Details:

Win10 Pro System (desktop): Ryzen 5 1600X, 16GB RAM, NVMe boot drive, Mellanox ConnectX-2 (direct connection to server)

FreeNAS System (server): Core i3-4170, 32GB RAM, 4×10TB in RAIDZ2, Mellanox ConnectX-2 (direct connection to desktop)

Main System (Byarlant): Ryzen 7 3800XT | Asus B350-F Strix | Corsair H80i V2 | 16GB G.Skill DDR4 3200MHz CAS-14 | XFX RX 5600 XT THICC II | Samsung 960 PRO 512GB / Samsung 970 EVO 500GB / UMIS SSD 256GB / Crucial MX500 2TB / WD White 7200RPM 8TB | Corsair CX650M | Mellanox ConnectX-3 10G NIC | Anidees AI-07BW Case | Dell U3415W Monitor | Microsoft Modern Keyboard


TrueNAS Server (Veda): Xeon E3-1241v3 | Supermicro X10SLL-F | Corsair H60 | 32GB Micron DDR3L ECC 1600MHz | 4x 10TB WD Whites / 2x 1TB HGST 2.5" / 1x Samsung PM961 128GB SSD / 1x Kingston 16GB SSD | Seasonic Prime Fanless 500W | Mellanox ConnectX-3 10G NIC | LSI 9207-8i LBA | Fractal Design Node 804 Case (side panels swapped to show off drives)


Media Center/Video Capture (Jesta): Core i7-2600 | Asus H77M-PRO | Noctua NH-L12S | 16GB Crucial DDR3 | EVGA GTX750Ti SC | Sandisk UltraII SSD 64GB / Seagate 1.5TB HDD | Corsair CX450M | Hauppauge ImpactVCB-PCIe | Syba USB3.1 Gen 2 Card | LG UH12NS30 BD-ROM | Silverstone Sugo SG-11 Case


Laptop (Narrative): Lenovo Flex 5 81X20005US | Ryzen 5 4500U | 16GB RAM (soldered) | Vega 6 Graphics | SKHynix P31 1TB NVMe SSD | Intel AX200 Wifi (all-around awesome machine)

Laptop (Rozen-ZuluSony VAIO VPCF13WFX | Core i7-740QM | 8GB Patriot DDR3 | GT 425M | Kingston 120GB SSD | Blu-ray Drive | Intel 7260 Wifi (lived a good life, retired with honor)


Tablet (---): Samsung Galaxy Tab A 8" (crosses fingers)
Tablet (ReGZ): Asus T102HA (BIOS clock doesn't tick, loses time when sleep/off) (I kill tablets with disturbing regularity)

Tablet (Unicorn): Surface Pro 2 (battery will reset total capacity to current charge, leading Windows to think it's always 100% charged until it dies)

Tablet (Loto): Dell Venue 8 Pro (screen discoloration issues, wouldn't update to Windows 10)

Tablet: iPad 2 16GB (WiFi died, basically useless after that)


Testbed/Old Desktop (Kshatriya): Xeon X5470 @ 4.0GHz | ZALMAN CNPS9500 | Gigabyte EP45-UD3L | 8GB Nanya DDR2 400MHz | XFX HD6870 DD | OCZ Vertex 3 Max-IOPS 120GB | Corsair CX430M (?) | HooToo USB 3.0 PCIe Card | NZXT H230 Case


Camera: Sony ɑ7II (w/ Meike Grip) | Sony SEL24240 | Samyang 35mm ƒ/2.8 | Sony SEL50F18F | Sony SEL2870 (kit lens) | PNY Elite Perfomance SDXC cards

Link to comment
Share on other sites

Link to post
Share on other sites

If you turn the computer off and on again you should be able to click disconnect and it should work. I've had this issue.


I just say though is iSCSI a necessity? I played with it for a while myself and found there's no real benifit to using it unless you have a real specific application for it like a program that only works with local disks but you want the functionality of zfs or a remote system that manages your drives.


You're more likely better off sticking with SMB. This PC can let you set it up as a network drive so it shows up with a drive letter making it more easily accessible.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 7 months later...
  • 1 month later...
On 8/12/2019 at 6:29 PM, FECV said:

Just ran into this issue on Server 2019 so pretty much Windows 10 and my solution was stupid. I had task manager open which monitors disk I/O and once i closed that iSCSI initiator disconnected normally.

I know this is an old post, but I've always had this problem in various WIndows Server OSes and it was so consistent that I had just assumed that it was Windows being Windows. I finally got fed up and decided to revisit the issue again when I came across this post.


I almost always have Task Manager open, and I found that closing it resolved the issue for me as well. I did, however want to add some additional clarification:


While closing Task Manager fixed the issue, it is not the actual root of the problem. The problem is having Task Manager open with disk performance counters enabled. By default, these counters are disabled on Windows Server 2012/2012 R2/2016/2019; however, I would generally enable them on my Windows Server installs by opening the command prompt (or PowerShell) as an administrator and entering the following command:

diskperf -Y

The disk performance counters can also be disabled using the same command:

diskperf -N

This unfortunately hides the disk performance metrics in Task Manager, but I no longer receive a "The session cannot be logged out since a device on that session is currently being used." message when attempting to disconnect an iSCSI volume with Task Manager open. I don't even need to take the volume offline first; it just works. It's still best practice to take the volume offline from the disk management screen first though, just in case some other process is trying to access it.

Link to comment
Share on other sites

Link to post
Share on other sites

Task manager open will often also tell you "the disk is in use" when trying to safely eject a regular USB drive. Took me a while to link the 2, mostly becasue I never do it for drives other than my backup sets.

Desktop: i7-5960X 4.4GHz, Noctua NH-D14, ASUS Rampage V, 32GB, RTX3080, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Thermaltake Overseer RX1, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case


Dell XPS 2 in 1 2019, 32GB, 1TB, 4K


GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now