Get Nouveau Along with Nvidia and Make Them Switchable

In my previous post, I have mentioned, because of the poor support of Linux 3.13 and 3.14 kernel for Nvidia proprietary driver, I had tried a lot to get my nvidia graphics work. One of my ideas is to just use nouveau + Intel drivers. After days of continuous trying, finally I take a more flexible method, which could get nouveau driver along with nvidia proprietary driver, and these two combinations can be switched on boot.

The workaround is very simple. If you are using Gentoo, please modify your kernel configurations as below, which will compile nouveau driver as kernel module instead of in-kernel driver:

1
2
3
4
Device Drivers  --->
Graphics support --->
<*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
<M> Nouveau (nVidia) cards

Make sure to disable nvidia FrameBuffer support, which may cause problems when running X. After you made the modifications, just recompile the kernel and install it. Skip this step if you are using binary package-based distributions.

Then, in the configuration files under /etc/modprobe.d, remove the lines of “blacklist nouveau” and “blacklist nvidia”. Also, it is better to remove /etc/X11/xorg.conf file, however, I am not sure if it matters.

Now, configure your grub2, append the parameter modprobe.blacklist=XXX to your kernel line. For example, mine looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
menuentry 'Gentoo GNU/Linux with Nvidia' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-f0cc0adb-a9d2-4711-8d10-b8952882997c' {
load_video
insmod gzio
insmod part_gpt
insmod ext2
set root='hd2,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2 613a406f-0f4d-4216-b3ca-f5d2841f7db9
else
search --no-floppy --fs-uuid --set=root 613a406f-0f4d-4216-b3ca-f5d2841f7db9
fi
echo 'Loading Gentoo Linux ...'
linux /vmlinuz-3.13.3 root=UUID=f0cc0adb-a9d2-4711-8d10-b8952882997c ro rootflags=subvol=gentoo quiet init=/usr/lib/systemd/systemd modprobe.blacklist=nouveau
echo 'Loading initramfs...'
initrd /initramfs-3.13.3.img
}

menuentry 'Gentoo GNU/Linux with Nouveau' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-f0cc0adb-a9d2-4711-8d10-b8952882997c' {
load_video
insmod gzio
insmod part_gpt
insmod ext2
set root='hd2,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2 613a406f-0f4d-4216-b3ca-f5d2841f7db9
else
search --no-floppy --fs-uuid --set=root 613a406f-0f4d-4216-b3ca-f5d2841f7db9
fi
echo 'Loading Gentoo Linux ...'
linux /vmlinuz-3.13.3 root=UUID=f0cc0adb-a9d2-4711-8d10-b8952882997c ro rootflags=subvol=gentoo quiet init=/usr/lib/systemd/systemd modprobe.blacklist=nvidia
echo 'Loading initramfs...'
initrd /initramfs-3.13.3.img
}

As you can see, the first menuentry means to boot with nvidia + Intel drivers (nouveau disabled), and the second means to boot with nouveau + Intel drivers (nvidia disabled). I have tested this workaround on Gentoo and Linux Deepin, and it works like a charm. In theory, this workaround shall work for all distributions. And also, it seems current bumblebee could manage nouveau driver too.

However, for those binary package-based distributions, to make nouveau rendering work, you may need to install additional module packages, such as nouveau-dri.

Since this is only my simple test, there may be some potential problems. Welcome to correct me.

Also, you may refer to Gentoo wiki, however, the workaround mentioned in the wiki page possibly not work for your distribution.