Auto suspend of Usb devices

,

I am still pretty new to linux, particularly Fedora, having previously just used Ubuntu servers and desktops, and not as a major diver. What I’m attempting to figure out is how to keep my USB keyboard, mouse, and a few other USB devices from shutting down or suspending while the computer sleeps. I use CKB for my K100 keyboard and just had to delete openrazer because it was throwing so many issues.

My thought is to add a rule to udev/rules.d, explicitly inserting the device IDs, and do it that way, as I attempted to do it using grub but it threw a lot of errors and forced me to rebuild my operating system because it locked me out completely.

My other question, which I should write separately but might as well ask, is about mounting drives. In Ubuntu, you add the UUID to fstab; doing this in Fedora has caused me a lot of difficulties, so I’ve resorted to running a custom script to mount them as soon as I log in. Is there an easier or simpler method to do this?

I found a fix though it makes the power managment run a higher idle.

Added a script at /usr/local/sbin/usb-no-suspend.sh and proceded to

Bash code

#!/bin/bash

for path in /sys/bus/usb/devices/*/power/autosuspend; do
  echo -1 > "$path" 2>/dev/null
done

for path in /sys/bus/usb/devices/*/power/control; do
  echo on > "$path" 2>/dev/null
done

for path in /sys/bus/usb/devices/*/power/wakeup; do
  echo enabled > "$path" 2>/dev/null
done

Then i added in a systemd Service to have it run on boot at /etc/systemd/system/usb-no-suspend.service

adding in

[Unit]
Description=Disable USB autosuspend at boot
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/bin/bash /usr/local/sbin/usb-no-suspend.sh

[Install]
WantedBy=multi-user.target

This has seemed ot work and using powertop was able to confirm that it is working.

This is a limited fix as i dont know if this causes other issues but for now it is working.

seems i have to figure out most of my problems by reading the old post and then fixxing it with the new os as the only post i found discussing this was from Fedora 36 here is the reference How to disable USB + Bluetooth autosuspend
I know I am a New user of the os but not having anyone respond or even really look at my request kinda sucks but hey guess i am learning linux by bashing my head against a wall till it breaks down. Hope this helps anyone in the future although fedora 43 comes out so this is probably going to break on it.

P.S Let me know what if any actual fix can be had for this or if this is incorrect.

Your default fstab may contain entries such as

UUID=f17f245b-7d9f-4315-8c12-a555c37ca0e2 /                       ext4    defaults        1 1
UUID=c4eb1f4d-eaab-4b8a-a952-302402d8844d /boot                   ext4    defaults        1 2
UUID=52B5-5EC4          /boot/efi               vfat    umask=0077,shortname=winnt 0 2

To add entries for file systems to be mounted at boot time simply follow that template.
Note that all 6 fields are required and that the last 2 digits probably should be 1 2 since nothing else can be mounted before the root file system “/” is mounted. There are several options available for field 4, which allow configuring the mount as the user chooses.

Using entries in fstab is fairly easy. The file system UUID for each partition can be found by using lsblk -f and details about fstab can be found with man fstab.

1 Like

This is probably the issue i have been having as i have always just set it to 0 2 i should have realized that is the issue thank you.

I figured out why i was ussing an old system of mouning here was how i had it and wht it kept failing

UUID= /mnt/Games ext4 defaults,uid=1000,gid=1000 0 2
UUID= /mnt/video ext4 defaults,uid=1000,gid=1000 0 2
UUID= /mnt/Media ext4 defaults,uid=1000,gid=1000 0 2
UUID= /mnt/Data ext4 defaults,uid=1000,gid=1000 0 2

uid=1000,gid=1000, guess this is the way to do it for other drive types like ntfs or ext3 where it did not save permissions in the metadata for the drive when setteing permissions before.