Linux Kernel3.7にNvidiaのドライバーを入れる方法

openSUSE12.3 RC2でLinuxのカーネルが3.7.10に

openSUSE 12.3 RC2を自作デスクトップマシンにアップグレードインストールして、Linuxカーネルのバージョンが3.7になりました。現在はカーネル3.7.10です。カーネルが最新になって快適なのですが、Nvidiaのグラボを挿しているため、Nvidiaドライバの再インストールが必要でした。LinuxのNvidiaドライバのインストールは色々鬼門になりやすいのですが、案の定、Kernelが先進的すぎてエラーになってハマったので、解決方法をメモします。

Nvidiaドライバのバージョン

今回試したのは、NVIDIA-Linux-x86_64-310.32.runです。

Kernel 3.7でハマったポイント

まず、普通にopenSUSE linuxをCUIモード(ランレベル3)で起動して、以下のコマンドでNvidiaドライバのインストールを試みました。

sh NVIDIA-Linux-x86_64-310.32.run

そうすると、途中で以下のエラーメッセージが出ました。

ERROR: The kernel header file '/lib/modules/3.7.1-16-desktop/build/include/linux/version.h' does not exist. The most likely reason for this is that the kernel source files in '/lib/modules/3.7.1-16-desktop/build' have not been configured.

これ、カーネルの階層構造が変わったために出るエラーのようです。以下のコマンドで回避できました。

ln -s /usr/src/linux-obj/x86_64/desktop/include/generated/uapi/linux/version.h /usr/src/linux/include/linux/version.h

再度インストールでまたカーネルエラーが発生

ただ、インストールを再実行すると以下のエラーが出ました。

If you are using a Linux 2.4 kernel, please make sure
you either have configured kernel sources matching your
kernel or the correct set of kernel headers installed
on your system.

If you are using a Linux 2.6 kernel, please make sure
you have configured kernel sources matching your kernel
installed on your system. If you specified a separate
output directory using either the "KBUILD_OUTPUT" or
the "O" KBUILD parameter, make sure to specify this
directory with the SYSOUT environment variable or with
the equivalent nvidia-installer command line option.

Depending on where and how the kernel sources (or the
kernel headers) were installed, you may need to specify
their location with the SYSSRC environment variable or
the equivalent nvidia-installer command line option.

何かKernel2.4とかと勘違いされているっぽいですね。以下のコマンドでこのエラーも出なくなりました。

cd /lib/modules/3.7.9-1.1-desktop/build/include/
ln -s generated/uapi/linux/

これでNvidiaドライバーはエラー無くLinux Kernel 3.7のシステムにインストールできました。

カーネルバージョンアップの注意点

2番目にハマったカーネル構造でgenerated/uapi/linux/へシンボリックリンクを張らなければならない問題は、カーネルアップデートのたびに実行する必要があるようです。NvidiaはLinuxコミュニティにあまり協力的な企業ではないのですが、Streamなどで海外ゲームも楽しめる環境が整いつつある今、カーネルの更新頻度の高速化に合わせた導入しやすいドライバーをリリースして欲しいと願ってやみません。

追記

@mforce4さんから以下のツイートを頂きました。

@miraihack 二番目のシンボリックリンクさえしてあれば、一番目のシンボリックリンクはしなくても大丈夫ですよ。

ありがとうございます。Nvidiaドライバをインストールする時は2番目のシンボリックリンクを貼るだけで大丈夫とのことです!