So we Linux users have it rough sometimes. Features that people on the big commercial operating systems take for granted and never have issues with can happen to us at any moment.
And when that happens, we do what? Reach right back out to the open source community to figure out which text file we need to edit, and what commands we need to run.
Well I’ve got just such a treat for you today. Something that’s been troubling me and making my Linux life a little less joyous for a while now.
I run Pop!OS 20.04 on my main laptop and I’ve had a couple issues relating to “Suspend”:
- It wasn’t waking up from suspend
- I had to flip open my laptop to wake it up because I use a bluetooth keyboard
How I Fixed Suspend
This is going to be a short article, but for those who find it, I’m sure I will be loved.
First of all, I discovered that the suspend issue comes from memory not “sleeping” deep enough. I found an article covering this pretty quickly. But the fix was framed in terms of a GRUB setting.
Well.. that’s troubling because by brand newish machine runs UEFI, not grub… so my fix had more to do with a command called kernelstub, which I had never heard of before.
Anyway, here’s the line that fixed it for me, and the related Github discussion that covered it.
sudo kernelstub -a rcutree.rcu_idle_gp_delay=1 sudo kernelstub -a mem_sleep_default=deep sudo kernelstup -p
That adds an option help your machine know to really put memory to bed when you’re in suspend mode. This will also help you avoid discovering that the inside of your laptop bag is incredibly hot for no reason when your laptop should have been asleep.
The middle command is the one that really did the trick for me. The first one solves it on some machines. The last one is just to give you a print out of your current kernel settings.
How I Fixed Wake with Keyboard
First thing to know is that your linux machine thinks about Bluetooth as a USB device. So mostly what you want to do is figure out which USB bus is being taken up by your Bluetooth radio. Here’s how I did that.
First, go to your usb drivers directory
You’ll probably have an entry in there called btusb. Change into that directory and `take a look at what devices are named in there. For me it’s “1-10:1.0” and “1-10:1.1” which end up being my keyboard and mouse.
So now you can run this command
grep . /sys/bus/usb/devices/*/power/wakeup
Now this is going to tell you which of your USB devices are allowed to wake up the machine. You’ll get output kind of like this.
/sys/bus/usb/devices/1-10/power/wakeup:disabled /sys/bus/usb/devices/1-1.1/power/wakeup:disabled /sys/bus/usb/devices/1-1/power/wakeup:disabled /sys/bus/usb/devices/1-6/power/wakeup:disabled /sys/bus/usb/devices/4-1.1/power/wakeup:disabled /sys/bus/usb/devices/4-1.2/power/wakeup:disabled /sys/bus/usb/devices/4-1/power/wakeup:disabled /sys/bus/usb/devices/usb1/power/wakeup:disabled /sys/bus/usb/devices/usb2/power/wakeup:disabled /sys/bus/usb/devices/usb3/power/wakeup:disabled /sys/bus/usb/devices/usb4/power/wakeup:disabled
You can now type
echo enabled > /sys/bus/usb/devices/1-10/power/wakeup
And that will enable it. If you run that grep command again, you’ll get the same output, but your bluetooth device will say “enabled” and will be allowed to wake up your machine.
Not so fast, though. You only set it for the session. So there’s still a config file to edit to make it permanent.
Go ahead and add that “echo enabled … ” commanded to /etc/rc.local and save. Now it will be permanent.
You now have a hard earned feature on Linux that Mac and Windows users expect to work thoughtlessly.