80

If you are using systemd then use udisksctl utility with power-off option: power-off Arranges for the drive to be safely removed and powered off. On the OS side this includes ensuring that no process is using the drive, then requesting that in-flight buffers and caches are committed to stable storage. I would recommend first to unmount all filesystems on ...


62

Open this file with your favorite text editor, I use nano here: sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf By default there is: [connection] wifi.powersave = 3 Change the value to 2. Reboot for the change to take effect. Possible values for the wifi.powersave field are: NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default ...


41

For Ubuntu and Debian, usbcore is compiled in to the kernel, so creating entries in /etc/modprobe.d will NOT work. Instead, we need to change the kernel boot parameters. Edit the /etc/default/grub file and change the GRUB_CMDLINE_LINUX_DEFAULT line to add the usbcore.autosuspend=-1 option: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1&...


41

Assuming your governor is the intel_pstate (default for Intel Sandy Bridge and Ivy Bridge CPUs as of kernel 3.9). This issue is not specific to Arch, but all distros using the new Intel pstate driver for managing CPU frequency/power management. Arch linux CPU frequency scaling. Theodore Ts'o wrote his explanation on Google+: intel_pstate can be disabled ...


34

write a script! battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'` if [ $battery_level -le 10 ] then notify-send "Battery low" "Battery level is ${battery_level}%!" fi then cron it to run every few minutes or so. But yeah, if you can do it through the GUI, that's probably a much better way of doing it.


31

Take a look at this SuperUser Q&A titled: How do you check how much power a USB port can deliver?, specifically my answer. lsusb -v You can get the maximum power using lsusb -v, for example: $ lsusb -v|egrep "^Bus|MaxPower" Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub MaxPower 0mA Bus 002 Device 001: ID 1d6b:0002 ...


31

The current governor can be obtained as follows: cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor Note that cpu* will give you the scaling governor of all your cores and not just e.g. cpu0. This solution might be system dependent, though. I'm not 100% sure this is portable.


29

While researching Core 2 CPU power states ("C-states"), I actually managed to implement support for most of the legacy Intel Core/Core 2 processors. The complete implementation (Linux patch) with all of the background information is documented here. As I accumulated more information about these processors, it started to become apparent that the C-...


27

You could use my tool uhubctl - command line utility to control USB power per port for compatible USB hubs. It works only on hubs that support per-port power switching, but note that many modern motherboards have USB hubs that support this feature. To compile: git clone https://github.com/mvp/uhubctl cd uhubctl make To install system-wide as /usr/sbin/...


25

If your computer actually keeps track of power (e.g. notebook), than on kernel 3.8.11 you can use the command below. It returns power measured in microwatts. cat /sys/class/power_supply/BAT0/power_now This works on kernel 3.8.11 (Ubuntu Quantal mainline generic).


24

On my system I can obtain the power drawn from the battery from cat /sys/class/power_supply/BAT0/power_now 9616000 On Thinkpads if the tp_smapi module is loaded, the file is cat /sys/devices/platform/smapi/BAT0/power_now The value seems to be in µW, though. You can convert it with any tool you're comfortable with, e.g. awk: awk '{print $1*10^-6 " W"}' /...


21

Umount the filesystem and then run hdparm -S 1 /dev/sdb to set it to spin down after five seconds (replace /dev/sdb with the actual device for the hard disk). This will minimize the power used and heat generated by the hard disk.


21

See Controlling a USB power supply (on/off) with linux, short version, for newer kernels "suspend" does not work anymore: echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms" echo "auto" > "/sys/bus/usb/devices/usbX/power/control" But it doesn't literally cut the power, it signals the device to poweroff, it's up to the device to ...


20

According to the kernel tree documentation, the autosuspend idle-delay time is controlled by the autosuspend module parameter in usbcore. Setting the initial default idle-delay to -1 will prevent the autosuspend of any USB device. You should still be able to to enable autosuspend for selected devices. The usbcore.autosuspend kernel parameter can be set when ...


20

You are looking for udev, which detects changes to various system states, including plugging devices in (or unplugging them). You can script udev to take some action when a device is attached or removed. Udev is, frankly, pretty complex, and you will want to do some really basic tests to make sure that you are detecting what you are looking for. The basic ...


20

I ran into this with gdm3 after upgrading to Debian 10: whenever the computer was left at the initial login screen, it would go to sleep after a while. To fix this, I had to edit the power settings for GNOME when running the gdm3 session; these are stored in /etc/gdm3/greeter.dconf-defaults, and the lines to edit are those in the “Automatic suspend” section ...


19

You could also have a look at usb-devices: $ usb-devices | grep 'Product=\|MxPwr' S: Product=EHCI Host Controller C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA S: Product=EHCI Host Controller C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA S: Product=USB Keykoard C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=98mA ...


18

For my specific case, I can get the status of the lid with $ cat /proc/acpi/button/lid/LID0/state state: open I can then just grep for open or closed to see if it's open or closed.


18

That's caused by the latest gnome-settings-daemon updates... There is no such option in power settings because it was removed by the GNOME devs (the shutdown/power off action is considered "too destructive"). Bottom line: you can no longer power off your laptop by pressing the power off button. You could however add a new dconf/gsettings option (i.e....


17

Potential Method #1 I think you can do it with these commands: disable echo 0 > /sys/bus/pci/slots/$NUMBER/power enable echo 1 > /sys/bus/pci/slots/$NUMBER/power Where $NUMBER is the number of the PCI slot. lspci -vv may help to identify the device. This is not very well documented... Potential Method #2 I came across this thread on U&L, ...


17

umount is perfectly safe for the disk. Once you've done that you have successfully unmounted the filesystem and you needn't worry along those lines. The primary difference between eject and umount doesn't concern the disk at all - rather it is about the USB port's 5v power output. After umount you can still see your disk listed in lsblk because it is still ...


17

Do you have an iphone connected to the computer? This happens to me whenever I connect my iphone to it. Linux arjun-thinkpad 4.4.7-1-lts #1 SMP Thu Apr 14 17:26:39 CEST 2016 x86_64 GNU/Linux


16

Another KISS solution completing Adam's sugestion. This is for people who dont have a power_now file. (Arch) echo - | awk "{printf \"%.1f\", \ $(( \ $(cat /sys/class/power_supply/BAT1/current_now) * \ $(cat /sys/class/power_supply/BAT1/voltage_now) \ )) / 1000000000000 }" ; echo " W " Reports the actual power draw in Watts with one decimal place.


15

I have the same Laptop. Did you push the power button for more than one second? It needs some time to trigger the event.


14

systemd can handle this. I think this is what you need: Open the /etc/systemd/logind.conf (manual): HandlePowerKey: action on power key is pressed; HandleSuspendKey: action on suspend key is pressed. HandleHibernateKey: action on hibernate key is pressed. HandleLidSwitch: action when the lid is closed. The action can be one of ignore, poweroff, reboot, ...


14

I had the same problem none of the solutions here suited my needs. Using cron is really a workaround, not a solution, udev rules are run when power is connected/disconnected but not after suspending/resuming and pm-utils are no longer used by default in Fedora 19 when you for example close lid of your laptop. Since systemd is now responsible for suspending/...


14

For the record, the (up-to-date) cpufreq documentation is here. What does "statically" mean?To me, it contrasts with "dynamic", and implies frequency would never change, i.e. with powersave the CPU frequency would always be a single value, equal to scaling_min_freq You're right. Back in the old cpufreq driver days, there were two kinds of governors: ...


13

On Ubuntu 16.04 LTS, I successfully used the following to disable suspend: sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target And this to re-enable it: sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target


13

remove and rescan will allow the kernel to cycler-power the PCI device without reboot: echo "1" > /sys/bus/pci/devices/DDDD\:BB\:DD.F//remove sleep 1 echo "1" > /sys/bus/pci/rescan where DDDD.BB.DD.F = Domain:Bus:Device.Function


13

Here's a small script that checks for the battery level and calls a custom command, here pm-hibernate, in case the battery level is below a certain threshold. #!/bin/sh ########################################################################### # # Usage: system-low-battery # # Checks if the battery level is low. If “low_threshold” is exceeded # a system ...


Only top voted, non community-wiki answers of a minimum length are eligible