After struggling with ondemand for a while, I will share how to permanently disable it in Ubuntu and its derivates.
Install cpufrequtils:
sudo apt-get install cpufrequtils
Then edit the following file (if it doesn't exist, create it):
sudo nano /etc/default/cpufrequtils
And add the following line to it:
GOVERNOR="performance"
Save and exit.
Now you need to disable ondemand daemon, otherwise after you reboot the settings will be overwritten.
sudo update-rc.d ondemand disable
And you are done!
You can check your settings with:
cpufreq-info
It will show a block of information for every core your processor has. Just check if all of then are in performance mode, and at the maximum speed of your processor.
Update:
The Debian Wiki says that sysfsutils is necessary in order to maintain the settings across reboots, but that is untrue. Also, enabling sysfsutils make my system unstable, so it's not recommended.
Sorry if I misspelled something. :)
Sources: