Monday, January 17, 2011

Tackling the Switchable graphics

Okay. The big issue to tackle. First let me preface this post with pointing out that I've written no actual original code here. I've just pieced together all the scripts and information from other more knowledgeable users who were kind enough to share their expertise with the community.

A note about this tutorial. I have it currently working on my laptop, the HP Envy 14. It should work for the other Hp Envy series laptops with hybrid graphics. From what I've been reading if you are here looking for a fix for the NVidia Optimus chipset you are still out of luck. At least as of this posting [17 January 2011]. The instructions included here should work for other laptops with ati/intel combinations. It should also work with other laptops with ati/ati combinations. I maintain that should statement until proven otherwise. If you have such a setup and use these directions please leave me a comment so that others will also know that they have hope ;-).

Also, so far the main purpose of this graphics switching is to improve battery life. Turning off a GPU saves a great deal of power. I'm researching right now if there is a way to enable hardware acceleration on the discrete graphics card if it is manually switched. As of right now the answer I have is it is not. To the best of my knowledge if you install the ATI Catalyst closed source drivers you will not have a working video setup any longer. I've tried twice during experimentation and been let down. I'll post an update to this article if I find a way to make it work, or find somebody else who does.

For the sake of giving credit where its due I'll list the blogs and forums and such that I used to piece this info together:

Now that we have that out of the way, I highly recommend you piece your way through those links to follow along. Its important I suppose, something about teaching a man to fish.

This blog is following my experience with Ubuntu specifically, the information can be used in other distributions with a little know how. This is important in this case because even the Debian derived distributions like Ubuntu, opensuse or xandros have some basic system level differences. Most of the directions and blogs detailing the work needed to get this working seemed to be based on Fedora. The big difference here is that Ubuntu do
esn't use a /etc/rc.local file. So copying the directions line for line won't work up front. Don't despair, there isn't a lot of difference, and I'll walk through the instructions.

Also, in a short time I hope to roll all these instructions into a script to make it a very easy install for other Ubuntu users.

How to Enable Switchable Graphics (Hybrid Graphics) in Ubuntu
1) Download my version of the rc.local script:
Now set the script as an executable, in the terminal:
"chmod +x local"

2) Change the username portion of the local script to your username

3) Move the local file from your home folder to /etc/init.d/local:
"sudo mv ~/local /etc/init.d/local"

4) Update rc! Now we tell the system that we added a bootup script:
"sudo update-rc.d local defaults 80"

5) Setup scripts to enable easy switching of cards.
This code is taken from the Hybrid Graphics link above. It can be copied and pasted from there, for convenience I've made it available for download:
I recommend saving the file to your home directory. As thats where my guide assumes its going.

In your terminal issue this command:
"cd ~; chmod +x"

6) Now download the shutdown script:
We'll be using this script to circumvent a bug that causes the fan to run at high speed at all times after a reboot if the power is not on for both cards at boot time. Thanks to the hybrid graphics in linux blog in the links above for this script and the time and effort spent troubleshooting the issue.

7) In the terminal:
"cd ~; chmod +x"

8) Now reboot.

Welcome back. You are just about done. Just need to make those handy scripts we downloaded a bit more accessible.

9) Right click on the top toolbar in some of its empty space and select "Add to panel"

10) Now select "Custom Application Launcher"

11) Now fill in the information below. Point the command portion directly at the script where-ever you happened to save it.

12) Now do the same for the shutdown script. Use the buttons to switch between graphics and shut down the machine.

Congrats. Now your battery life should be markedly improved.


  1. Hi Marc, thanks for putting all this info together. I also have an HP Envy 14 running Ubuntu 10.10. ATI card is off and PowerTop shows about 15 Watt power usage. The problem is that when I resume from standby, the power usage is much higher 25 W or more. Looks like this is a bug, do you see the same problem? Thanks

  2. I hadn't actually playing with powertop yet. In the process of gathering data with it now. i'll let you know what I find.

  3. New post made and I dropped you a line. I do have the same issue. So far I've found nothing easy that fixes it. Now I'm looking into it.

  4. This comment has been removed by the author.

  5. I was hoping for this, since forever!!
    Now I can happily run linux on my dm4.
    Best of best wishes!!

    But, hardware acceleration is the greatest issue when using switchable graphics. Hope the optimus and ati hybrid graphics use a shared system to use them, so the development may go together.

  6. Hello, thanks for the great info! I've been looking for solutions to these issues for a while now.

    When I use your local script, I get an error when I try to apply the update, telling me that I'm "Missing LSB information"... Did you get this problem, and was there anything specific you had to add to fix it? I tried looking at a few help pages for LSB, but the official wiki is down, and the other pages I saw gave examples that seemed a little to specific for their machines. Sorry for the noob blast!

  7. No problem Phil. Unfortunately I didn't run into that problem. Without more information or a similar problem I'm not sure what I can tell you. If you figure something out please feel free to drop me an email or a comment so I can add it to the tutorial

  8. Thank you for all your posts please keep us updated if you fin anything new :)

  9. It looks like the scripts you have for download are the older version, which unfortunately were broken for me in Ubuntu Maverick. I went to as referred in your article and used the updated scripts (as well as the package requirements and icons); the scripts are updated to support openbox and GNOME.

    Just as a suggestion, can you include the lines to download required packages and icons to your article, and update the downloadable scripts?

    Thanks for all of your hard work, and looking forward to future articles for Envy, especially regarding hardware acceleration.

  10. ...update on the missing LSB (Linux Standard Base) information issue I ran into while trying to use the init script:

    I found the info at
    to be useful. A brief summary is that I had to add the commented start/stop info as a header in my local script. I was worried that I might have to modify the numbers for default start/stop for my system, but testing it exactly as provided in the above link worked, so I'm leaving it as is. Hope this helps someone!

  11. For quick access, here is the header info from the above link to add to init.d/local (leave the hash marks in):

    # Provides: scriptname
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start daemon at boot time
    # Description: Enable service provided by daemon.

    I also ran their suggested commands to remove any (potentially corrupt) links and re-add them for good measure:
    sudo update-rc.d -f local remove
    sudo update-rc.d local defaults

  12. Still can't get it to work... After some searching, I found that for some reason there is no vgaswitcheroo in /sys/kernel/debug

    Any ideas on why it's missing? (I'm using Linux 2.6.35-27-generic)

  13. Found the problem. As mentioned in other sites, vga_switcheroo will magically disappear if you have the proprietary Radeon driver installed. This driver is called fglrx. So if Synaptic shows that you have fglrx on your machine, uninstall it and reboot - et voila, vga_switcheroo returns.

  14. Hey marc, i am having issues with the shutdown though am using the shutdown script to shutdown the pc. My system just hangs on the shutdown and i have to force shutdown pc using long press of the power button. I even tried using 'init' and 'shutdown' command. I still have the same issue. Do u think of any workaround or a soultion.?

    Thanks for all ur help. Its been great.

  15. I found this post and it certainly would be of much help, if Ubuntu would even boot up on my HP Envy 14. I installed Natty via Wubi and it went through the standard Ubuntu install screens. Once installation completes, the computer restarts and when the option to select between Windows 7 and Ubuntu appears, I select Ubuntu. Immediately following that selection, a cursor momentarily appears on a black background and then the monitor turns off (not just to the color black, but it is obvious the backlight is actually off.) The computer and fan continue to run, but absolutely nothing appears on the display. This occurs every time I attempt to run Ubuntu after a restart. Can anyone help me figure out what is going on and how it can be fixed? (Pardon the wordiness!)

  16. @Matthew: Durig boot, it seems that both graphic cards gets disabled and enabled with minimum brightness level.
    Once you select Linux from the Grub2 menu, wait a little bit (30 sec?) and then press the brightness key ( 4th from the ESC key). You should see the GDM login window.
    If the above does not work, boot in "Safe mode" from the grub menu. (You will still have to press the brightness level light later on just like above"and then you will see the login prompt.
    Login with your user name and do
    $sudo gdm. IT should also work.
    harringf at gmail dot com

  17. Is this problem solved now in the latest versions of fglrx?

  18. Hello.. I have a problem.. after resume from suspend mode fan run a high speed..

  19. HI SIR,
    I'M a newbee to ubuntu. Still trying to figure out the to shutdown the graphics card(ATI mobility Radeon Premium Graphics Card). I'm using ubuntu 11.10 beta (may be because someone else installed it). my laptop is hp dv-6. i have done the above steps. But there is no Custom Application Launcher in my ubuntu. no right click is happening to the above panal.
    Please help my laptop is too hot and didn't let me to touch its keys. !!!!!!help

    hey i found this
    done the whole thing
    In few days i send my feed back

  21. Hi, I totally disabled ATI card in ubuntu 11.10.
    # cat /sys/kernel/debug/vgaswitcheroo/switch
    1:DIS: :Off:0000:01:00.0

    Intel 3000 (sandy bridge default) seems to work quite well in 3.1 kernel. I am able to run unreal tournament 2004, alien-arena, nexuiz, serious sam 1 and 2, Xonotic, sauerbraten (very fast), postal 1, and humble indie games (except trine). The most shocking was when I checked Nexuiz fps on windows 7 both on power saver (intel 3000) and high performance(ati) mode with that on ubuntu. Nexuiz on ubuntu ultra high setting had 8.44 fps and on normal had 23.24 fps. On windows I could get only 8.006 fps on ATI (though graphics seemed good, can't say if its my illusion). Intel open source driver seems to improve a lot recently on ubuntu. There are still issues with wine. E.g in angry bird (windows version) I cannot see all the bricks. I still want ATI to run for my games. The problem with ATI is that if I enable it, computer locks and only way to get it started is hard reboot using power button. If you guys have switchable working please include in this post.

  22. Marc, I really have to hand it to you for this blog. It's been incredibly helpful to get hardware specific advice in my attempts to get Ubuntu up and running on my Envy 14.
    After struggling for hours upon hours with the switchable graphics, Phil's post above about uninstalling the fglrx driver for the Radeon driver was the only thing I could find on the web that would make switcheroo appear in my /debug/ folder. I highly recommend you add a section to this post mentioning that you must not have this driver installed for this fix to work. Hopefully it would save another user hours of their life working on this problem!


  23. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.

    123 HP Setup Envy 5540