Skip to content

Instantly share code, notes, and snippets.

@JuniYadi
Last active November 8, 2024 02:12
Show Gist options
  • Save JuniYadi/32688a363bb03f821e254cccfbe03239 to your computer and use it in GitHub Desktop.
Save JuniYadi/32688a363bb03f821e254cccfbe03239 to your computer and use it in GitHub Desktop.
Set Default CPU Frequency to Max CPU Speed
#!/bin/bash
echo "Install CPU Power"
apt install linux-cpupower -y
echo "Get Detail CPU"
cpupower frequency-info
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo "Setup Systemd"
tee /etc/systemd/system/cpupower-performance.service > /dev/null << EOF
[Unit]
Description=Set CPU governor to performance
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -g performance
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable cpupower-performance
systemctl start cpupower-performance
echo "Done"
echo "Get Detail CPU"
cpupower frequency-info
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
@JuniYadi
Copy link
Author

JuniYadi commented Nov 8, 2024

curl -sL https://gist.githubusercontent.com/JuniYadi/32688a363bb03f821e254cccfbe03239/raw | bash

@JuniYadi
Copy link
Author

JuniYadi commented Nov 8, 2024

Sample Output

root@rdp:~# curl -sL https://gist.githubusercontent.com/JuniYadi/32688a363bb03f821e254cccfbe03239/raw | bash
Install CPU Power
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcpupower1
The following NEW packages will be installed:
  libcpupower1 linux-cpupower
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1915 kB of archives.
After this operation, 2206 kB of additional disk space will be used.
Get:1 file:/etc/apt/mirrors/debian-security.list Mirrorlist [39 B]
Get:2 https://deb.debian.org/debian-security bookworm-security/main amd64 libcpupower1 amd64 6.1.112-1 [906 kB]
Get:3 https://deb.debian.org/debian-security bookworm-security/main amd64 linux-cpupower amd64 6.1.112-1 [1009 kB]
Fetched 1915 kB in 1s (1713 kB/s)    
Selecting previously unselected package libcpupower1.
(Reading database ... 26165 files and directories currently installed.)
Preparing to unpack .../libcpupower1_6.1.112-1_amd64.deb ...
Unpacking libcpupower1 (6.1.112-1) ...
Selecting previously unselected package linux-cpupower.
Preparing to unpack .../linux-cpupower_6.1.112-1_amd64.deb ...
Unpacking linux-cpupower (6.1.112-1) ...
Setting up libcpupower1 (6.1.112-1) ...
Setting up linux-cpupower (6.1.112-1) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u8) ...
Get Detail CPU
analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 800 MHz - 4.40 GHz
  available cpufreq governors: performance schedutil
  current policy: frequency should be within 800 MHz and 4.40 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 4.00 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil
schedutil
Setup Systemd
Created symlink /etc/systemd/system/multi-user.target.wants/cpupower-performance.service → /etc/systemd/system/cpupower-performance.service.
Done
Get Detail CPU
analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 800 MHz - 4.40 GHz
  available cpufreq governors: performance schedutil
  current policy: frequency should be within 800 MHz and 4.40 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 4.40 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
performance
performance
performance
performance
performance
performance
performance
performance
root@rdp:~# 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment