Contenu | Rechercher | Menus

Annonce

Si vous rencontrez des soucis à rester connecté sur le forum (ou si vous avez perdu votre mot de passe) déconnectez-vous et reconnectez-vous depuis cette page, en cochant la case "Me connecter automatiquement lors de mes prochaines visites".
Test de l'ISO d'Ubuntu francophone : nous avons besoin de testeurs pour la version francophone d'Ubuntu 14.04. Liens et informations ici.

Attention, une faille de sécurité dans bash a récemment été rapportée, il est recommandé de mettre à jour son système (plus de détails)

#1 Le 24/04/2014, à 16:57

Nytrilik

[Tuto] Asus N56VZ Ubuntu gnome 14.04 : nvidia-prime+gdm+bbswitch

Hello,

I finally found a solution about black or white screen (depends of computer's mood) when you switch from power saving mode to performance mode (and reverse) on Optimus laptop + gdm.

Config :
Asus N56VZ
Ubuntu 14.04 Gnome amd64
kernel > 3.13.0-29-generic
Nvidia GT 650M  > 340.17-0ubuntu1~xedgers14.04.1
nvidia-prime > 0.6.2
bbswitch-dkms > 0.7-2ubuntu1
gdm > 3.10.0.1-0ubuntu4~trusty2

This tutorial will help you to fix the use of gdm with nvidia-prime and bbswitch by making an easy script for automatically switching from a card to an other.

--Dont reboot you're computer until the end of the procedure--

Start open terminal and delete nvidia previous version

sudo apt-get purge nvidia*
sudo apt-get autoremove

Install nvidia and intel free drivers (I didn't try but nvidia-current drivers probably work too).

sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install xserver-xorg-video-intel nvidia-331 ppa-purge

Install this ppa, it will fix a screen bug between drivers and gdm.

sudo add-apt-repository ppa:darkxst/gdm-prime
sudo apt-get update
sudo apt-get upgrade

Then go in x11 folder : '/etc/x11'. Drivers installation change 'xorg.conf' name to 'xorg.conf.mmddyyyy' (mmddyyyy = date of nvidia driver installation). So take this file, make a copy (you can keep it, there's no incidence on procedure) and rename the new created file in 'xorg.conf-nvidia'. Open it (you have to make these changes in root mode $ sudo gedit). Once the file is open on gedit, paste these lines into it :

Section "Monitor"
    Identifier "VGA-0"
    Option "Ignore" "True"
EndSection

In case of your file is missing or empty, I post my own 'xorg.conf-nvidia' file. If you use it please, don't forget to change 'Bus ID' for both cards, intel and nvidia

lspci -vnn | grep '\''[030[02]\]'

(the bus ID is on the left).

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "PCI:0@0:2:0"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
EndSection

Section "Monitor"
    Identifier "VGA-0"
    Option "Ignore" "True"
EndSection

Ok, now we're gonna make a executable script for switching from a config to an other, just create an empty file and paste the following commands into it. I named it 'optimus'. Don't forget to change its properties > “automatically execute as a program” (chmod +x '/folder/optimus').

#!/bin/bash

if [ $# = 0 ]; then
	echo "Use the one of following commands:"
	echo
	echo "1) sudo nohup $0 nvidia"
	echo "2) sudo nohup $0 intel"
	echo
	
	read command
	
	if [ "$command" = "1" ]; then
		sudo nohup "$0" nvidia
	fi
	
	if [ "$command" = "2" ]; then
		sudo nohup "$0" intel
	fi
	
	exit
fi


if [ `whoami` != "root" ]; then 
	echo "You must run it as root";
	exit
fi


if [ "$1" = "nvidia" ]; then
	gnome-session-quit
	service gdm stop

	tee /proc/acpi/bbswitch <<<ON
	sleep 2
	modprobe nvidia
	cp '/etc/X11/xorg.conf-nvidia' '/etc/X11/xorg.conf' 
	prime-select nvidia

	service gdm start
	service gdm restart
fi


if [ "$1" = "intel" ]; then
	gnome-session-quit
	service gdm stop

	rm '/etc/X11/xorg.conf'
	prime-select intel
	sleep 2
	rmmod nvidia
	sleep 2
	tee /proc/acpi/bbswitch <<<OFF

	service gdm start
	service gdm restart
fi

Then move it to '/usr/bin' folder (as root : sudo nautilus).

Next, create a new empty file, I named it 'xorg-delete' and paste the few lines below :

#!/bin/bash 
### BEGIN INIT INFO 
# Provides:          xorg-delete 
# Required-Start:    $remote_fs $syslog 
# Required-Stop:     $remote_fs $syslog 
# Default-Start:      
# Default-Stop:      0 1 6 
# X-Interactive:     true 
# Short-Description: remove xorg.conf 
# Description:       remove file '/etc/X11/xorg.conf'
#                    placed in /etc/init.d. 
### END INIT INFO 

prime-select intel
sleep 2
rm '/etc/X11/xorg.conf'
exit 0

Make it automatically executable (chmod +x '/folder/xorg-delete') and place it in 'etc/init.d'. I know it sounds weird to create a script just for remove a simple config file (prime-select is reset to intel mode at every boot session. So the line is useless but I keep it just in case) but if you reboot or shutdown you're computer in nvidia mode without remove 'xorg.conf', the intel card can't be properly used at start and you gonna get a black screen.

Enter this command in a terminal :

sudo update-rc.d xorg-delete stop 99 0 1 6 .

We finally finished with gdm and nvidia. To call the optimus script, enter 'optimus' in a terminal and follow instructions.
BUT don't do it now, we need to fix bbswitch before ! The following steps will help you to only launch intel card at start. Nvidia card will remain shutdown by default until you decide to activate it with the optimus script.

Open (root mode) 'etc/modules' and paste this line :

bbswitch load_state=0

You should have something like this :

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

lp
rtc
bbswitch load_state=0

Open gnome startup applications list :

gnome-session-properties

Remove : "Nvidia-x-server-settings" (if you installed it)

Ok, last step... Open (root) '/etc/rc.local' and paste just before the line "exit 0", the command

rmmod nvidia

And we're done !!

Reboot you're computer and be sure the nvidia card is 'OFF' at start and when you switch on the intel profile, then 'ON' on nvidia profile. Use this command.

cat /procc/acpi/bbswitch

NB : if you get a black screen at start after following this tutorial, don't panic, open a console tty (ctrl+f1) and call the 'optimus' script in intel mode. Then go back on this tutorial and check every steps. (I often bring some updates so keep an eye on it).

Hope, this tutorial will help many of you, stuck with nvidia-prime + gdm + bbswitch on optimus laptop. I'm a beginner on ubuntu and I couldn't be able to find those solutions without the help of Deve, Tim and ubuntu-fr's tutorials. Thanks to them.

Ciao

Dernière modification par Nytrilik (Le 24/06/2014, à 04:30)

Hors ligne

#2 Le 24/04/2014, à 17:19

Korak

Re : [Tuto] Asus N56VZ Ubuntu gnome 14.04 : nvidia-prime+gdm+bbswitch

Bonjour,

Je ne sais pas trop comment t'aider mais il faudrait un truc du genre:

Lancer ton fichier Optimus avec un paramètre.

Le paramètre sera (par exemple) on ou off.

Et suivant ce paramètre, tu actives une carte graphique ou l'autre.

Il faut donc que ton script récupère le paramètre donné en entrée de commande.


OS: Ubuntu 14.04 64 bits + Windows 8.1 64 bits en dualboot (BIOS UEFI, Secure Boot activé et table de partitions GPT)
PC portable HP Pavilion g7-2335sb: Processeur: AMD A4-4300M APU   Carte graphique: AMD Radeon HD 7420G   Mémoire vive: 6 Go RAM
Je suis Parrain-Linux

En ligne

Haut de page ↑