Setting a default CPU Frequency in Ubuntu?

The correct way to do this in Ubuntu is:

  • Copy /etc/init.d/skeleton to scriptname and edit it to your needs.
  • Make it executable.
  • Install your script into the Debian runlevels via this command.

sudo update-rc.d scriptname defaults

  • Check that links to your script exist in other runlevels, e.g rc2.d, rc3.d. You can also confirm that this script is properly installed through the Administration->Bootup Manager GUI.

Check /etc/init.d/README for more detailed instructions and links to the specification document. You can also impose finer control over which run-levels your scripts runs on, and the priority it should get called at:

$ sudo update-rc.d dummy defaults
 Adding system startup for /etc/init.d/dummy ...
   /etc/rc0.d/K20dummy -> ../init.d/dummy
   /etc/rc1.d/K20dummy -> ../init.d/dummy
   /etc/rc6.d/K20dummy -> ../init.d/dummy
   /etc/rc2.d/S20dummy -> ../init.d/dummy
   /etc/rc3.d/S20dummy -> ../init.d/dummy
   /etc/rc4.d/S20dummy -> ../init.d/dummy
   /etc/rc5.d/S20dummy -> ../init.d/dummy
$ sudo update-rc.d -f dummy remove
 Removing any system startup links for /etc/init.d/dummy ...
   /etc/rc0.d/K20dummy
   /etc/rc1.d/K20dummy
   /etc/rc2.d/S20dummy
   /etc/rc3.d/S20dummy
   /etc/rc4.d/S20dummy
   /etc/rc5.d/S20dummy
   /etc/rc6.d/K20dummy

$ sudo update-rc.d -n -f dummy start 20 2 3 4 5 .
 Adding system startup for /etc/init.d/dummy ...
   /etc/rc2.d/S20dummy -> ../init.d/dummy
   /etc/rc3.d/S20dummy -> ../init.d/dummy
   /etc/rc4.d/S20dummy -> ../init.d/dummy
   /etc/rc5.d/S20dummy -> ../init.d/dummy
$ sudo update-rc.d -n -f dummy stop 20 0 6 .
 Adding system startup for /etc/init.d/dummy ...
   /etc/rc0.d/K20dummy -> ../init.d/dummy
   /etc/rc6.d/K20dummy -> ../init.d/dummy

Edit: The first step initially said to follow a template I provided with the answer, but I later realized that a standardized template exists so I've modified the answer accordingly.


(UBUNTU 9.10) There is already a script titled "ondemand" in the init.d that sets the cpu frequency, and if yours is not set after it does it's magic then yours will not work. An easy fix is if you edit the line that says "echo -n ondemand > $CPUFREQ" and change ondemand to powersave it will save you the headache of making your own.