Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I get Ubuntu to select a default cpufreq on boot? These are the frequencies my CPU has available:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2300000 2200000 2000000 1800000 1000000

I want 2200000 set as default. I have learnt that running the following command will do just that:

$ cpufreq-selector -f 2200000

My question is how do I get that to run on boot and stay default?

share|improve this question

migrated from stackoverflow.com Aug 12 '09 at 13:42

This question came from our site for professional and enthusiast programmers.

4  
This is a question for superuser.com –  Ricket Aug 12 '09 at 13:39
    
(blog.stackoverflow.com/2009/07/…) –  Ricket Aug 12 '09 at 13:40
    
I agree. voting to close –  Randolpho Aug 12 '09 at 13:41
1  
Also, to answer Jim's question: embraceubuntu.com/2005/09/07/… –  Randolpho Aug 12 '09 at 13:41
    
You should change the title to something more appropriate. –  nagul Aug 12 '09 at 14:41

5 Answers 5

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.

share|improve this answer

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

share|improve this answer
    
Or disable ondemand on startup and copy it to a new name appropriate to your situation and then enable that one. –  MT. Mar 16 '10 at 4:29
    
do this: sudo update-rc.d ondemand defaults –  Hendy Irawan Aug 26 '11 at 12:11
    
Powersave doesn't actually save power, and often uses more than ondemand. –  psusi Apr 12 '12 at 14:06

On a simple case like this one I would add a line with the command to /etc/rc.local, before the "exit 0".

For more complex init scripts, follow nagul answer.

share|improve this answer

Write a script to execute your command, then put the script in your /etc/init.d directory.

It'll then be run at startup

share|improve this answer
    
Scripts in /etc/init.d are not automatically executed. –  bohan Sep 10 '12 at 0:14

Follow the steps:

1. edit /etc/rc.local :  sudo gedit /etc/rc.local
2. add the line berofe exit 0:  cpufreq-selector -f 2200000 [add sudo if it need]
3. save the file and exit
4. you can run the for current session : sudo /etc/rc.local
5. From next session this script will automatically run
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.