Configuring Linux to work with 2 graphics devices

Posted on 2007-10-18
Last Modified: 2013-12-16
I own a Sony Vaio SZ notebook, which includes both an integrated Intel 945 graphics chipset as well as a GeForce 7400 chipset (which can be switched when the computer is turned off in order to choose between better battery life or better performance).

I have Ubuntu 7.04 installed, which was originally installed when I was using the Intel chipset. When later I switched to the Nvidia chipset, X crashed upon start. I then installed the Nvidia driver manually using the command line, and X started perfectly running at top performance.

The problem is that I am now unable to revert back to Intel when I want battery life. So I want to know if there is a simple way of switching between these devices easily, or, better yet, have Ubuntu automatically detect which graphics device is reconfire X accordingly upon boot? Under Windows Vista (preloaded with the notebook), this works wonderfully.

Question by:gsaito
    LVL 20

    Expert Comment

    ..."So I want to know if there is a simple way of switching between these devices easily..."
    There is a way of dong that , but is it easy for you , it all depends on your willingness to issue
    couple shell commands.
    Backup your current /etc/X11/xorg.config file ---->  sudo mv   /etc/X11/xorg.conf   /etc/X11/xorg.nvidia
    Then restart laptop with Intel graphic chipset enabled and let Ubuntu re-detect video card and create new xorg.conf  file with settings pertaining to Intel 945 video chipset. Most likely there is already a good one for
    Intel 945 video device if nVIDIA video driver installed made backup of previous xorg.conf. It would then be renamed to xorg.bak ( or eventually xorg.old )
    Now backup xorg configuration file for Intel video ---> sudo mv /etc/X11/xorg.conf  /etc/X11/
    As you may have realised by now you have now two valid xorg.conf file: one for your nVidia and one for Intel 945  video card.
    So, for example if you're running Ubuntu session with Intel945 in charge of your current video/display settings
    and you want to restart your laptop with nVIDIA video driver enabled simply issue command:
    sudo cp /etc/X11/xorg.nvidia  /etc/X11/xorg.conf
    to overwrite Intel 945 video configuration file .
    Next time you reboot laptop you'll have nVIDIA video driver taking care of your display.
    Same way, if you want to reboot laptop with Intel 945 video chipset enabled type similar command:
    sudo cp /etc/X11/  /etc/X11/xorg.conf
    reboot and Intel graphic driver will load for that session.
    Whole procedure could be simplifed and enhanced with other commands you may wish to include in
    bash script made for that purpose but I'm not really very good at bash shell scripting .
    For instance you can create bash script to check which video driver kernel module is currently loaded
    so you'll know exactly which of two commands I gave you  to run before rebooting laptop in order to load correct
    video driver.

    Author Comment

    Thanks a lot nedvis. This solution worked 99%, but the remaining 1% is what is annoying me... by the way, I am now using Ubuntu 7.10.

    I actually had originally installed Ubuntu with the Intel integrated chipset running. So I made the backup of
     the xorg.conf file to

    Then I switched to the NVIDIA chipset and rebooted. X would not start, and Ubuntu would not redetect the hardware, so I was left with a command line screen. I then installed the NVIDIA drivers from NVIDIA's website and then I was able to run X/Gnome perfectly.

    The problem happened when I tried to switch back to my integrated Intel chipset. I backed up xorg.conf to xorg.conf.nvidia and copied back to xorg.conf, then I rebooted. X/Gnome would load just fine, *but* compiz refuses to work now, although it would work perfectly before.

    So Gnome loads the 'classic' desktop (ie, no desktop effects). When I go to System -> Preferences -> Appearance -> Visual Effects and try to turn it on, I simply receive the message that "Desktop Effects could not be enabled". I'm puzzled because I am using the exact same xorg.conf file I had before installing the NVIDIA drivers, and desktop effects used to work just fine then.

    Any ideas?

    Author Comment

    I just realized this may be trickier than originally thought. Since my Intel configuration was now 'defective', I tried switching back to NVIDIA by copying xorg.conf.nvidia back to xorg.conf and rebooting. Much to my surprise, X would not load and reported several lines of errors. I had to run the NVIDIA driver installation utility (the one we download from NVIDIA's website) to get it running again... Maybe some other files that xorg.conf references are getting modified in the process of installing a new driver, therefore only switching xorg.conf files is apparently not sufficient.
    LVL 20

    Accepted Solution

    This is certainly problem related to the way Linux is loading video drivers.
    Basically , there are two different ways of how's kernel handling devices
    a- via in-line device drivers ( integrated in kernel )
    b- modular device drivers ( device kernel modules loaded on demand )
    The Ubuntu typical kernel has some drivers compile as part of kernel ( In case of Intel 945
    most likely in-line device driver) .
    Only device drivers compiled in-line are available to the kernel during the boot process:
    modular drivrs are only available after the system has been booted.

    My advice would be to go and download Ubuntu 7.10
    kernel SOURCES package ( new version you're running right now) and compile NEW kernel patched with nVIDIA modular device driver in separate directory , while leaving olde kernel -that works with Intel945- so you'll have actually
     TWO DIFFERENT KERNELS you can boot your laptop into:
    one for Intel 945
    one for nVIDIA
    GRUB boot loader menu would take care of that at system startup where you would select from GRUB menu what kernel to boot: either Inter945 or nVIDIA patched kernel.
    I'm doing same thing with my Debian Etch PC where I have one "generic" kernel and one
    which will call nVIDIA kernel module during system boot process.


    Author Comment

    Thank you nedvis. I have not yet tried it but it looks to be the solution. I will try it later and report back.
    LVL 20

    Expert Comment

    Thank you for the points, gsaito
    In meantime you might wish to read those couple links to get an idea on how to install and
    handle system with two different kernels :
    ============================ official======================================
    LVL 1

    Expert Comment

    It may be an old question, but being that a lot of people are still using their vaio sz notebooks (sz370 here) thought I'd post my solution from back in May '07 when I got it running seamlessly. Check my original post on the matter in the Ubuntu forums here to get the full list of links and scripts.

    Basically just create 2 xorg.conf files (one for each card) and put a script in /etc/rc2.d to load the necessary xorg.conf based on which card you have selected.

    Additionally, assuming you use 3D acceleration, you're going to want to have the script swap out the appropriate libGL files (nvidia and mesa) in /usr/lib as necessary for the selected card. It's easiest to do this by creating symlinks to the required files, so you can just change the symlinks instead of the scripts later on when updating drivers.

    It's full auto-detection and has been working great for me the last couple years (including in 8.04 Hardy Heron)

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now