Category: Linux

power saving on laptop

One of the easiest way to make sure that you can have a decent battery life is

sudo yum install tlp smartmontools
sudo systemctl enable tlp
sudo systemctl start tlp

And after this you can check the status like this:

sudo tlp stat
— TLP 0.9 ——————————————–

+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=powersave
DISK_DEVICES=”sda sdb”
DISK_APM_LEVEL_ON_AC=”254 254″
DISK_APM_LEVEL_ON_BAT=”128 128″
SATA_LINKPWR_ON_AC=max_performance
SATA_LINKPWR_ON_BAT=min_power
AHCI_RUNTIME_PM_TIMEOUT=15
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersave
RADEON_POWER_PROFILE_ON_AC=high
RADEON_POWER_PROFILE_ON_BAT=low
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE=”sr0″
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
RUNTIME_PM_ALL=1
RUNTIME_PM_DRIVER_BLACKLIST=”radeon nouveau”
USB_AUTOSUSPEND=1
USB_BLACKLIST_WWAN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0

+++ System Info
System         = LENOVO Lenovo Y50-70 20378
BIOS           = 9ECN26WW(V1.09)
Release        = “Fedora release 25 (Twenty Five)”
Kernel         = 4.8.0-0.rc5.git1.1.fc25.x86_64 #1 SMP Tue Sep 6 15:52:10 UTC 2016 x86_64
/proc/cmdline  = BOOT_IMAGE=/vmlinuz-4.8.0-0.rc5.git1.1.fc25.x86_64 root=/dev/mapper/fedora_balp–fed–amitag-root ro nomodeset rd.lvm.lv=fedora_balp-fed-amitag/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=fedora_balp-fed-amitag/swap rhgb quiet resume=/dev/dm-1 LANG=en_US.UTF-8
Init system    = systemd
Boot mode      = UEFI

+++ TLP Status
State          = enabled
Last run       = 12:16:55 PM,    556 sec(s) ago
Mode           = AC
Power source   = AC

Notice: systemd-rfkill@.service is not masked — invoke “systemctl mask systemd-rfkill@.service” to correct this!
Notice: systemd-rfkill.service is not masked — invoke “systemctl mask systemd-rfkill.service” to correct this!

+++ Processor
CPU model      = —————————————————–

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   800000 [kHz]

 

xsos – a tool for sysadmins and support

Here is a very nice article that you may find useful

https://access.redhat.com/discussions/469323

ssh – remove offending key.

Whenever a system/server is re-installed or the host key changed for any reason, you would have seen the “host key verification failed”. And as usual you would have to go to known_hosts file and delete the offending key. I will show you 2 simple ways to do this here.

The output that you get in such scenario is:

Offending ECDSA key in ~/.ssh/known_hosts:4

First, you can use sed to directly delete the offending key with a command like this :

sed -i 4d ~/.ssh/known_hosts

So, if you see, we are using “-i” to do the changes inline and using “4d” command to delete the 4th line.

But being on Linux has the advantage that everything can be automated. So, lets do this in simpler way.

We will be using command called xclip for this, so get that intalled.

sudo dnf install xclip

Once that is done, add a alias in your bashrc file like this:

alias ssh-remove-key='a=( $(xclip -o|sed "s,:, ,") ) ; sed -i -e "${a[1]}d" ${a[0]}'

After this is done, whenever you get that error, copy the “<file>:line” portion and execute “ssh-remove-key” and the key is gone from file 🙂