nvidia 内核配置
[*] Enable loadable module support --->
Processor type and features --->
[*] MTRR (Memory Type Range Register) support
Device Drivers --->
Graphics support --->
[*] VGA Arbitration
Device Drivers --->
Character devices --->
[*] IPMI top-level message handler
framebuffer 会和 nvidia 冲突,所以去除一些内核选项。
Device Drivers --->
Graphics support --->
Frame buffer Devices --->
<*> Support for frame buffer devices --->
< > nVidia Framebuffer Support
< > nVidia Riva support
Device Drivers --->
Graphics support --->
< > Nouveau (nVidia) cards
CONFIG_FB_EFI 使能时也会导致驱动有一些问题,所以需要配置如下:
Bus options (PCI etc.) --->
[*] Mark VGA/VBE/EFI FB as generic system framebuffer
Device Drivers --->
Graphics support --->
Frame buffer Devices --->
[*] Simple framebuffer support
X 配置
USE=“X”写入/etc/portage/make.conf.- 配置内核
Device Drivers --->
Input device support --->
<*> Event interface
Device Drivers --->
Graphics support --->
Frame Buffer Devices --->
<*> Support for frame buffer devices --->
## (Disable all drivers, including VGA, Intel, NVIDIA, and ATI, except EFI-based Framebuffer Support, only if you are using UEFI)
## (Further down, enable basic console support. KMS uses this.)
Console display driver support --->
<*> Framebuffer Console Support
注意: uefi framebuffer 也不能选择,参考 nvidia 部分,使用 simple framebuffer.
- 把
VIDEO_CARDS="nvidia"和INPUT_DEVICES="libinput synaptics"写入到/etc/portage/make.conf。portageq envvar INPUT_DEVICES可以用来查看当前的输入设备。 - 安装 xorg
emerge -av x11-base/xorg-drivers,emerge --ask x11-base/xorg-server。也可以把xorg-server替换为x11-base/xorg-x11,xorg-x11这个包比xorg-server大,多了很多字体和其他的一些东西,很多用不上,后面需要再专门安装缺少的。 env-update然后source /etc/profile
安装 nvidia 驱动
emerge -av x11-drivers/nvidia-drivers确保tools开启,会自动安装 nvidia-settings。gpasswd -a xyz video, 把用户加入到 vidio 组里面。
startx
- 切换到普通用户,然后运行 startx,发现报错,文件找不到等等,具体信息可以在
~/.local/share/xorg/Xorg.0.log里面找到。 - 配置文件在
/etc/X11/xorg.conf.d/, 示例在/usr/share/doc/xorg-server-${version}/xorg.conf.example.bz2 /etc/X11/xorg.conf.d/nvidia.conf里面写入:Section "Device" Identifier "nvidia" Driver "nvidia" EndSection- 经过仔细搜索发现这是个比较久的问题。18年的时候,就已经出现了。本质的原因是 xorg-server 的 suid 这个 USE 的问题, suid 能够让使用者的权限提升到拥有者的权限,在以前, xorg-server 会默认带有 suid,这样普通用户也可以 startx。后来 xorg-server 增加了 elogind 这个 use, 可以使用 elogind 而不是 suid,这样 普通用户也可以使用 startx 了,而且因为 systemd 的出现,新的 kde 等桌面,要不依赖 systemd,要不依赖于 elogind.
- 在 make.conf 里面的 USE 里面增加
elogind,这样全局开启elogind,然后emerge -avuDN @world, 然后emerge --depclean, `emerge rc-update add elogind boot把 elogind 增加到 boot 启动里面,否则 pam_elogind 会遇到问题。 参考: https://wiki.gentoo.org/wiki/Non_root_Xorg
https://wiki.gentoo.org/wiki/Elogind- reboot, 然后 startx 就只是提示没有 xterm 和 twm 了。
emerge -av xterm twm,然后再 startx 就ok 了。loginctl后面接不同参数实现不同功能,poweroffrebootsuspendhibernatehybrid-sleep这几个里面休眠还不能用,需要进一步配置,但是关机和重启是可以用的。- 如果希望休眠和恢复增加 hook,可以 写脚本放入
/lib64/elogind/system-sleep/,具体参考: https://wiki.gentoo.org/wiki/Elogind - 可以安装
x11-apps/mesa-progs来测试 nvidia 显卡。 startx 以后,输入glxinfo | grep direct可以查看结果。 还可以运行glxgears来查看 fps. - 如果 nvidia 内核模块进行了修改,那么修改了
/etc/modprobe.d/nvidia.conf之后,还需要update-modules,然后重新加载模块modprobe -r nvidiamodprobe nvidia
旧系统配置文件
配置文件主要在 /etc/X11/xorg.conf.d/,.xinitrc , /etc/X11/Sessions/ 这几个里面。
i3wm
echo ">=x11-wm/i3-4.18 doc" > /etc/portage/package.use/i3给 i3wm 增加 docemerge -av i3 dmenu i3status i3lock安装 i3wm 相关的软件,其中 i3status 可以用功能更强的 i3blocks 代替,i3bar 可以用 polybar 来代替。~/.xinitrc里面写入exec dbus-launch --exit-with-session i3表示使用 i3 作为窗口管理系统。startx启动 i3wm,选择默认首次配置地址,选择 win 按键作为 modifier 按键。
双显卡
可以参考 https://wiki.gentoo.org/wiki/NVIDIA/Optimus
参考:
https://wiki.gentoo.org/wiki/Xorg/Guide
https://wiki.gentoo.org/wiki/Non_root_Xorg
https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers