24

When I "safely remove" an external hard-drive from my file-manager (Thunar), the whole hard-drive is powered off and disappears from /dev. Therefore, I guess that under the hood, this is done by calling udisksctl power-off -b /dev/sdX which has the same effect.

I thought it should somehow be possible to bring the device up again. After having read https://stackoverflow.com/a/12675749, I thought that powering off is maybe done by writing to /sys/bus/usb/devices/usbX/power/control, but the sysfs seems to remain untouched.

So, how is it possible to power-on an external device again after powering it off with udisksctl? To me, it is annoying that I can not re-mount a partition after unmounting it from the file manager.

Binabik
  • 353
  • 5
    The unbind/rebind approach described here does work. However, it has the undesirable side-effect of resetting all other devices on that USB controller. This is bad if you have, say, another USB hard drive that you are accessing - you get I/O errors and an unwanted remount read-only. – Nate Eldredge Aug 07 '19 at 01:33
  • 1
    Take a look at this answer. It has many useful information which might be useful to you. – Masoud Gheysari Aug 11 '19 at 01:35
  • 3
    At some risk of asking the obvious, is unplugging/re-plugging in the external device an option? Or if there is a physical power switch on it, turning that off and back on? The first option is something that, to me, has just become a near-daily "second-nature" kind of thing. – Jim Aug 20 '19 at 23:06
  • 1
    @Jim that's what I do nearly every day, too. But it remains annoying. – Binabik Aug 23 '19 at 09:55
  • 1
    @Binabik I hear you. Windows is the same if you use the "safe removal" feature. – Jim Aug 23 '19 at 21:18
  • All I know is that to make an ESATA device be seen by lsblk I do echo "- - -" | sudo tee /sys/class/scsi_host/host2/scan (that is, if it's not auto-picked up / detected when plugged in) –  Sep 10 '19 at 14:24

1 Answers1

5

If Thunar is behaving like udisksctl power-off, then it is using usb_remove_store().

That means Thunar is being misfeature-compatible with Microsoft Windows. You can just use eject /dev/sdX from the command line instead to allow hardware to be safely removed. The only difference is that the LED light won't turn off. To un-eject, use eject -t /dev/sdX.

Here's a quote from Alan Stern (who actually wrote the Linux kernel code that performs the "remove" option):

In fact, the "remove" attribute works for any USB device, since all it does is disable the upstream port. But normally it's intended only for mass-storage devices. I was going to say that it's needed only for mass-storage devices, but that's not correct -- it isn't needed at all. Its main purpose is to make people who have been conditioned by Windows feel more comfortable, by turning off an LED on the device to indicate that removal is now safe.

hackerb9
  • 1,569