A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
68

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 ...


37

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 ...


36

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 ...


34

For Ubuntu and Debian, usbcore is compiled in the kernel, so create entries on /etc/modprobe.d will NOT work: 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" Note that quit ...


28

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.


28

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-states ...


27

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 ...


26

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.


22

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"}' /...


22

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/...


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

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 ...


19

Add the kernel options acpi=off apm=off to the contents of GRUB_CMDLINE_LINUX_DEFAULT in file /etc/default/grub Then run sudo update-grub Finally reboot your computer.


18

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).


18

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 ...


17

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 ...


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

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, ...


16

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....


15

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.


15

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 ...


14

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.


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 ...


12

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/...


11

You don't have a recognizable swap partition. Check that your swap partition is active: run cat /proc/swaps to see what swap space is in use. This may be a symptom of trying to hibernate to a swap file. See e.g. Ubuntu bug #313724. Some hibernation methods accept swap files, but this depends on both the hibernation method and the kernel version, and it ...


11

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


10

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, ...


10

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: ...


10

Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro. On Linux, umount / also happens to work, because it is effectively converted to the former command. That said, you don't need to worry about unmounting too much, unless You have mounted an old filesystem like FAT - as used by ...


9

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


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