不满足于新安装的 Archlinux/Xfce4 里面仅能使用 Intel 的集成显卡,于是开始折腾如何启用 Nvidia 的独立显卡,我的这台老本本里带的是 GeForce GT500M。
先是卸载了之前误装的 nouveau,不过它的wiki相当不错,配套的 [freedesktop.org 页面](https://nouveau.freedesktop.org/wiki/CodeNames/#NVC0) 提供了完整的 Code Names,我的 GT500M 属于 NVC0 Family (Fermi 架构) 的 `NVD9 (GF119)` 。
在 Nvidia 的官网页面上 [Legacy Driver](https://www.nvidia.com/object/IO_32667.html) 里面可以看到 `390.xx Driver` 可以支持这款显卡。[Archlinux Nvidia 的 wiki](https://wiki.archlinux.org/index.php/NVIDIA#Minimal_configuration) 上也写得很清楚:
> For GeForce 400/500 series cards [NVCx and NVDx] from around 2010-2011, install the nvidia-390xx or nvidia-390xx-lts package.
于是执行最简步骤,顺利地安装了以下packages:
yay -S xf86-video-intel
yay -S mesa xf86-input-mouse xf86-input-evdev xf86-input-keyboard
yay -S nvidia-390xx nvidia-390xx-utils
接着安装 [“大黄蜂” 【bumblebee】](https://wiki.archlinux.org/index.php/Bumblebee),它是相当于 Nvidia Optimus 的一种技术,针对笔记本电脑的显卡切换提供无缝的支持,大多数情况下使用 Intel 的集成显卡来渲染,当需要的时候(例如游戏或是OpenGL调用)可以切换为 NVIDIA 独立显卡提供高帧率的渲染。
早期的计算机不具备这种能力,需要用户重启后在 BIOS 内进行手动的设置才可以,到了 2007 年左右,出现了初代的 Switchable Graphics 技术,但是仍然不受到用户的注意。
因此 2010 年左右 NVIDIA 推出了 Optimus 技术,简单来说,驱动程序将需要处理的 3D 渲染工作交给 GPU 做出运算处理,透过 PCI-E 将渲染结果穿给 Intel IGP 最终的图像输出到屏幕仍旧是 IGP 处理器来完成。这有点儿类似于当年 3DFX 加速卡将 3D 工作完成后交给 2D 显示卡做显示输出。由于 IGP 只是被当作一个简单的显示控制器,渲染是无缝切无闪烁的,对于用户来说不需要手动切换,更不需要重启计算机。
> Bumblebee is an effort to make NVIDIA Optimus enabled laptops work in GNU/Linux systems. Such feature involves two graphics cards with two different power consumption profiles plugged in a layered way sharing a single framebuffer.
> It tries to mimic the Optimus technology behavior; using the dedicated GPU for rendering when needed and power it down when not in use. The present releases only support rendering on-demand, ...
安装 Bumblebee 的命令如下:
yay -S bumblebee
sudo usermod -a -G bumblebee ${whoami}
sudo systemctl enable bumblebeed
安装好之后可以发现系统实际上屏蔽了 nvidia 的驱动,`lspci -vnn | grep -i -A10 vga` 可以发现居然识别不出独立显卡 VGA 设备(一开始我没有仔细阅读文档,一直困惑是哪里执行了错误的步骤或是 package 不对……)!
继续按照 wiki 的测试步骤,在桌面环境下
yay -S glxgears glxinfo
optirun glxgears -info
可以看到一个窗口弹出,显示三个齿轮转动的 3D 动画。`optirun` 实际上是启用了独立显卡来执行,所以在命令行里可以看到帧率相当高(1000+)。之后如果简单的执行 `glxgears -info` 会看到集显自己来渲染,帧率基本上只有 60 左右。
再往下可以执行 `optirun -b none nvidia-settings -c :8`,这条命令会启动 NVIDIA 的配置窗口,里面可以看到独显的具体技术参数等。
在 `/etc/bumblebee/bumblebee.conf` 里面确认选择的是 nvidia driver,然后查看 `xorg.conf.nvidia` 的配置项。基本上应该是不用修改的。 `/etc/X11/` 里面默认是不需要 `xorg.conf` 文件的,因为使用的依旧是集显。
至此,bumblebee 配置告一段落,后面有时间会再研究是否可以支持外接显示器。
参考资料:
1. [Archlinux - Nvidia 驱动安装血泪史](https://www.jianshu.com/p/eda410b53d5d)
2. [ArchLinux - 双显卡安装 NVIDIA 闭源驱动](https://gorgias.me/2017/01/17/Arch-Linux-%E5%8F%8C%E6%98%BE%E5%8D%A1-%E5%AE%89%E8%A3%85-NVIDIA-%E9%97%AD%E6%BA%90%E9%A9%B1%E5%8A%A8/)
评论