I need to turn on/off an external usb hdd on my Proxmox VE 8 zimaboard832 (Debian 12 Bookworm) automatically. It's possibile with uhubctl? If it is, how can i make a turn_on/off bash script safely?


1 Answer 1


uhubctl doesn't turn off devices. It turns off the power to USB port the device is connected to. This has the effect of disconnecting and reconnecting the external device ("port off" causes a disconnect, "port on" causes it to renegotiate and reconnect).

So uhubctl may be able to do what you want... if the USB port, itself, is able to be controlled. Not all USB ports can be programmatically controlled in this way.

Now there's also udiskctl which can force a disk to disconnect. And there's also the eject command.

So there’s two main ways of “removing” a USB device. And which option is used depends on what file manager is used!

The first is a “soft eject”. This is what the eject command does, and also appears to be what “pcmanfm” does. In this scenario, eject -t will cause the partitions to reappear. This works because the device is still connected to the bus (and still shows in /dev/) and so the OS can control it. Depending on if your setup automounts devices or not, it may be safe to remove disks at this point. The device still has power.

The other is more “hard”. This is what udiskctl power-off and Nautilus does. Here the device is effectively removed from the bus and so disappears from /dev/


# /usr/bin/udisksctl power-off -b /dev/sdg
# dmesg | tail -1
[179677.977567] usb 1-2.2: USB disconnect, device number 10

We can see the kernel has reported the USB device has been disconnected. It no longer shows up in lsusb as a result. It's safe to remove this device.

Finally we can try to control the USB port itself.

That “usb 1-2.2” becomes important. This means USB bus 1-2, port 2.

We can use uhubctl to re-enabled it, by turning it off and on:

# /usr/sbin/uhubctl -l 1-2 -p 2 -a off  
Current status for hub 1-2 [0bda:5411 Generic 4-Port USB 2.0 Hub, USB 2.10, 4 ports]
  Port 2: 0101 power connect []
Sent power off request
New status for hub 1-2 [0bda:5411 Generic 4-Port USB 2.0 Hub, USB 2.10, 4 ports]
  Port 2: 0000 off

# uhubctl -l 1-2 -p 2 -a on 
Current status for hub 1-2 [0bda:5411 Generic 4-Port USB 2.0 Hub, USB 2.10, 4 ports]
  Port 2: 0000 off
Sent power on request
New status for hub 1-2 [0bda:5411 Generic 4-Port USB 2.0 Hub, USB 2.10, 4 ports]
  Port 2: 0101 power connect []

And it’s re-appeared again!

[179834.775058] usb 1-2.2: new high-speed USB device number 11 using ehci-pci
[179834.888056] usb 1-2.2: New USB device found, idVendor=0781, idProduct=5567, bcdDevice= 1.00
[179834.888063] usb 1-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[179834.888067] usb 1-2.2: Product: Cruzer Blade
[179834.888070] usb 1-2.2: Manufacturer: SanDisk
[179834.888074] usb 1-2.2: SerialNumber: 4C530000260115213093

Note that not all hubs can be controlled this way.

For hubs that do have "power control" uhubctl is a great way of powering down remote devices.

  • Many thanks. I've written to zimaboard support team to understand if usb has power control and then I'll try this.
    – Alessandro
    Mar 28 at 12:39
  • Zimaboard support system told me this: "Last week, we carefully evaluated this feature, and I believe it's currently not supported. It only supports signal recognition switching; power-level switching is not supported. I need to further evaluate the feasibility of implementation with the engineering and BIOS teams. Any suggestions or recommendations you have for the solution could greatly help us in altering our existing design and BIOS functionality. If I use an external usb-hub It could be possible to use the tricks that you described?
    – Alessandro
    Apr 17 at 10:55
  • @Alessandro Yes, where the motherboard doesn't support power control an external hub may support this. I can't provide any recommendations, though; it may be hit-or-miss. A cheap hub I bought off Amazon a decade ago supports it, just fine. Apr 17 at 11:28
  • which one did you buy? if I may ask, so I increase the chances that it will work..
    – Alessandro
    Apr 17 at 11:36
  • 1
    I've found a compatibility list here: github.com/mvp/uhubctl?tab=readme-ov-file
    – Alessandro
    Apr 18 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .