Thunderbolt is basically a PCIe bus exposed in the form of a user-friendly, pluggable interface. As you can imagine, hot-plugging a PCIe card in any machine isn't something you can expect to consistently do without problems - unless extreme care has been taken by the manufacturers of the host and removable devices as well as the developers of the mainboard firmware, device firmware, OS kernel, and device drivers.
All that is to say, there's a huge surface area of potential bugs and issues that would prevent this hot-plug from working the way we'd want it to. My recommendation would be to use a debug kernel and try to break into the debugger when it freezes - if you can, then it's probably not a hardware or firmware issue. Instructions on doing that are probably a little beyond the scope of the question or my reply here, but resources are available online that make this a bit easier.
Now if you want a means by which you can manually eject the device prior to yanking it, you can try the following:
After identifying the device address in the system in the output of lspci
command, where DDDD:BB:DD.F is the Domain:Bus:Device.Function of the thunderbolt peripheral in question:
05:00.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 06:00.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 06:03.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 06:04.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 06:05.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 06:06.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 07:00.0 System peripheral: Intel Corporation DSL3510 Thunderbolt Port [Cactus Ridge] (rev 03) 08:00.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Controller [Cactus Ridge] 09:00.0 PCI bridge: Intel Corporation DSL3510 Thunderbolt Controller [Cactus Ridge]
you can execute the following:
echo "1" | sudo tee /sys/bus/pci/devices/DDDD\:BB\:DD.F/remove > /dev/null
Which should trigger the unload routines in the kernel and the driver (and possibly even in the device firmware), after which you might be able to eject it more-safely. (A grep
in a subshell can obviously take the place of the DDDD:BB:DD.F for ease-of-use in the future).
Upon replugging the device, it might become necessary to manually rescan:
echo "1" | sudo tee /sys/bus/pci/rescan > /dev/null
(Or it might not be needed.)
I haven't used Linux in a while as I'm almost exclusively FreeBSD and OS X these days, so please forgive me if I'm off the mark on anything here.