I’ve searched far and wide, but all I found on the subject was for Linux kernel 2.6 and below.
My question is this, I want to suspend power to a USB on a schedule, and plan to do that in a bash script, that script will also have a rsync function. My issue is, how can I suspend a USB port in kernel 5.10? As I mentioned, all the methods are for 2.6.
A bit more on my use case. I want to have 3 external hard drives connected via USB to my NAS, and have portions of the NAS backed up to those drives on a daily basis.
However, I do not want them to stay up and running the whole time, nor do I want to connect and disconnect them daily.
Consider letting Linux put the hard drives into sleep modus when idle.
The following will instruct Linux to put drive sda to sleep when idle for 5 minutes. It only has to run once at boot time.
hdparm -S 60 /dev/sda
Linux will wake the drive up when needed. No scripting necessary.
hey and thanks for replying.
Sleep is not powered off completely, I want to cut power to that port so that in the case of a surge or something it would not flow to it when it’s off.
That is not how that stuff works.
You can only kill power to the USB bus, not the individual ports, and that would be done by your bios. If you have other devices on that bus, you can cause some issues down the road.
Low power and sleep, suspend is managed by the OS but it sends uEFI commands to the controller to do the actual work.
If you are trying to do backups on a schedule, killing the ports without verifying the backups are complete would cause data corruption. Have you figured out how to check and verify backups are completed first?
Well of course I would not kill them while the rsync is running. That’s the whole point of the script, step 1 make sure the port is active, step 2 start rsync, step 3 kill the port. Step 3 would not execute until step 2 is finished.
So what you’re saying is it was possible before kernel 2.6, but no one has found a solution to do this since?
Not exactly but now everything runs a micro-controller with its own firmware. With modern machines, there is less controlling the hardware and more of a “talking to firmware that controls the hardware” type of thing. You will more than likely need to dig deep into the EFI variables of your specific hardware to see if it is possible to control individual buses, let alone individual ports.
Oh, wow. Somehow I imagined it will be much easier. I did come across a piece of software that can control USB Hubs, but only specific ones.
This one, so if all else fails, I’ll go that route.