Saturday, May 19, 2012

Forced to upgrade Brunbuntu and same old story again,  new release fixes a little and breaks some more. I swear, this is on purpose by Canonical to sell support (or to get testers for free). Neither of which I'm a big supporter of as it is deliberately not focusing on quality. Next time I promise, I'll go back to old-school and build my own distribution completely from source.

What's the point of messing around fundamentals in user-land like with init, network configuration, boot (grub 1, 2, x...) when it has been working fine in the past? Even Android is better in comparison. At least you know it's different so you don't expect thinks to be as they were... for like the past 2 decades! It's bad enough that Linux kernel isn't following industry standard POSIX 1003.1c & 2b API:s. (Yes, it could - but it doesn't for God only knows what reason.)

I feel like I'm getting ol an gray with all this rambling about...

Anyhow, back to the story: For my VGN-Z21WN-B laptop, I had difficulties getting X to use accelerated 3D NVIDIA drivers. With 10.04 one could just force X to use the correct driver by changing 3 files (see script below). After tearing my hair for 1/2 day, this bloke led me to what I was missing:

http://www.adhocism.net/2011/05/installing-ubuntu-11-04-on-sony-vaio-vpc-z13m9eb/

Turns out neither of all that is needed any more, except one detail:

/etc/default/grub and changed the GRUB_CMDLINE_LINUX_DEFAULT to “quiet splash acpi_osi=”. Now I reinstalled Grub by typing “sudo update-grub”. This enables static switching of the GPUs when restarting from Ubuntu.

Voilà!

No special kernel-module that needs recompiling for each new kernel-release, no script tweaking file-tree, no patching /etc/init/gdb.configand and so on...

Here's the old tweak-script for historical reference:


#!/bin/bash
# Set correct X drivers for Sony Vaio Z series
# (Tested on a VGN-Z21WN running Ubuntu 10.04)
#
#Useage: set-xdriver.sh [INTEL|NVIDIA]
# Parameter is optioal.
# If no argument is supplied, script will auto-detect GFX
#
# This script is inspired by the script found at:
# https://wiki.ubuntu.com/sonyvaioz
#
# Script is suitable to be called with no argument from
# /etc/init/gdm.conf
#
#pre-start script
# /etc/X11/set-xdriver.sh
#end script

set -e
set -u

function detect_HW() {

   if ( lspci | grep "00:02.1" >/dev/null) ; then
     echo "INTEL"

   else
     echo "NVIDIA"
   fi
}

function tweak_files() {
   if [ "x$1" == "xINTEL" ]; then
      echo "Setting X for [INTEL]"
      ln -sf /etc/X11/xorg.INTEL /etc/X11/xorg.conf
      ln -sf /usr/lib/mesa/libGL.so /usr/lib/libGL.so
      ln -sf /usr/lib/xorg/modules/extensions/libglx.so.INTEL /usr/lib/xorg/modules/extensions/libglx.so
   else
      echo "Setting X for [NVIDIA]"
      ln -sf /etc/X11/xorg.NVIDIA /etc/X11/xorg.conf
      ln -sf /usr/lib/nvidia-current/libGL.so /usr/lib/libGL.so
      ln -sf /usr/lib/nvidia-current/xorg/libglx.so /usr/lib/xorg/modules/extensions/libglx.so
   fi
}


function sanity_checks() {
   if [ $(whoami) != "root" ]; then
      echo "Error: This script must be run as root"
      exit -1
   fi

   if [ ! -f /etc/X11/xorg.INTEL ] ; then
      echo "Error: /etc/X11/ lacks separate xorg.conf file for INTEL"
      exit -1
   fi

   if [ ! -f /etc/X11/xorg.NVIDIA ] ; then
      echo "Error: /etc/X11/ lacks separate xorg.conf files for NVIDIA"
      exit -1
   fi

   if [ ! -f /usr/lib/xorg/modules/extensions/libglx.so.INTEL ] ; then
      echo "Error: Original libglx.so for INTEL missing. Did you make a copy?"
      echo "Get a new original from the package xserver-xorg-core if needed"
      exit -1
   fi

   if [ ! -f /usr/lib/nvidia-current/xorg/libglx.so ] ; then
      echo "Error: Package nvidia-current is not installed. Please Install it."
      exit -1
   fi

}

sanity_checks

if [ $# -eq 1 ] ; then
   GFX=$1
else
   GFX=$(detect_HW)
fi

echo "Setting X for [$GFX]"



3 comments:

  1. Problem on Debian 7.7 (wheezy) for non repo NVIDIA-Linux-x86_64-340.58.run

    Restore:

    sudo echo > /etc/X11/xorg.conf

    apt-get install --reinstall xserver-xorg-core

    ReplyDelete
  2. According to: https://packages.debian.org/wheezy/libs/glx-alternative-nvidia

    Use 'update-alternatives --config glx' to select an implementation.

    ReplyDelete
  3. From script invoked by apt-get above:

    Manual configuration required to enable Nvidia driver │
    │ │
    │ The Nvidia driver is not yet configured; it needs to be enabled in │
    │ xorg.conf before it can be used. │
    │ │
    │ Please see the package documentation for instructions.

    ReplyDelete