Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
60

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


33

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


28

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


27

Open this file with your text editor, let's use nano for example: sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf By default there is wifi.powersave = 3 Just change it to a value of 2. The change will be active upon the next reboot. The values for the powersave field are: NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the ...


26

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


25

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


24

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.


23

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.


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


19

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


19

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

You could use 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 list status of all hubs, their locations ...


17

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.


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


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


16

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


15

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


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.


14

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.


14

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

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


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


12

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


11

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


10

Computers generally don't track the current they are drawing. It is common that there are voltage sensors that are readable. Power consumption can vary widely over time depending on workload. CPUs now throttle back when load is low. Disks will shutdown when idle. Tools like powertop will track processes which trigger increases in power consumption. ...


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


9

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.


9

You need to change the DPMS settings, which are controllable with xset. You can disable all DPMS with: $ xset -dpms And re-enable them with: $ xset +dpms You can also control how long before the monitor switches into each state (standby, suspend, and off; they're explained in this Wikipedia article) by passing 3 integers for the number of seconds before ...


9

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


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