# Automatically set powersaving options on startup

## defer-

Powertop suggests the following powersaving options. How can i automatically set these options on startup? Is it possible with sysctl.conf or is there some other configs for these options?

```
ethtool -s eth0 wol d;

iw wlan0 set power_save on;

echo "disable" > '/proc/acpi/ibm/bluetooth';

echo '60' > '/sys/module/snd_hda_intel/parameters/power_save';

echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy';

echo 'min_power' > '/sys/class/scsi_host/host1/link_power_management_policy';

echo 'min_power' > '/sys/class/scsi_host/host2/link_power_management_policy';

echo 'min_power' > '/sys/class/scsi_host/host3/link_power_management_policy';

echo 'auto' > '/sys/bus/usb/devices/1-6/power/control';

echo 'auto' > '/sys/bus/usb/devices/4-1/power/control';

echo 'auto' > '/sys/bus/usb/devices/4-2/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.7/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:15:00.5/power/control';

echo 'auto' > '/sys/bus/pci/devices/0000:15:00.4/power/control';
```

----------

## amospalla

What about a shell script in /etc/local.d named for example /etc/local.d/powersaving.start with the content you wrote ?

----------

## haarp

/etc/udev/rules.d/10-local-powersave.rules (adjust for your own USB devices):

```
## PCI device autosuspend

ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"

## USB device autosuspend

# Only include known onboard devices of the Thinkpad W700/W701

# as other devices may not handle autosuspend well (input devices)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0765", ATTR{idProduct}=="5001", ATTR{power/control}="auto" # Colorimeter

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="08ff", ATTR{idProduct}=="2810", ATTR{power/control}="auto" # Fingerprint Reader (W700)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="147e", ATTR{idProduct}=="2016", ATTR{power/control}="auto" # Fingerprint Reader (W701)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0a5c", ATTR{idProduct}=="2145", ATTR{power/control}="auto" # Bluetooth (W700)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0a5c", ATTR{idProduct}=="217f", ATTR{power/control}="auto" # Bluetooth (W701)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", ATTR{idProduct}=="1008", ATTR{power/control}="auto" # Lenovo Hub

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", ATTR{idProduct}=="480c", ATTR{power/control}="auto" # Webcam (W700)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", ATTR{idProduct}=="4816", ATTR{power/control}="auto" # Webcam (W701)

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", ATTR{idProduct}=="6004", ATTR{power/control}="auto" # Tablet

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", ATTR{power/control}="auto"                          # USB Hub

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="8087", ATTR{idProduct}=="0020", ATTR{power/control}="auto" # Intel USB Hub
```

/etc/modprobe.d/local.conf:

```
options snd_hda_intel powersave=1
```

/etc/bluetooth/main.conf:

```
# What value should be assumed for the adapter Powered property when

# SetProperty(Powered, ...) hasn't been called yet. Defaults to true

####InitiallyPowered = true

InitiallyPowered = false

# Remember the previously stored Powered state when initializing adapters

####RememberPowered = true

RememberPowered = false
```

pm-utils takes care of the others when AC is unplugged:

To enable SATA ALPM (did produce hangs when entering suspend on one of my laptops): /etc/pm/config.d/local:

```
SATA_ALPM_ENABLE="true"
```

If the following command  fails, add pcie_aspm=force to your kernel command line

```
echo powersave >/sys/module/pcie_aspm/parameters/policy
```

Wifi should switch to powersave mode by default

----------

## defer-

Thanks for advices. Heres how i did :

/etc/udev/rules.d/10-local-powersave.rules

```

# PCI runtime power management

ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"

# USB autosuspend

ACTION=="add", SUBSYSTEM=="usb", ATTR{power/control}="auto"

ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="60"

# SATA active link power management

SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"

# Wlan power save

ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/sbin/iw %k set power_save on"

# Disable bluetooth

SUBSYSTEM=="rfkill", ATTR{type}=="bluetooth", ATTR{state}="0"

# Disable wake-on-LAN

ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*" RUN+="/usr/sbin/ethtool -s %k wol d"
```

/etc/local.d/powersave.start

```
echo "disable" > /proc/acpi/ibm/bluetooth
```

----------

